From 7daa5b750fe657f662247868e8a8db89ee5b29a6 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 1 Oct 2016 08:13:40 +0000 Subject: [PATCH] Previous/Next navigation on a issue is not displayed on r15639 and later (#23781). git-svn-id: http://svn.redmine.org/redmine/trunk@15850 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/queries_helper.rb | 17 ++++++++++------- test/integration/issues_test.rb | 29 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index 6bf8b3177..57a45312e 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -262,16 +262,19 @@ module QueriesHelper end end - def retrieve_query_from_session - if session[:query] - if session[:query][:id] - @query = IssueQuery.find_by_id(session[:query][:id]) + def retrieve_query_from_session(klass=IssueQuery) + session_key = klass.name.underscore.to_sym + session_data = session[session_key] + + if session_data + if session_data[:id] + @query = IssueQuery.find_by_id(session_data[:id]) return unless @query else - @query = IssueQuery.new(:name => "_", :filters => session[:query][:filters], :group_by => session[:query][:group_by], :column_names => session[:query][:column_names], :totalable_names => session[:query][:totalable_names]) + @query = IssueQuery.new(:name => "_", :filters => session_data[:filters], :group_by => session_data[:group_by], :column_names => session_data[:column_names], :totalable_names => session_data[:totalable_names]) end - if session[:query].has_key?(:project_id) - @query.project_id = session[:query][:project_id] + if session_data.has_key?(:project_id) + @query.project_id = session_data[:project_id] else @query.project = @project end diff --git a/test/integration/issues_test.rb b/test/integration/issues_test.rb index c231eeb0e..2e8587d5a 100644 --- a/test/integration/issues_test.rb +++ b/test/integration/issues_test.rb @@ -109,6 +109,35 @@ class IssuesTest < Redmine::IntegrationTest assert_equal 0, Issue.find(1).attachments.length end + def test_next_and_previous_links_should_be_displayed_after_filter + with_settings :default_language => 'en' do + get '/projects/ecookbook/issues?set_filter=1&tracker_id=1' + assert_response :success + assert_select 'td.id', :text => '5' + + get '/issues/5' + assert_response :success + assert_select '.next-prev-links .position', :text => '3 of 5' + end + end + + def test_next_and_previous_links_should_be_displayed_after_saved_query + query = IssueQuery.create!(:name => 'Calendar Query', + :visibility => IssueQuery::VISIBILITY_PUBLIC, + :filters => {'tracker_id' => {:operator => '=', :values => ['1']}} + ) + + with_settings :default_language => 'en' do + get "/projects/ecookbook/issues?set_filter=1&query_id=#{query.id}" + assert_response :success + assert_select 'td.id', :text => '5' + + get '/issues/5' + assert_response :success + assert_select '.next-prev-links .position', :text => '6 of 8' + end + end + def test_other_formats_links_on_index get '/projects/ecookbook/issues' -- 2.39.5