diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index a3a27ce..3a6e298 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -182,7 +182,7 @@ class CmsController < MyProfileController if request.post? @article.destroy session[:notice] = _("\"#{@article.name}\" was removed.") - referer = ActionController::Routing::Routes.recognize_path URI.parse(request.referer).path + referer = ActionController::Routing::Routes.recognize_path URI.parse(request.referer).path rescue nil if referer and referer[:controller] == 'cms' redirect_to referer elsif @article.parent diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index 4d9fdbe..c01da22 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -6,6 +6,8 @@ class CmsController; def rescue_action(e) raise e end; end class CmsControllerTest < ActionController::TestCase + include NoosferoTestHelper + fixtures :environments def setup @@ -199,13 +201,29 @@ class CmsControllerTest < ActionController::TestCase should 'be able to remove article' do a = profile.articles.build(:name => 'my-article') a.save! - assert_difference Article, :count, -1 do + @request.env['HTTP_REFERER'] = url_for :controller => 'cms', :profile => profile.identifier, :action => 'index' post :destroy, :profile => profile.identifier, :id => a.id assert_redirected_to :controller => 'cms', :profile => profile.identifier, :action => 'index' end end + should 'redirect to cms after remove article from content management' do + a = profile.articles.build(:name => 'my-article') + a.save! + @request.env['HTTP_REFERER'] = url_for :controller => 'cms', :profile => profile.identifier, :action => 'index' + post :destroy, :profile => profile.identifier, :id => a.id + assert_redirected_to :controller => 'cms', :profile => profile.identifier, :action => 'index' + end + + should 'redirect to blog after remove article from content viewer' do + a = profile.articles.build(:name => 'my-article') + a.save! + @request.env['HTTP_REFERER'] = url_for :controller => 'content_viewer', :action => 'view_page' + post :destroy, :profile => profile.identifier, :id => a.id + assert_redirected_to :controller => 'content_viewer', :action => 'view_page' + end + should 'be able to acess Rss feed creation page' do login_as(profile.identifier) assert_nothing_raised do @@ -888,6 +906,7 @@ class CmsControllerTest < ActionController::TestCase should 'offer confirmation to remove article' do a = profile.articles.create!(:name => 'my-article') + @request.env['HTTP_REFERER'] = url_for :controller => 'cms', :profile => profile.identifier, :action => 'index' post :destroy, :profile => profile.identifier, :id => a.id assert_response :redirect end diff --git a/test/test_helper.rb b/test/test_helper.rb index 36935d4..1b7249a 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -272,9 +272,11 @@ module NoosferoTestHelper def will_paginate(arg1, arg2) end - def url_for(args = {}) - args + def url_for *args + url = ActionController::UrlRewriter.new(@request, nil) + url.rewrite *args end + def javascript_tag(any) '' end -- libgit2 0.21.2