Mercurial > hg > soundsoftware-site
comparison test/unit/query_test.rb @ 441:cbce1fd3b1b7 redmine-1.2
Update to Redmine 1.2-stable branch (Redmine SVN rev 6000)
author | Chris Cannam |
---|---|
date | Mon, 06 Jun 2011 14:24:13 +0100 |
parents | 051f544170fe |
children | cbb26bc654de |
comparison
equal
deleted
inserted
replaced
245:051f544170fe | 441:cbce1fd3b1b7 |
---|---|
1 # redMine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2008 Jean-Philippe Lang | 2 # Copyright (C) 2006-2011 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. |
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_range_for_this_week_with_week_starting_on_monday | |
195 I18n.locale = :fr | |
196 assert_equal '1', I18n.t(:general_first_day_of_week) | |
197 | |
198 Date.stubs(:today).returns(Date.parse('2011-04-29')) | |
199 | |
200 query = Query.new(:project => Project.find(1), :name => '_') | |
201 query.add_filter('due_date', 'w', ['']) | |
202 assert query.statement.match(/issues\.due_date > '2011-04-24 23:59:59(\.9+)?' AND issues\.due_date <= '2011-05-01 23:59:59(\.9+)?/), "range not found in #{query.statement}" | |
203 I18n.locale = :en | |
204 end | |
205 | |
206 def test_range_for_this_week_with_week_starting_on_sunday | |
207 I18n.locale = :en | |
208 assert_equal '7', I18n.t(:general_first_day_of_week) | |
209 | |
210 Date.stubs(:today).returns(Date.parse('2011-04-29')) | |
211 | |
212 query = Query.new(:project => Project.find(1), :name => '_') | |
213 query.add_filter('due_date', 'w', ['']) | |
214 assert query.statement.match(/issues\.due_date > '2011-04-23 23:59:59(\.9+)?' AND issues\.due_date <= '2011-04-30 23:59:59(\.9+)?/), "range not found in #{query.statement}" | |
215 end | |
216 | |
194 def test_operator_does_not_contains | 217 def test_operator_does_not_contains |
195 query = Query.new(:project => Project.find(1), :name => '_') | 218 query = Query.new(:project => Project.find(1), :name => '_') |
196 query.add_filter('subject', '!~', ['uNable']) | 219 query.add_filter('subject', '!~', ['uNable']) |
197 assert query.statement.include?("LOWER(#{Issue.table_name}.subject) NOT LIKE '%unable%'") | 220 assert query.statement.include?("LOWER(#{Issue.table_name}.subject) NOT LIKE '%unable%'") |
198 find_issues_with_query(query) | 221 find_issues_with_query(query) |
214 result = find_issues_with_query(query) | 237 result = find_issues_with_query(query) |
215 assert_not_nil result | 238 assert_not_nil result |
216 assert !result.empty? | 239 assert !result.empty? |
217 assert_equal((Issue.visible - Issue.watched_by(User.current)).sort_by(&:id).size, result.sort_by(&:id).size) | 240 assert_equal((Issue.visible - Issue.watched_by(User.current)).sort_by(&:id).size, result.sort_by(&:id).size) |
218 User.current = nil | 241 User.current = nil |
242 end | |
243 | |
244 def test_statement_should_be_nil_with_no_filters | |
245 q = Query.new(:name => '_') | |
246 q.filters = {} | |
247 | |
248 assert q.valid? | |
249 assert_nil q.statement | |
219 end | 250 end |
220 | 251 |
221 def test_default_columns | 252 def test_default_columns |
222 q = Query.new | 253 q = Query.new |
223 assert !q.columns.empty? | 254 assert !q.columns.empty? |