]> source.dussan.org Git - redmine.git/commitdiff
Fixed: error when displaying an issue with a query sorted by an association, eg....
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 8 Jan 2012 18:21:00 +0000 (18:21 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 8 Jan 2012 18:21:00 +0000 (18:21 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8569 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
test/functional/issues_controller_test.rb

index 43ed6387e520aeb6458a8d14590ea90f97780370..8cd34d08ea2f7a386b3ad35accc05c4a499afb97 100644 (file)
@@ -328,7 +328,7 @@ private
       sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
       sort_update(@query.sortable_columns, 'issues_index_sort')
       limit = 500
-      issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1))
+      issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version])
       if (idx = issue_ids.index(@issue.id)) && idx < limit
         @prev_issue_id = issue_ids[idx - 1] if idx > 0
         @next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1)
index c6b96cb3e1d7eeaa46a3671392abff533c0d7f5d..22ee54739e50096ab1c647c265ba845df487cccc 100644 (file)
@@ -947,6 +947,20 @@ class IssuesControllerTest < ActionController::TestCase
     assert_tag 'a', :attributes => {:href => '/issues/5'}, :content => /Next/
   end
 
+  def test_show_should_display_prev_next_links_with_query_and_sort_on_association
+    @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => nil}
+    
+    %w(project tracker status priority author assigned_to category fixed_version).each do |assoc_sort|
+      @request.session['issues_index_sort'] = assoc_sort
+
+      get :show, :id => 3
+      assert_response :success, "Wrong response status for #{assoc_sort} sort"
+
+      assert_tag 'a', :content => /Previous/
+      assert_tag 'a', :content => /Next/
+    end
+  end
+
   def test_show_should_display_prev_next_links_with_project_query_in_session
     @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => 1}
     @request.session['issues_index_sort'] = 'id'