summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-12-07 21:35:14 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-12-07 21:35:14 +0000
commit12077a4d44718ede358187c800c5eff06eae13ac (patch)
tree3318a1e6d45e872b92d30c8c1a138ff1b6a6e16b
parent24317f617e49fa6008e341449b3c9219166345a9 (diff)
downloadredmine-12077a4d44718ede358187c800c5eff06eae13ac.tar.gz
redmine-12077a4d44718ede358187c800c5eff06eae13ac.zip
Fixed that a cross-project custom query is not remembered inside project (#9738).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8113 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/queries_helper.rb3
-rw-r--r--test/functional/issues_controller_test.rb22
2 files changed, 24 insertions, 1 deletions
diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
index 7c43be12c..419843b6d 100644
--- a/app/helpers/queries_helper.rb
+++ b/app/helpers/queries_helper.rb
@@ -85,7 +85,8 @@ module QueriesHelper
else
# retrieve from session
@query = Query.find_by_id(session[:query][:id]) if session[:query][:id]
- @query ||= Query.new(:name => "_", :project => @project, :filters => session[:query][:filters], :group_by => session[:query][:group_by], :column_names => session[:query][:column_names])
+ @query ||= Query.new(:name => "_", :filters => session[:query][:filters], :group_by => session[:query][:group_by], :column_names => session[:query][:column_names])
+ @query.project = @project
end
end
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 9557cfcb4..5f3f34522 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -254,6 +254,28 @@ class IssuesControllerTest < ActionController::TestCase
assert_not_nil assigns(:issue_count_by_group)
end
+ def test_index_with_query_id_and_project_id_should_set_session_query
+ get :index, :project_id => 1, :query_id => 4
+ assert_response :success
+ assert_kind_of Hash, session[:query]
+ assert_equal 4, session[:query][:id]
+ assert_equal 1, session[:query][:project_id]
+ end
+
+ def test_index_with_cross_project_query_in_session_should_show_project_issues
+ q = Query.create!(:name => "test", :user_id => 2, :is_public => false, :project => nil)
+ @request.session[:query] = {:id => q.id, :project_id => 1}
+
+ with_settings :display_subprojects_issues => '0' do
+ get :index, :project_id => 1
+ end
+ assert_response :success
+ assert_not_nil assigns(:query)
+ assert_equal q.id, assigns(:query).id
+ assert_equal 1, assigns(:query).project_id
+ assert_equal [1], assigns(:issues).map(&:project_id).uniq
+ end
+
def test_private_query_should_not_be_available_to_other_users
q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
@request.session[:user_id] = 3