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
This commit is contained in:
Go MAEDA
2022-07-31 13:33:27 +00:00
parent 6ee209843e
commit 72e2efdc60
6 changed files with 98 additions and 7 deletions

View File

@@ -274,6 +274,39 @@ class ProjectsControllerTest < Redmine::ControllerTest
end
end
def test_index_should_ignore_user_default_query_if_it_is_invisible
query = ProjectQuery.find(11)
query.update(visibility: Query::VISIBILITY_PRIVATE, user_id: 2)
query.save!
# If visible default query
@request.session[:user_id] = 2
User.find(2).pref.update(default_project_query: query.id)
get :index
assert_select 'h2', text: query.name
# If invisible default query
@request.session[:user_id] = 3
User.find(3).pref.update(default_project_query: query.id)
get :index
assert_select 'h2', text: I18n.t(:label_project_plural)
end
def test_index_should_ignore_global_default_query_if_it_is_not_public
query = ProjectQuery.find(11)
with_settings default_project_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
get :index
assert_select 'h2', text: I18n.t(:label_project_plural)
end
end
end
def test_autocomplete_js
get(
:autocomplete,