From 1827d609a1b4a20dc99b903b6b39174a6cd5ac43 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Thu, 14 Jan 2010 23:24:55 +0000 Subject: [PATCH] Cleaned up the IssueController redirects to use the back_url like the other actions. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3315 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/issues_controller.rb | 4 +- app/views/issues/context_menu.rhtml | 20 +++++----- test/functional/issues_controller_test.rb | 46 +++++++++++++++++++++++ 3 files changed, 58 insertions(+), 12 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 5da0aa283..c0d791e4b 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -217,7 +217,7 @@ class IssuesController < ApplicationController end call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal}) respond_to do |format| - format.html { redirect_to(params[:back_to] || {:action => 'show', :id => @issue}) } + format.html { redirect_back_or_default({:action => 'show', :id => @issue}) } format.xml { head :ok } end return @@ -293,7 +293,7 @@ class IssuesController < ApplicationController :total => @issues.size, :ids => '#' + unsaved_issue_ids.join(', #')) end - redirect_to(params[:back_to] || {:controller => 'issues', :action => 'index', :project_id => @project}) + redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project}) return end @available_statuses = Workflow.available_statuses(@project) diff --git a/app/views/issues/context_menu.rhtml b/app/views/issues/context_menu.rhtml index 4a1d0c310..aff836c00 100644 --- a/app/views/issues/context_menu.rhtml +++ b/app/views/issues/context_menu.rhtml @@ -8,7 +8,7 @@ <%= l(:field_status) %> @@ -23,7 +23,7 @@ <%= l(:field_tracker) %> @@ -33,7 +33,7 @@ <%= l(:field_priority) %> @@ -43,10 +43,10 @@ <%= l(:field_fixed_version) %> @@ -56,10 +56,10 @@ <%= l(:field_assigned_to) %> @@ -69,10 +69,10 @@ <%= l(:field_category) %> @@ -82,7 +82,7 @@ <%= l(:field_done_ratio) %> diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 2ea91d5e2..78ab04e1b 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -947,6 +947,36 @@ class IssuesControllerTest < ActionController::TestCase assert_equal 4, issue.fixed_version_id assert_not_equal issue.project_id, issue.fixed_version.project_id end + + def test_post_edit_should_redirect_back_using_the_back_url_parameter + issue = Issue.find(2) + @request.session[:user_id] = 2 + + post :edit, + :id => issue.id, + :issue => { + :fixed_version_id => 4 + }, + :back_url => '/issues' + + assert_response :redirect + assert_redirected_to '/issues' + end + + def test_post_edit_should_not_redirect_back_using_the_back_url_parameter_off_the_host + issue = Issue.find(2) + @request.session[:user_id] = 2 + + post :edit, + :id => issue.id, + :issue => { + :fixed_version_id => 4 + }, + :back_url => 'http://google.com' + + assert_response :redirect + assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id + end def test_get_bulk_edit @request.session[:user_id] = 2 @@ -1053,6 +1083,22 @@ class IssuesControllerTest < ActionController::TestCase end end + def test_post_bulk_edit_should_redirect_back_using_the_back_url_parameter + @request.session[:user_id] = 2 + post :bulk_edit, :ids => [1,2], :back_url => '/issues' + + assert_response :redirect + assert_redirected_to '/issues' + end + + def test_post_bulk_edit_should_not_redirect_back_using_the_back_url_parameter_off_the_host + @request.session[:user_id] = 2 + post :bulk_edit, :ids => [1,2], :back_url => 'http://google.com' + + assert_response :redirect + assert_redirected_to :controller => 'issues', :action => 'index', :project_id => Project.find(1).identifier + end + def test_move_routing assert_routing( {:method => :get, :path => '/issues/1/move'}, -- 2.39.5