diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 52857e0..a7bfcf2 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -169,7 +169,7 @@ class CmsController < MyProfileController profile.home_page = @article profile.save(false) session[:notice] = _('"%s" configured as home page.') % @article.name - redirect_to :action => 'view', :id => @article.id + redirect_to (request.referer || profile.url) end def upload_files diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index b840ce5..f8a8016 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -115,9 +115,7 @@ class CmsControllerTest < Test::Unit::TestCase post :set_home_page, :profile => profile.identifier, :id => a.id - assert_redirected_to :action => 'view', :id => a.id - - profile = Profile.find(@profile.id) + profile.reload assert_equal a, profile.home_page end @@ -133,12 +131,18 @@ class CmsControllerTest < Test::Unit::TestCase post :set_home_page, :profile => profile.identifier, :id => a.id - assert_redirected_to :action => 'view', :id => a.id - - profile = Profile.find(@profile.id) + profile.reload assert_equal a, profile.home_page end + should 'redirect to previous page after setting home page' do + a = profile.articles.build(:name => 'my new home page') + a.save! + + @request.env['HTTP_REFERER'] = '/random_page' + post :set_home_page, :profile => profile.identifier, :id => a.id + assert_redirected_to '/random_page' + end should 'set last_changed_by when creating article' do login_as(profile.identifier) -- libgit2 0.21.2