summaryrefslogtreecommitdiffstats
path: root/test/functional/issues_controller_test.rb
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2022-07-31 13:33:27 +0000
committerGo MAEDA <maeda@farend.jp>2022-07-31 13:33:27 +0000
commit72e2efdc6070bc4aef66042b471a5b20c8daa43b (patch)
treea3d86d9cbf5b65e114858f9c9315ae4ce815281a /test/functional/issues_controller_test.rb
parent6ee209843ed0720a861173680bc888a10f305b2e (diff)
downloadredmine-72e2efdc6070bc4aef66042b471a5b20c8daa43b.tar.gz
redmine-72e2efdc6070bc4aef66042b471a5b20c8daa43b.zip
Default query should not be applied if the query is not allowed to be set as the default (#37499).
Patch by Mizuki ISHIKAWA. git-svn-id: https://svn.redmine.org/redmine/trunk@21748 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/issues_controller_test.rb')
-rw-r--r--test/functional/issues_controller_test.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 71dcfd6ad..9028141f3 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -8482,4 +8482,55 @@ class IssuesControllerTest < Redmine::ControllerTest
# query filters for tracker_id == 3
assert results.detect{ |i| i['tracker_id'] != 3 }
end
+
+ def test_index_should_ignore_user_default_query_if_it_is_invisible
+ query = IssueQuery.find(4)
+
+ query.update(visibility: Query::VISIBILITY_PRIVATE, user_id: 2)
+ query.save!
+
+ # If visible default query
+ @request.session[:user_id] = 2
+ @request.session[:issue_query] = nil
+ User.find(2).pref.update(default_issue_query: query.id)
+ get :index
+ assert_select 'h2', text: query.name
+
+ # If invisible default query
+ @request.session[:user_id] = 3
+ @request.session[:issue_query] = nil
+ User.find(3).pref.update(default_issue_query: query.id)
+ get :index
+ assert_select 'h2', text: 'Issues'
+ end
+
+ def test_index_should_ignore_project_default_query_if_it_is_not_public
+ query = IssueQuery.find(1)
+ query.project.update(default_issue_query: query)
+
+ query.update(visibility: Query::VISIBILITY_PRIVATE, user_id: 2)
+ query.save!
+
+ [User.find(1), User.find(2)].each do |user|
+ @request.session[:user_id] = user.id
+ @request.session[:issue_query] = nil
+ get :index, params: { project_id: query.project.id }
+ assert_select 'h2', text: 'Issues'
+ end
+ end
+
+ def test_index_should_ignore_global_default_query_if_it_is_not_public
+ query = IssueQuery.find(1)
+ with_settings default_issue_query: query.id do
+ query.update(visibility: Query::VISIBILITY_PRIVATE, user_id: 2)
+ query.save!
+
+ [User.find(1), User.find(2)].each do |user|
+ @request.session[:user_id] = user.id
+ @request.session[:issue_query] = nil
+ get :index
+ assert_select 'h2', text: 'Issues'
+ end
+ end
+ end
end