@@ -1,524 +1,524 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2008 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2008 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 |
|
19 | |||
20 | class QueryTest < ActiveSupport::TestCase |
|
20 | class QueryTest < ActiveSupport::TestCase | |
21 | fixtures :projects, :enabled_modules, :users, :members, :member_roles, :roles, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :watchers, :custom_fields, :custom_values, :versions, :queries |
|
21 | fixtures :projects, :enabled_modules, :users, :members, :member_roles, :roles, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :watchers, :custom_fields, :custom_values, :versions, :queries | |
22 |
|
22 | |||
23 | def test_custom_fields_for_all_projects_should_be_available_in_global_queries |
|
23 | def test_custom_fields_for_all_projects_should_be_available_in_global_queries | |
24 | query = Query.new(:project => nil, :name => '_') |
|
24 | query = Query.new(:project => nil, :name => '_') | |
25 | assert query.available_filters.has_key?('cf_1') |
|
25 | assert query.available_filters.has_key?('cf_1') | |
26 | assert !query.available_filters.has_key?('cf_3') |
|
26 | assert !query.available_filters.has_key?('cf_3') | |
27 | end |
|
27 | end | |
28 |
|
28 | |||
29 | def test_system_shared_versions_should_be_available_in_global_queries |
|
29 | def test_system_shared_versions_should_be_available_in_global_queries | |
30 | Version.find(2).update_attribute :sharing, 'system' |
|
30 | Version.find(2).update_attribute :sharing, 'system' | |
31 | query = Query.new(:project => nil, :name => '_') |
|
31 | query = Query.new(:project => nil, :name => '_') | |
32 | assert query.available_filters.has_key?('fixed_version_id') |
|
32 | assert query.available_filters.has_key?('fixed_version_id') | |
33 | assert query.available_filters['fixed_version_id'][:values].detect {|v| v.last == '2'} |
|
33 | assert query.available_filters['fixed_version_id'][:values].detect {|v| v.last == '2'} | |
34 | end |
|
34 | end | |
35 |
|
35 | |||
36 | def test_project_filter_in_global_queries |
|
36 | def test_project_filter_in_global_queries | |
37 | query = Query.new(:project => nil, :name => '_') |
|
37 | query = Query.new(:project => nil, :name => '_') | |
38 | project_filter = query.available_filters["project_id"] |
|
38 | project_filter = query.available_filters["project_id"] | |
39 | assert_not_nil project_filter |
|
39 | assert_not_nil project_filter | |
40 | project_ids = project_filter[:values].map{|p| p[1]} |
|
40 | project_ids = project_filter[:values].map{|p| p[1]} | |
41 | assert project_ids.include?("1") #public project |
|
41 | assert project_ids.include?("1") #public project | |
42 | assert !project_ids.include?("2") #private project user cannot see |
|
42 | assert !project_ids.include?("2") #private project user cannot see | |
43 | end |
|
43 | end | |
44 |
|
44 | |||
45 | def find_issues_with_query(query) |
|
45 | def find_issues_with_query(query) | |
46 | Issue.find :all, |
|
46 | Issue.find :all, | |
47 | :include => [ :assigned_to, :status, :tracker, :project, :priority ], |
|
47 | :include => [ :assigned_to, :status, :tracker, :project, :priority ], | |
48 | :conditions => query.statement |
|
48 | :conditions => query.statement | |
49 | end |
|
49 | end | |
50 |
|
50 | |||
51 | def assert_find_issues_with_query_is_successful(query) |
|
51 | def assert_find_issues_with_query_is_successful(query) | |
52 | assert_nothing_raised do |
|
52 | assert_nothing_raised do | |
53 | find_issues_with_query(query) |
|
53 | find_issues_with_query(query) | |
54 | end |
|
54 | end | |
55 | end |
|
55 | end | |
56 |
|
56 | |||
57 | def assert_query_statement_includes(query, condition) |
|
57 | def assert_query_statement_includes(query, condition) | |
58 | assert query.statement.include?(condition), "Query statement condition not found in: #{query.statement}" |
|
58 | assert query.statement.include?(condition), "Query statement condition not found in: #{query.statement}" | |
59 | end |
|
59 | end | |
60 |
|
60 | |||
61 | def test_query_should_allow_shared_versions_for_a_project_query |
|
61 | def test_query_should_allow_shared_versions_for_a_project_query | |
62 | subproject_version = Version.find(4) |
|
62 | subproject_version = Version.find(4) | |
63 | query = Query.new(:project => Project.find(1), :name => '_') |
|
63 | query = Query.new(:project => Project.find(1), :name => '_') | |
64 | query.add_filter('fixed_version_id', '=', [subproject_version.id.to_s]) |
|
64 | query.add_filter('fixed_version_id', '=', [subproject_version.id.to_s]) | |
65 |
|
65 | |||
66 | assert query.statement.include?("#{Issue.table_name}.fixed_version_id IN ('4')") |
|
66 | assert query.statement.include?("#{Issue.table_name}.fixed_version_id IN ('4')") | |
67 | end |
|
67 | end | |
68 |
|
68 | |||
69 | def test_query_with_multiple_custom_fields |
|
69 | def test_query_with_multiple_custom_fields | |
70 | query = Query.find(1) |
|
70 | query = Query.find(1) | |
71 | assert query.valid? |
|
71 | assert query.valid? | |
72 | assert query.statement.include?("#{CustomValue.table_name}.value IN ('MySQL')") |
|
72 | assert query.statement.include?("#{CustomValue.table_name}.value IN ('MySQL')") | |
73 | issues = find_issues_with_query(query) |
|
73 | issues = find_issues_with_query(query) | |
74 | assert_equal 1, issues.length |
|
74 | assert_equal 1, issues.length | |
75 | assert_equal Issue.find(3), issues.first |
|
75 | assert_equal Issue.find(3), issues.first | |
76 | end |
|
76 | end | |
77 |
|
77 | |||
78 | def test_operator_none |
|
78 | def test_operator_none | |
79 | query = Query.new(:project => Project.find(1), :name => '_') |
|
79 | query = Query.new(:project => Project.find(1), :name => '_') | |
80 | query.add_filter('fixed_version_id', '!*', ['']) |
|
80 | query.add_filter('fixed_version_id', '!*', ['']) | |
81 | query.add_filter('cf_1', '!*', ['']) |
|
81 | query.add_filter('cf_1', '!*', ['']) | |
82 | assert query.statement.include?("#{Issue.table_name}.fixed_version_id IS NULL") |
|
82 | assert query.statement.include?("#{Issue.table_name}.fixed_version_id IS NULL") | |
83 | assert query.statement.include?("#{CustomValue.table_name}.value IS NULL OR #{CustomValue.table_name}.value = ''") |
|
83 | assert query.statement.include?("#{CustomValue.table_name}.value IS NULL OR #{CustomValue.table_name}.value = ''") | |
84 | find_issues_with_query(query) |
|
84 | find_issues_with_query(query) | |
85 | end |
|
85 | end | |
86 |
|
86 | |||
87 | def test_operator_none_for_integer |
|
87 | def test_operator_none_for_integer | |
88 | query = Query.new(:project => Project.find(1), :name => '_') |
|
88 | query = Query.new(:project => Project.find(1), :name => '_') | |
89 | query.add_filter('estimated_hours', '!*', ['']) |
|
89 | query.add_filter('estimated_hours', '!*', ['']) | |
90 | issues = find_issues_with_query(query) |
|
90 | issues = find_issues_with_query(query) | |
91 | assert !issues.empty? |
|
91 | assert !issues.empty? | |
92 | assert issues.all? {|i| !i.estimated_hours} |
|
92 | assert issues.all? {|i| !i.estimated_hours} | |
93 | end |
|
93 | end | |
94 |
|
94 | |||
95 | def test_operator_all |
|
95 | def test_operator_all | |
96 | query = Query.new(:project => Project.find(1), :name => '_') |
|
96 | query = Query.new(:project => Project.find(1), :name => '_') | |
97 | query.add_filter('fixed_version_id', '*', ['']) |
|
97 | query.add_filter('fixed_version_id', '*', ['']) | |
98 | query.add_filter('cf_1', '*', ['']) |
|
98 | query.add_filter('cf_1', '*', ['']) | |
99 | assert query.statement.include?("#{Issue.table_name}.fixed_version_id IS NOT NULL") |
|
99 | assert query.statement.include?("#{Issue.table_name}.fixed_version_id IS NOT NULL") | |
100 | assert query.statement.include?("#{CustomValue.table_name}.value IS NOT NULL AND #{CustomValue.table_name}.value <> ''") |
|
100 | assert query.statement.include?("#{CustomValue.table_name}.value IS NOT NULL AND #{CustomValue.table_name}.value <> ''") | |
101 | find_issues_with_query(query) |
|
101 | find_issues_with_query(query) | |
102 | end |
|
102 | end | |
103 |
|
103 | |||
104 | def test_operator_greater_than |
|
104 | def test_operator_greater_than | |
105 | query = Query.new(:project => Project.find(1), :name => '_') |
|
105 | query = Query.new(:project => Project.find(1), :name => '_') | |
106 | query.add_filter('done_ratio', '>=', ['40']) |
|
106 | query.add_filter('done_ratio', '>=', ['40']) | |
107 | assert query.statement.include?("#{Issue.table_name}.done_ratio >= 40") |
|
107 | assert query.statement.include?("#{Issue.table_name}.done_ratio >= 40") | |
108 | find_issues_with_query(query) |
|
108 | find_issues_with_query(query) | |
109 | end |
|
109 | end | |
110 |
|
110 | |||
111 | def test_operator_in_more_than |
|
111 | def test_operator_in_more_than | |
112 | Issue.find(7).update_attribute(:due_date, (Date.today + 15)) |
|
112 | Issue.find(7).update_attribute(:due_date, (Date.today + 15)) | |
113 | query = Query.new(:project => Project.find(1), :name => '_') |
|
113 | query = Query.new(:project => Project.find(1), :name => '_') | |
114 | query.add_filter('due_date', '>t+', ['15']) |
|
114 | query.add_filter('due_date', '>t+', ['15']) | |
115 | issues = find_issues_with_query(query) |
|
115 | issues = find_issues_with_query(query) | |
116 | assert !issues.empty? |
|
116 | assert !issues.empty? | |
117 | issues.each {|issue| assert(issue.due_date >= (Date.today + 15))} |
|
117 | issues.each {|issue| assert(issue.due_date >= (Date.today + 15))} | |
118 | end |
|
118 | end | |
119 |
|
119 | |||
120 | def test_operator_in_less_than |
|
120 | def test_operator_in_less_than | |
121 | query = Query.new(:project => Project.find(1), :name => '_') |
|
121 | query = Query.new(:project => Project.find(1), :name => '_') | |
122 | query.add_filter('due_date', '<t+', ['15']) |
|
122 | query.add_filter('due_date', '<t+', ['15']) | |
123 | issues = find_issues_with_query(query) |
|
123 | issues = find_issues_with_query(query) | |
124 | assert !issues.empty? |
|
124 | assert !issues.empty? | |
125 | issues.each {|issue| assert(issue.due_date >= Date.today && issue.due_date <= (Date.today + 15))} |
|
125 | issues.each {|issue| assert(issue.due_date >= Date.today && issue.due_date <= (Date.today + 15))} | |
126 | end |
|
126 | end | |
127 |
|
127 | |||
128 | def test_operator_less_than_ago |
|
128 | def test_operator_less_than_ago | |
129 | Issue.find(7).update_attribute(:due_date, (Date.today - 3)) |
|
129 | Issue.find(7).update_attribute(:due_date, (Date.today - 3)) | |
130 | query = Query.new(:project => Project.find(1), :name => '_') |
|
130 | query = Query.new(:project => Project.find(1), :name => '_') | |
131 | query.add_filter('due_date', '>t-', ['3']) |
|
131 | query.add_filter('due_date', '>t-', ['3']) | |
132 | issues = find_issues_with_query(query) |
|
132 | issues = find_issues_with_query(query) | |
133 | assert !issues.empty? |
|
133 | assert !issues.empty? | |
134 | issues.each {|issue| assert(issue.due_date >= (Date.today - 3) && issue.due_date <= Date.today)} |
|
134 | issues.each {|issue| assert(issue.due_date >= (Date.today - 3) && issue.due_date <= Date.today)} | |
135 | end |
|
135 | end | |
136 |
|
136 | |||
137 | def test_operator_more_than_ago |
|
137 | def test_operator_more_than_ago | |
138 | Issue.find(7).update_attribute(:due_date, (Date.today - 10)) |
|
138 | Issue.find(7).update_attribute(:due_date, (Date.today - 10)) | |
139 | query = Query.new(:project => Project.find(1), :name => '_') |
|
139 | query = Query.new(:project => Project.find(1), :name => '_') | |
140 | query.add_filter('due_date', '<t-', ['10']) |
|
140 | query.add_filter('due_date', '<t-', ['10']) | |
141 | assert query.statement.include?("#{Issue.table_name}.due_date <=") |
|
141 | assert query.statement.include?("#{Issue.table_name}.due_date <=") | |
142 | issues = find_issues_with_query(query) |
|
142 | issues = find_issues_with_query(query) | |
143 | assert !issues.empty? |
|
143 | assert !issues.empty? | |
144 | issues.each {|issue| assert(issue.due_date <= (Date.today - 10))} |
|
144 | issues.each {|issue| assert(issue.due_date <= (Date.today - 10))} | |
145 | end |
|
145 | end | |
146 |
|
146 | |||
147 | def test_operator_in |
|
147 | def test_operator_in | |
148 | Issue.find(7).update_attribute(:due_date, (Date.today + 2)) |
|
148 | Issue.find(7).update_attribute(:due_date, (Date.today + 2)) | |
149 | query = Query.new(:project => Project.find(1), :name => '_') |
|
149 | query = Query.new(:project => Project.find(1), :name => '_') | |
150 | query.add_filter('due_date', 't+', ['2']) |
|
150 | query.add_filter('due_date', 't+', ['2']) | |
151 | issues = find_issues_with_query(query) |
|
151 | issues = find_issues_with_query(query) | |
152 | assert !issues.empty? |
|
152 | assert !issues.empty? | |
153 | issues.each {|issue| assert_equal((Date.today + 2), issue.due_date)} |
|
153 | issues.each {|issue| assert_equal((Date.today + 2), issue.due_date)} | |
154 | end |
|
154 | end | |
155 |
|
155 | |||
156 | def test_operator_ago |
|
156 | def test_operator_ago | |
157 | Issue.find(7).update_attribute(:due_date, (Date.today - 3)) |
|
157 | Issue.find(7).update_attribute(:due_date, (Date.today - 3)) | |
158 | query = Query.new(:project => Project.find(1), :name => '_') |
|
158 | query = Query.new(:project => Project.find(1), :name => '_') | |
159 | query.add_filter('due_date', 't-', ['3']) |
|
159 | query.add_filter('due_date', 't-', ['3']) | |
160 | issues = find_issues_with_query(query) |
|
160 | issues = find_issues_with_query(query) | |
161 | assert !issues.empty? |
|
161 | assert !issues.empty? | |
162 | issues.each {|issue| assert_equal((Date.today - 3), issue.due_date)} |
|
162 | issues.each {|issue| assert_equal((Date.today - 3), issue.due_date)} | |
163 | end |
|
163 | end | |
164 |
|
164 | |||
165 | def test_operator_today |
|
165 | def test_operator_today | |
166 | query = Query.new(:project => Project.find(1), :name => '_') |
|
166 | query = Query.new(:project => Project.find(1), :name => '_') | |
167 | query.add_filter('due_date', 't', ['']) |
|
167 | query.add_filter('due_date', 't', ['']) | |
168 | issues = find_issues_with_query(query) |
|
168 | issues = find_issues_with_query(query) | |
169 | assert !issues.empty? |
|
169 | assert !issues.empty? | |
170 | issues.each {|issue| assert_equal Date.today, issue.due_date} |
|
170 | issues.each {|issue| assert_equal Date.today, issue.due_date} | |
171 | end |
|
171 | end | |
172 |
|
172 | |||
173 | def test_operator_this_week_on_date |
|
173 | def test_operator_this_week_on_date | |
174 | query = Query.new(:project => Project.find(1), :name => '_') |
|
174 | query = Query.new(:project => Project.find(1), :name => '_') | |
175 | query.add_filter('due_date', 'w', ['']) |
|
175 | query.add_filter('due_date', 'w', ['']) | |
176 | find_issues_with_query(query) |
|
176 | find_issues_with_query(query) | |
177 | end |
|
177 | end | |
178 |
|
178 | |||
179 | def test_operator_this_week_on_datetime |
|
179 | def test_operator_this_week_on_datetime | |
180 | query = Query.new(:project => Project.find(1), :name => '_') |
|
180 | query = Query.new(:project => Project.find(1), :name => '_') | |
181 | query.add_filter('created_on', 'w', ['']) |
|
181 | query.add_filter('created_on', 'w', ['']) | |
182 | find_issues_with_query(query) |
|
182 | find_issues_with_query(query) | |
183 | end |
|
183 | end | |
184 |
|
184 | |||
185 | def test_operator_contains |
|
185 | def test_operator_contains | |
186 | query = Query.new(:project => Project.find(1), :name => '_') |
|
186 | query = Query.new(:project => Project.find(1), :name => '_') | |
187 | query.add_filter('subject', '~', ['uNable']) |
|
187 | query.add_filter('subject', '~', ['uNable']) | |
188 | assert query.statement.include?("LOWER(#{Issue.table_name}.subject) LIKE '%unable%'") |
|
188 | assert query.statement.include?("LOWER(#{Issue.table_name}.subject) LIKE '%unable%'") | |
189 | result = find_issues_with_query(query) |
|
189 | result = find_issues_with_query(query) | |
190 | assert result.empty? |
|
190 | assert result.empty? | |
191 | result.each {|issue| assert issue.subject.downcase.include?('unable') } |
|
191 | result.each {|issue| assert issue.subject.downcase.include?('unable') } | |
192 | end |
|
192 | end | |
193 |
|
193 | |||
194 | def test_operator_does_not_contains |
|
194 | def test_operator_does_not_contains | |
195 | query = Query.new(:project => Project.find(1), :name => '_') |
|
195 | query = Query.new(:project => Project.find(1), :name => '_') | |
196 | query.add_filter('subject', '!~', ['uNable']) |
|
196 | query.add_filter('subject', '!~', ['uNable']) | |
197 | assert query.statement.include?("LOWER(#{Issue.table_name}.subject) NOT LIKE '%unable%'") |
|
197 | assert query.statement.include?("LOWER(#{Issue.table_name}.subject) NOT LIKE '%unable%'") | |
198 | find_issues_with_query(query) |
|
198 | find_issues_with_query(query) | |
199 | end |
|
199 | end | |
200 |
|
200 | |||
201 | def test_filter_watched_issues |
|
201 | def test_filter_watched_issues | |
202 | User.current = User.find(1) |
|
202 | User.current = User.find(1) | |
203 | query = Query.new(:name => '_', :filters => { 'watcher_id' => {:operator => '=', :values => ['me']}}) |
|
203 | query = Query.new(:name => '_', :filters => { 'watcher_id' => {:operator => '=', :values => ['me']}}) | |
204 | result = find_issues_with_query(query) |
|
204 | result = find_issues_with_query(query) | |
205 | assert_not_nil result |
|
205 | assert_not_nil result | |
206 | assert !result.empty? |
|
206 | assert !result.empty? | |
207 | assert_equal Issue.visible.watched_by(User.current).sort_by(&:id), result.sort_by(&:id) |
|
207 | assert_equal Issue.visible.watched_by(User.current).sort_by(&:id), result.sort_by(&:id) | |
208 | User.current = nil |
|
208 | User.current = nil | |
209 | end |
|
209 | end | |
210 |
|
210 | |||
211 | def test_filter_unwatched_issues |
|
211 | def test_filter_unwatched_issues | |
212 | User.current = User.find(1) |
|
212 | User.current = User.find(1) | |
213 | query = Query.new(:name => '_', :filters => { 'watcher_id' => {:operator => '!', :values => ['me']}}) |
|
213 | query = Query.new(:name => '_', :filters => { 'watcher_id' => {:operator => '!', :values => ['me']}}) | |
214 | result = find_issues_with_query(query) |
|
214 | result = find_issues_with_query(query) | |
215 | assert_not_nil result |
|
215 | assert_not_nil result | |
216 | assert !result.empty? |
|
216 | assert !result.empty? | |
217 | assert_equal((Issue.visible - Issue.watched_by(User.current)).sort_by(&:id).size, result.sort_by(&:id).size) |
|
217 | assert_equal((Issue.visible - Issue.watched_by(User.current)).sort_by(&:id).size, result.sort_by(&:id).size) | |
218 | User.current = nil |
|
218 | User.current = nil | |
219 | end |
|
219 | end | |
220 |
|
220 | |||
221 | def test_default_columns |
|
221 | def test_default_columns | |
222 | q = Query.new |
|
222 | q = Query.new | |
223 | assert !q.columns.empty? |
|
223 | assert !q.columns.empty? | |
224 | end |
|
224 | end | |
225 |
|
225 | |||
226 | def test_set_column_names |
|
226 | def test_set_column_names | |
227 | q = Query.new |
|
227 | q = Query.new | |
228 | q.column_names = ['tracker', :subject, '', 'unknonw_column'] |
|
228 | q.column_names = ['tracker', :subject, '', 'unknonw_column'] | |
229 | assert_equal [:tracker, :subject], q.columns.collect {|c| c.name} |
|
229 | assert_equal [:tracker, :subject], q.columns.collect {|c| c.name} | |
230 | c = q.columns.first |
|
230 | c = q.columns.first | |
231 | assert q.has_column?(c) |
|
231 | assert q.has_column?(c) | |
232 | end |
|
232 | end | |
233 |
|
233 | |||
234 | def test_groupable_columns_should_include_custom_fields |
|
234 | def test_groupable_columns_should_include_custom_fields | |
235 | q = Query.new |
|
235 | q = Query.new | |
236 | assert q.groupable_columns.detect {|c| c.is_a? QueryCustomFieldColumn} |
|
236 | assert q.groupable_columns.detect {|c| c.is_a? QueryCustomFieldColumn} | |
237 | end |
|
237 | end | |
238 |
|
238 | |||
239 | def test_default_sort |
|
239 | def test_default_sort | |
240 | q = Query.new |
|
240 | q = Query.new | |
241 | assert_equal [], q.sort_criteria |
|
241 | assert_equal [], q.sort_criteria | |
242 | end |
|
242 | end | |
243 |
|
243 | |||
244 | def test_set_sort_criteria_with_hash |
|
244 | def test_set_sort_criteria_with_hash | |
245 | q = Query.new |
|
245 | q = Query.new | |
246 | q.sort_criteria = {'0' => ['priority', 'desc'], '2' => ['tracker']} |
|
246 | q.sort_criteria = {'0' => ['priority', 'desc'], '2' => ['tracker']} | |
247 | assert_equal [['priority', 'desc'], ['tracker', 'asc']], q.sort_criteria |
|
247 | assert_equal [['priority', 'desc'], ['tracker', 'asc']], q.sort_criteria | |
248 | end |
|
248 | end | |
249 |
|
249 | |||
250 | def test_set_sort_criteria_with_array |
|
250 | def test_set_sort_criteria_with_array | |
251 | q = Query.new |
|
251 | q = Query.new | |
252 | q.sort_criteria = [['priority', 'desc'], 'tracker'] |
|
252 | q.sort_criteria = [['priority', 'desc'], 'tracker'] | |
253 | assert_equal [['priority', 'desc'], ['tracker', 'asc']], q.sort_criteria |
|
253 | assert_equal [['priority', 'desc'], ['tracker', 'asc']], q.sort_criteria | |
254 | end |
|
254 | end | |
255 |
|
255 | |||
256 | def test_create_query_with_sort |
|
256 | def test_create_query_with_sort | |
257 | q = Query.new(:name => 'Sorted') |
|
257 | q = Query.new(:name => 'Sorted') | |
258 | q.sort_criteria = [['priority', 'desc'], 'tracker'] |
|
258 | q.sort_criteria = [['priority', 'desc'], 'tracker'] | |
259 | assert q.save |
|
259 | assert q.save | |
260 | q.reload |
|
260 | q.reload | |
261 | assert_equal [['priority', 'desc'], ['tracker', 'asc']], q.sort_criteria |
|
261 | assert_equal [['priority', 'desc'], ['tracker', 'asc']], q.sort_criteria | |
262 | end |
|
262 | end | |
263 |
|
263 | |||
264 | def test_sort_by_string_custom_field_asc |
|
264 | def test_sort_by_string_custom_field_asc | |
265 | q = Query.new |
|
265 | q = Query.new | |
266 | c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'string' } |
|
266 | c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'string' } | |
267 | assert c |
|
267 | assert c | |
268 | assert c.sortable |
|
268 | assert c.sortable | |
269 | issues = Issue.find :all, |
|
269 | issues = Issue.find :all, | |
270 | :include => [ :assigned_to, :status, :tracker, :project, :priority ], |
|
270 | :include => [ :assigned_to, :status, :tracker, :project, :priority ], | |
271 | :conditions => q.statement, |
|
271 | :conditions => q.statement, | |
272 | :order => "#{c.sortable} ASC" |
|
272 | :order => "#{c.sortable} ASC" | |
273 | values = issues.collect {|i| i.custom_value_for(c.custom_field).to_s} |
|
273 | values = issues.collect {|i| i.custom_value_for(c.custom_field).to_s} | |
274 | assert !values.empty? |
|
274 | assert !values.empty? | |
275 | assert_equal values.sort, values |
|
275 | assert_equal values.sort, values | |
276 | end |
|
276 | end | |
277 |
|
277 | |||
278 | def test_sort_by_string_custom_field_desc |
|
278 | def test_sort_by_string_custom_field_desc | |
279 | q = Query.new |
|
279 | q = Query.new | |
280 | c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'string' } |
|
280 | c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'string' } | |
281 | assert c |
|
281 | assert c | |
282 | assert c.sortable |
|
282 | assert c.sortable | |
283 | issues = Issue.find :all, |
|
283 | issues = Issue.find :all, | |
284 | :include => [ :assigned_to, :status, :tracker, :project, :priority ], |
|
284 | :include => [ :assigned_to, :status, :tracker, :project, :priority ], | |
285 | :conditions => q.statement, |
|
285 | :conditions => q.statement, | |
286 | :order => "#{c.sortable} DESC" |
|
286 | :order => "#{c.sortable} DESC" | |
287 | values = issues.collect {|i| i.custom_value_for(c.custom_field).to_s} |
|
287 | values = issues.collect {|i| i.custom_value_for(c.custom_field).to_s} | |
288 | assert !values.empty? |
|
288 | assert !values.empty? | |
289 | assert_equal values.sort.reverse, values |
|
289 | assert_equal values.sort.reverse, values | |
290 | end |
|
290 | end | |
291 |
|
291 | |||
292 | def test_sort_by_float_custom_field_asc |
|
292 | def test_sort_by_float_custom_field_asc | |
293 | q = Query.new |
|
293 | q = Query.new | |
294 | c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'float' } |
|
294 | c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'float' } | |
295 | assert c |
|
295 | assert c | |
296 | assert c.sortable |
|
296 | assert c.sortable | |
297 | issues = Issue.find :all, |
|
297 | issues = Issue.find :all, | |
298 | :include => [ :assigned_to, :status, :tracker, :project, :priority ], |
|
298 | :include => [ :assigned_to, :status, :tracker, :project, :priority ], | |
299 | :conditions => q.statement, |
|
299 | :conditions => q.statement, | |
300 | :order => "#{c.sortable} ASC" |
|
300 | :order => "#{c.sortable} ASC" | |
301 | values = issues.collect {|i| begin; Kernel.Float(i.custom_value_for(c.custom_field).to_s); rescue; nil; end}.compact |
|
301 | values = issues.collect {|i| begin; Kernel.Float(i.custom_value_for(c.custom_field).to_s); rescue; nil; end}.compact | |
302 | assert !values.empty? |
|
302 | assert !values.empty? | |
303 | assert_equal values.sort, values |
|
303 | assert_equal values.sort, values | |
304 | end |
|
304 | end | |
305 |
|
305 | |||
306 | def test_invalid_query_should_raise_query_statement_invalid_error |
|
306 | def test_invalid_query_should_raise_query_statement_invalid_error | |
307 | q = Query.new |
|
307 | q = Query.new | |
308 | assert_raise Query::StatementInvalid do |
|
308 | assert_raise Query::StatementInvalid do | |
309 | q.issues(:conditions => "foo = 1") |
|
309 | q.issues(:conditions => "foo = 1") | |
310 | end |
|
310 | end | |
311 | end |
|
311 | end | |
312 |
|
312 | |||
313 | def test_issue_count_by_association_group |
|
313 | def test_issue_count_by_association_group | |
314 | q = Query.new(:name => '_', :group_by => 'assigned_to') |
|
314 | q = Query.new(:name => '_', :group_by => 'assigned_to') | |
315 | count_by_group = q.issue_count_by_group |
|
315 | count_by_group = q.issue_count_by_group | |
316 | assert_kind_of Hash, count_by_group |
|
316 | assert_kind_of Hash, count_by_group | |
317 | assert_equal %w(NilClass User), count_by_group.keys.collect {|k| k.class.name}.uniq.sort |
|
317 | assert_equal %w(NilClass User), count_by_group.keys.collect {|k| k.class.name}.uniq.sort | |
318 | assert_equal %w(Fixnum), count_by_group.values.collect {|k| k.class.name}.uniq |
|
318 | assert_equal %w(Fixnum), count_by_group.values.collect {|k| k.class.name}.uniq | |
319 | assert count_by_group.has_key?(User.find(3)) |
|
319 | assert count_by_group.has_key?(User.find(3)) | |
320 | end |
|
320 | end | |
321 |
|
321 | |||
322 | def test_issue_count_by_list_custom_field_group |
|
322 | def test_issue_count_by_list_custom_field_group | |
323 | q = Query.new(:name => '_', :group_by => 'cf_1') |
|
323 | q = Query.new(:name => '_', :group_by => 'cf_1') | |
324 | count_by_group = q.issue_count_by_group |
|
324 | count_by_group = q.issue_count_by_group | |
325 | assert_kind_of Hash, count_by_group |
|
325 | assert_kind_of Hash, count_by_group | |
326 | assert_equal %w(NilClass String), count_by_group.keys.collect {|k| k.class.name}.uniq.sort |
|
326 | assert_equal %w(NilClass String), count_by_group.keys.collect {|k| k.class.name}.uniq.sort | |
327 | assert_equal %w(Fixnum), count_by_group.values.collect {|k| k.class.name}.uniq |
|
327 | assert_equal %w(Fixnum), count_by_group.values.collect {|k| k.class.name}.uniq | |
328 | assert count_by_group.has_key?('MySQL') |
|
328 | assert count_by_group.has_key?('MySQL') | |
329 | end |
|
329 | end | |
330 |
|
330 | |||
331 | def test_issue_count_by_date_custom_field_group |
|
331 | def test_issue_count_by_date_custom_field_group | |
332 | q = Query.new(:name => '_', :group_by => 'cf_8') |
|
332 | q = Query.new(:name => '_', :group_by => 'cf_8') | |
333 | count_by_group = q.issue_count_by_group |
|
333 | count_by_group = q.issue_count_by_group | |
334 | assert_kind_of Hash, count_by_group |
|
334 | assert_kind_of Hash, count_by_group | |
335 | assert_equal %w(Date NilClass), count_by_group.keys.collect {|k| k.class.name}.uniq.sort |
|
335 | assert_equal %w(Date NilClass), count_by_group.keys.collect {|k| k.class.name}.uniq.sort | |
336 | assert_equal %w(Fixnum), count_by_group.values.collect {|k| k.class.name}.uniq |
|
336 | assert_equal %w(Fixnum), count_by_group.values.collect {|k| k.class.name}.uniq | |
337 | end |
|
337 | end | |
338 |
|
338 | |||
339 | def test_label_for |
|
339 | def test_label_for | |
340 | q = Query.new |
|
340 | q = Query.new | |
341 | assert_equal 'assigned_to', q.label_for('assigned_to_id') |
|
341 | assert_equal 'assigned_to', q.label_for('assigned_to_id') | |
342 | end |
|
342 | end | |
343 |
|
343 | |||
344 | def test_editable_by |
|
344 | def test_editable_by | |
345 | admin = User.find(1) |
|
345 | admin = User.find(1) | |
346 | manager = User.find(2) |
|
346 | manager = User.find(2) | |
347 | developer = User.find(3) |
|
347 | developer = User.find(3) | |
348 |
|
348 | |||
349 | # Public query on project 1 |
|
349 | # Public query on project 1 | |
350 | q = Query.find(1) |
|
350 | q = Query.find(1) | |
351 | assert q.editable_by?(admin) |
|
351 | assert q.editable_by?(admin) | |
352 | assert q.editable_by?(manager) |
|
352 | assert q.editable_by?(manager) | |
353 | assert !q.editable_by?(developer) |
|
353 | assert !q.editable_by?(developer) | |
354 |
|
354 | |||
355 | # Private query on project 1 |
|
355 | # Private query on project 1 | |
356 | q = Query.find(2) |
|
356 | q = Query.find(2) | |
357 | assert q.editable_by?(admin) |
|
357 | assert q.editable_by?(admin) | |
358 | assert !q.editable_by?(manager) |
|
358 | assert !q.editable_by?(manager) | |
359 | assert q.editable_by?(developer) |
|
359 | assert q.editable_by?(developer) | |
360 |
|
360 | |||
361 | # Private query for all projects |
|
361 | # Private query for all projects | |
362 | q = Query.find(3) |
|
362 | q = Query.find(3) | |
363 | assert q.editable_by?(admin) |
|
363 | assert q.editable_by?(admin) | |
364 | assert !q.editable_by?(manager) |
|
364 | assert !q.editable_by?(manager) | |
365 | assert q.editable_by?(developer) |
|
365 | assert q.editable_by?(developer) | |
366 |
|
366 | |||
367 | # Public query for all projects |
|
367 | # Public query for all projects | |
368 | q = Query.find(4) |
|
368 | q = Query.find(4) | |
369 | assert q.editable_by?(admin) |
|
369 | assert q.editable_by?(admin) | |
370 | assert !q.editable_by?(manager) |
|
370 | assert !q.editable_by?(manager) | |
371 | assert !q.editable_by?(developer) |
|
371 | assert !q.editable_by?(developer) | |
372 | end |
|
372 | end | |
373 |
|
373 | |||
374 | context "#available_filters" do |
|
374 | context "#available_filters" do | |
375 | setup do |
|
375 | setup do | |
376 | @query = Query.new(:name => "_") |
|
376 | @query = Query.new(:name => "_") | |
377 | end |
|
377 | end | |
378 |
|
378 | |||
379 | should "include users of visible projects in cross-project view" do |
|
379 | should "include users of visible projects in cross-project view" do | |
380 | users = @query.available_filters["assigned_to_id"] |
|
380 | users = @query.available_filters["assigned_to_id"] | |
381 | assert_not_nil users |
|
381 | assert_not_nil users | |
382 | assert users[:values].map{|u|u[1]}.include?("3") |
|
382 | assert users[:values].map{|u|u[1]}.include?("3") | |
383 | end |
|
383 | end | |
384 |
|
384 | |||
385 | context "'member_of_group' filter" do |
|
385 | context "'member_of_group' filter" do | |
386 | should "be present" do |
|
386 | should "be present" do | |
387 | assert @query.available_filters.keys.include?("member_of_group") |
|
387 | assert @query.available_filters.keys.include?("member_of_group") | |
388 | end |
|
388 | end | |
389 |
|
389 | |||
390 | should "be an optional list" do |
|
390 | should "be an optional list" do | |
391 | assert_equal :list_optional, @query.available_filters["member_of_group"][:type] |
|
391 | assert_equal :list_optional, @query.available_filters["member_of_group"][:type] | |
392 | end |
|
392 | end | |
393 |
|
393 | |||
394 | should "have a list of the groups as values" do |
|
394 | should "have a list of the groups as values" do | |
395 | Group.destroy_all # No fixtures |
|
395 | Group.destroy_all # No fixtures | |
396 | group1 = Group.generate!.reload |
|
396 | group1 = Group.generate!.reload | |
397 | group2 = Group.generate!.reload |
|
397 | group2 = Group.generate!.reload | |
398 |
|
398 | |||
399 | expected_group_list = [ |
|
399 | expected_group_list = [ | |
400 | [group1.name, group1.id], |
|
400 | [group1.name, group1.id], | |
401 | [group2.name, group2.id] |
|
401 | [group2.name, group2.id] | |
402 | ] |
|
402 | ] | |
403 | assert_equal expected_group_list, @query.available_filters["member_of_group"][:values] |
|
403 | assert_equal expected_group_list.sort, @query.available_filters["member_of_group"][:values].sort | |
404 | end |
|
404 | end | |
405 |
|
405 | |||
406 | end |
|
406 | end | |
407 |
|
407 | |||
408 | context "'assigned_to_role' filter" do |
|
408 | context "'assigned_to_role' filter" do | |
409 | should "be present" do |
|
409 | should "be present" do | |
410 | assert @query.available_filters.keys.include?("assigned_to_role") |
|
410 | assert @query.available_filters.keys.include?("assigned_to_role") | |
411 | end |
|
411 | end | |
412 |
|
412 | |||
413 | should "be an optional list" do |
|
413 | should "be an optional list" do | |
414 | assert_equal :list_optional, @query.available_filters["assigned_to_role"][:type] |
|
414 | assert_equal :list_optional, @query.available_filters["assigned_to_role"][:type] | |
415 | end |
|
415 | end | |
416 |
|
416 | |||
417 | should "have a list of the Roles as values" do |
|
417 | should "have a list of the Roles as values" do | |
418 | assert @query.available_filters["assigned_to_role"][:values].include?(['Manager',1]) |
|
418 | assert @query.available_filters["assigned_to_role"][:values].include?(['Manager',1]) | |
419 | assert @query.available_filters["assigned_to_role"][:values].include?(['Developer',2]) |
|
419 | assert @query.available_filters["assigned_to_role"][:values].include?(['Developer',2]) | |
420 | assert @query.available_filters["assigned_to_role"][:values].include?(['Reporter',3]) |
|
420 | assert @query.available_filters["assigned_to_role"][:values].include?(['Reporter',3]) | |
421 | end |
|
421 | end | |
422 |
|
422 | |||
423 | should "not include the built in Roles as values" do |
|
423 | should "not include the built in Roles as values" do | |
424 | assert ! @query.available_filters["assigned_to_role"][:values].include?(['Non member',4]) |
|
424 | assert ! @query.available_filters["assigned_to_role"][:values].include?(['Non member',4]) | |
425 | assert ! @query.available_filters["assigned_to_role"][:values].include?(['Anonymous',5]) |
|
425 | assert ! @query.available_filters["assigned_to_role"][:values].include?(['Anonymous',5]) | |
426 | end |
|
426 | end | |
427 |
|
427 | |||
428 | end |
|
428 | end | |
429 |
|
429 | |||
430 | end |
|
430 | end | |
431 |
|
431 | |||
432 | context "#statement" do |
|
432 | context "#statement" do | |
433 | context "with 'member_of_group' filter" do |
|
433 | context "with 'member_of_group' filter" do | |
434 | setup do |
|
434 | setup do | |
435 | Group.destroy_all # No fixtures |
|
435 | Group.destroy_all # No fixtures | |
436 | @user_in_group = User.generate! |
|
436 | @user_in_group = User.generate! | |
437 | @second_user_in_group = User.generate! |
|
437 | @second_user_in_group = User.generate! | |
438 | @user_in_group2 = User.generate! |
|
438 | @user_in_group2 = User.generate! | |
439 | @user_not_in_group = User.generate! |
|
439 | @user_not_in_group = User.generate! | |
440 |
|
440 | |||
441 | @group = Group.generate!.reload |
|
441 | @group = Group.generate!.reload | |
442 | @group.users << @user_in_group |
|
442 | @group.users << @user_in_group | |
443 | @group.users << @second_user_in_group |
|
443 | @group.users << @second_user_in_group | |
444 |
|
444 | |||
445 | @group2 = Group.generate!.reload |
|
445 | @group2 = Group.generate!.reload | |
446 | @group2.users << @user_in_group2 |
|
446 | @group2.users << @user_in_group2 | |
447 |
|
447 | |||
448 | end |
|
448 | end | |
449 |
|
449 | |||
450 | should "search assigned to for users in the group" do |
|
450 | should "search assigned to for users in the group" do | |
451 | @query = Query.new(:name => '_') |
|
451 | @query = Query.new(:name => '_') | |
452 | @query.add_filter('member_of_group', '=', [@group.id.to_s]) |
|
452 | @query.add_filter('member_of_group', '=', [@group.id.to_s]) | |
453 |
|
453 | |||
454 | assert_query_statement_includes @query, "#{Issue.table_name}.assigned_to_id IN ('#{@user_in_group.id}','#{@second_user_in_group.id}')" |
|
454 | assert_query_statement_includes @query, "#{Issue.table_name}.assigned_to_id IN ('#{@user_in_group.id}','#{@second_user_in_group.id}')" | |
455 | assert_find_issues_with_query_is_successful @query |
|
455 | assert_find_issues_with_query_is_successful @query | |
456 | end |
|
456 | end | |
457 |
|
457 | |||
458 | should "search not assigned to any group member (none)" do |
|
458 | should "search not assigned to any group member (none)" do | |
459 | @query = Query.new(:name => '_') |
|
459 | @query = Query.new(:name => '_') | |
460 | @query.add_filter('member_of_group', '!*', ['']) |
|
460 | @query.add_filter('member_of_group', '!*', ['']) | |
461 |
|
461 | |||
462 | # Users not in a group |
|
462 | # Users not in a group | |
463 | assert_query_statement_includes @query, "#{Issue.table_name}.assigned_to_id IS NULL OR #{Issue.table_name}.assigned_to_id NOT IN ('#{@user_in_group.id}','#{@second_user_in_group.id}','#{@user_in_group2.id}')" |
|
463 | assert_query_statement_includes @query, "#{Issue.table_name}.assigned_to_id IS NULL OR #{Issue.table_name}.assigned_to_id NOT IN ('#{@user_in_group.id}','#{@second_user_in_group.id}','#{@user_in_group2.id}')" | |
464 | assert_find_issues_with_query_is_successful @query |
|
464 | assert_find_issues_with_query_is_successful @query | |
465 |
|
465 | |||
466 | end |
|
466 | end | |
467 |
|
467 | |||
468 | should "search assigned to any group member (all)" do |
|
468 | should "search assigned to any group member (all)" do | |
469 | @query = Query.new(:name => '_') |
|
469 | @query = Query.new(:name => '_') | |
470 | @query.add_filter('member_of_group', '*', ['']) |
|
470 | @query.add_filter('member_of_group', '*', ['']) | |
471 |
|
471 | |||
472 | # Only users in a group |
|
472 | # Only users in a group | |
473 | assert_query_statement_includes @query, "#{Issue.table_name}.assigned_to_id IN ('#{@user_in_group.id}','#{@second_user_in_group.id}','#{@user_in_group2.id}')" |
|
473 | assert_query_statement_includes @query, "#{Issue.table_name}.assigned_to_id IN ('#{@user_in_group.id}','#{@second_user_in_group.id}','#{@user_in_group2.id}')" | |
474 | assert_find_issues_with_query_is_successful @query |
|
474 | assert_find_issues_with_query_is_successful @query | |
475 |
|
475 | |||
476 | end |
|
476 | end | |
477 | end |
|
477 | end | |
478 |
|
478 | |||
479 | context "with 'assigned_to_role' filter" do |
|
479 | context "with 'assigned_to_role' filter" do | |
480 | setup do |
|
480 | setup do | |
481 | # No fixtures |
|
481 | # No fixtures | |
482 | MemberRole.delete_all |
|
482 | MemberRole.delete_all | |
483 | Member.delete_all |
|
483 | Member.delete_all | |
484 | Role.delete_all |
|
484 | Role.delete_all | |
485 |
|
485 | |||
486 | @manager_role = Role.generate!(:name => 'Manager') |
|
486 | @manager_role = Role.generate!(:name => 'Manager') | |
487 | @developer_role = Role.generate!(:name => 'Developer') |
|
487 | @developer_role = Role.generate!(:name => 'Developer') | |
488 |
|
488 | |||
489 | @project = Project.generate! |
|
489 | @project = Project.generate! | |
490 | @manager = User.generate! |
|
490 | @manager = User.generate! | |
491 | @developer = User.generate! |
|
491 | @developer = User.generate! | |
492 | @boss = User.generate! |
|
492 | @boss = User.generate! | |
493 | User.add_to_project(@manager, @project, @manager_role) |
|
493 | User.add_to_project(@manager, @project, @manager_role) | |
494 | User.add_to_project(@developer, @project, @developer_role) |
|
494 | User.add_to_project(@developer, @project, @developer_role) | |
495 | User.add_to_project(@boss, @project, [@manager_role, @developer_role]) |
|
495 | User.add_to_project(@boss, @project, [@manager_role, @developer_role]) | |
496 | end |
|
496 | end | |
497 |
|
497 | |||
498 | should "search assigned to for users with the Role" do |
|
498 | should "search assigned to for users with the Role" do | |
499 | @query = Query.new(:name => '_') |
|
499 | @query = Query.new(:name => '_') | |
500 | @query.add_filter('assigned_to_role', '=', [@manager_role.id.to_s]) |
|
500 | @query.add_filter('assigned_to_role', '=', [@manager_role.id.to_s]) | |
501 |
|
501 | |||
502 | assert_query_statement_includes @query, "#{Issue.table_name}.assigned_to_id IN ('#{@manager.id}','#{@boss.id}')" |
|
502 | assert_query_statement_includes @query, "#{Issue.table_name}.assigned_to_id IN ('#{@manager.id}','#{@boss.id}')" | |
503 | assert_find_issues_with_query_is_successful @query |
|
503 | assert_find_issues_with_query_is_successful @query | |
504 | end |
|
504 | end | |
505 |
|
505 | |||
506 | should "search assigned to for users not assigned to any Role (none)" do |
|
506 | should "search assigned to for users not assigned to any Role (none)" do | |
507 | @query = Query.new(:name => '_') |
|
507 | @query = Query.new(:name => '_') | |
508 | @query.add_filter('assigned_to_role', '!*', ['']) |
|
508 | @query.add_filter('assigned_to_role', '!*', ['']) | |
509 |
|
509 | |||
510 | assert_query_statement_includes @query, "#{Issue.table_name}.assigned_to_id IS NULL OR #{Issue.table_name}.assigned_to_id NOT IN ('#{@manager.id}','#{@developer.id}','#{@boss.id}')" |
|
510 | assert_query_statement_includes @query, "#{Issue.table_name}.assigned_to_id IS NULL OR #{Issue.table_name}.assigned_to_id NOT IN ('#{@manager.id}','#{@developer.id}','#{@boss.id}')" | |
511 | assert_find_issues_with_query_is_successful @query |
|
511 | assert_find_issues_with_query_is_successful @query | |
512 | end |
|
512 | end | |
513 |
|
513 | |||
514 | should "search assigned to for users assigned to any Role (all)" do |
|
514 | should "search assigned to for users assigned to any Role (all)" do | |
515 | @query = Query.new(:name => '_') |
|
515 | @query = Query.new(:name => '_') | |
516 | @query.add_filter('assigned_to_role', '*', ['']) |
|
516 | @query.add_filter('assigned_to_role', '*', ['']) | |
517 |
|
517 | |||
518 | assert_query_statement_includes @query, "#{Issue.table_name}.assigned_to_id IN ('#{@manager.id}','#{@developer.id}','#{@boss.id}')" |
|
518 | assert_query_statement_includes @query, "#{Issue.table_name}.assigned_to_id IN ('#{@manager.id}','#{@developer.id}','#{@boss.id}')" | |
519 | assert_find_issues_with_query_is_successful @query |
|
519 | assert_find_issues_with_query_is_successful @query | |
520 | end |
|
520 | end | |
521 | end |
|
521 | end | |
522 | end |
|
522 | end | |
523 |
|
523 | |||
524 | end |
|
524 | end |
General Comments 0
You need to be logged in to leave comments.
Login now