Fixed: error when displaying an issue with a query sorted by an association, eg. priority (#9936).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8569 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-01-08 18:21:00 +00:00
parent 381319c4e8
commit 417219bfc4
2 changed files with 15 additions and 1 deletions

View 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)

View 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'