|
1 |
# frozen_string_literal: true
|
|
2 |
|
|
3 |
# Redmine - project management software
|
|
4 |
# Copyright (C) 2006- Jean-Philippe Lang
|
|
5 |
#
|
|
6 |
# This program is free software; you can redistribute it and/or
|
|
7 |
# modify it under the terms of the GNU General Public License
|
|
8 |
# as published by the Free Software Foundation; either version 2
|
|
9 |
# of the License, or (at your option) any later version.
|
|
10 |
#
|
|
11 |
# This program is distributed in the hope that it will be useful,
|
|
12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
# GNU General Public License for more details.
|
|
15 |
#
|
|
16 |
# You should have received a copy of the GNU General Public License
|
|
17 |
# along with this program; if not, write to the Free Software
|
|
18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
19 |
|
|
20 |
require_relative '../test_helper'
|
|
21 |
|
|
22 |
class QueriesControllerIsForAllTest < Redmine::ControllerTest
|
|
23 |
fixtures :projects, :users, :roles, :members, :member_roles, :issues, :issue_statuses, :trackers,
|
|
24 |
:enumerations, :custom_fields, :custom_values, :custom_fields_trackers, :queries
|
|
25 |
|
|
26 |
def setup
|
|
27 |
User.current = nil
|
|
28 |
@request.session[:user_id] = 1 # admin
|
|
29 |
@controller = QueriesController.new
|
|
30 |
end
|
|
31 |
|
|
32 |
def test_new_query_is_for_all_checkbox_not_disabled
|
|
33 |
get :new
|
|
34 |
assert_response :success
|
|
35 |
# Verify that the "For all projects" checkbox is not disabled when creating a new query
|
|
36 |
assert_select 'input[name=query_is_for_all][type=checkbox][checked]:not([disabled])'
|
|
37 |
end
|
|
38 |
|
|
39 |
def test_new_project_query_is_for_all_checkbox_not_disabled
|
|
40 |
get(:new, :params => {:project_id => 1})
|
|
41 |
assert_response :success
|
|
42 |
# Verify that the checkbox is not disabled when creating a new query within a project
|
|
43 |
assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked]):not([disabled])'
|
|
44 |
end
|
|
45 |
|
|
46 |
def test_edit_global_query_is_for_all_checkbox_disabled
|
|
47 |
# Create a global query (project_id = nil)
|
|
48 |
query = IssueQuery.create!(:name => 'test_global_query', :user_id => 1, :project_id => nil)
|
|
49 |
|
|
50 |
get(:edit, :params => {:id => query.id})
|
|
51 |
assert_response :success
|
|
52 |
|
|
53 |
# Verify that the "For all projects" checkbox is disabled when editing an existing global query
|
|
54 |
assert_select 'input[name=query_is_for_all][type=checkbox][checked][disabled]'
|
|
55 |
end
|
|
56 |
|
|
57 |
def test_edit_project_query_is_for_all_checkbox_not_disabled
|
|
58 |
# Create a project-specific query
|
|
59 |
query = IssueQuery.create!(:name => 'test_project_query', :user_id => 1, :project_id => 1)
|
|
60 |
|
|
61 |
get(:edit, :params => {:id => query.id})
|
|
62 |
assert_response :success
|
|
63 |
|
|
64 |
# Verify that the checkbox is not disabled when editing a project-specific query
|
|
65 |
assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked]):not([disabled])'
|
|
66 |
end
|
|
67 |
end
|