From 6d2eb0485b77962dc1eec007b07b5e8696e64a18 Mon Sep 17 00:00:00 2001 From: Daniel Cunha Date: Mon, 10 Jan 2011 23:55:38 -0300 Subject: [PATCH] Fixes problem of downloading a file after press save button at article edition --- app/controllers/my_profile/cms_controller.rb | 6 +++++- test/functional/cms_controller_test.rb | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 7c27705..3d8aeb9 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -94,7 +94,11 @@ class CmsController < MyProfileController @article.last_changed_by = user if @article.update_attributes(params[:article]) if !continue - redirect_to @article.view_url + if @article.content_type.nil? || @article.image? + redirect_to @article.view_url + else + redirect_to :action => (@article.parent ? 'view' : 'index'), :id => @article.parent + end end end end diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index a52598b..2421d2c 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -1551,4 +1551,29 @@ class CmsControllerTest < Test::Unit::TestCase assert_tag :a, :content => "An image" end + should 'update image and be redirect to view_page' do + image = UploadedFile.create!(:profile => @profile, :uploaded_data => fixture_file_upload('files/rails.png', 'image/png')) + post :edit, :profile => @profile.identifier, :id => image.id, :article => { } + assert_redirected_to image.view_url + end + + should 'update article and be redirect to view_page' do + a = fast_create(TextileArticle, :profile_id => @profile.id) + post :edit, :profile => @profile.identifier, :id => a.id, :article => { } + assert_redirected_to a.view_url + end + + should 'update file and be redirect to cms' do + file = UploadedFile.create!(:profile => @profile, :uploaded_data => fixture_file_upload('files/test.txt', 'text/plain')) + post :edit, :profile => @profile.identifier, :id => file.id, :article => { } + assert_redirected_to :action => 'index' + end + + should 'update file and be redirect to cms folder' do + f = fast_create(Folder, :profile_id => @profile.id, :name => 'foldername') + file = UploadedFile.create!(:profile => @profile, :uploaded_data => fixture_file_upload('files/test.txt', 'text/plain'), :parent_id => f.id) + post :edit, :profile => @profile.identifier, :id => file.id, :article => { :title => 'text file' } + assert_redirected_to :action => 'view', :id => f + end + end -- libgit2 0.21.2