]> source.dussan.org Git - redmine.git/commitdiff
Don't generate sort links with params.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 10 Jul 2016 16:58:43 +0000 (16:58 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 10 Jul 2016 16:58:43 +0000 (16:58 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@15628 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/sort_helper.rb
test/integration/issues_test.rb

index 8c17f115d22cefd2bd5d17b4f265bc8f41fd6712..8fb13818fafaa614a1d8c6a3de36d84dbda4302d 100644 (file)
@@ -218,12 +218,7 @@ module SortHelper
     caption = column.to_s.humanize unless caption
 
     sort_options = { :sort => @sort_criteria.add(column.to_s, order).to_param }
-    url_options = params.merge(sort_options)
-
-     # Add project_id to url_options
-    url_options = url_options.merge(:project_id => params[:project_id]) if params.has_key?(:project_id)
-
-    link_to(caption, url_options, :class => css)
+    link_to(caption, {:params => request.query_parameters.merge(sort_options)}, :class => css)
   end
 
   # Returns a table header <th> tag with a sort link for the named column
index 5d94a57bcb909a8725ba361b84bc1addb980d62f..668f346d4c0faa1fca3c049b2517545c6a6f4842 100644 (file)
@@ -143,6 +143,32 @@ class IssuesTest < Redmine::IntegrationTest
     end
   end
 
+  def test_pagination_links_should_not_use_params_as_url_options
+    with_settings :per_page_options => '2' do
+      get '/projects/ecookbook/issues?host=foo'
+
+      assert_select 'a[href=?]', '/projects/ecookbook/issues?host=foo&page=2', :text => '2'
+    end
+  end
+
+  def test_sort_links_on_index
+    get '/projects/ecookbook/issues'
+
+    assert_select 'a[href=?]', '/projects/ecookbook/issues?sort=subject%2Cid%3Adesc', :text => 'Subject'
+  end
+
+  def test_sort_links_should_preserve_query_parameters
+    get '/projects/ecookbook/issues?foo=bar'
+
+    assert_select 'a[href=?]', '/projects/ecookbook/issues?foo=bar&sort=subject%2Cid%3Adesc', :text => 'Subject'
+  end
+
+  def test_sort_links_should_not_use_params_as_url_options
+    get '/projects/ecookbook/issues?host=foo'
+
+    assert_select 'a[href=?]', '/projects/ecookbook/issues?host=foo&sort=subject%2Cid%3Adesc', :text => 'Subject'
+  end
+
   def test_issue_with_user_custom_field
     @field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user', :is_for_all => true, :trackers => Tracker.all)
     Role.anonymous.add_permission! :add_issues, :edit_issues