diff 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
line wrap: on
line diff
--- a/test/unit/query_test.rb	Thu Mar 03 11:42:28 2011 +0000
+++ b/test/unit/query_test.rb	Mon Jun 06 14:24:13 2011 +0100
@@ -1,5 +1,5 @@
-# redMine - project management software
-# Copyright (C) 2006-2008  Jean-Philippe Lang
+# Redmine - project management software
+# Copyright (C) 2006-2011  Jean-Philippe Lang
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -191,6 +191,29 @@
     result.each {|issue| assert issue.subject.downcase.include?('unable') }
   end
   
+  def test_range_for_this_week_with_week_starting_on_monday
+    I18n.locale = :fr
+    assert_equal '1', I18n.t(:general_first_day_of_week)
+    
+    Date.stubs(:today).returns(Date.parse('2011-04-29'))
+    
+    query = Query.new(:project => Project.find(1), :name => '_')
+    query.add_filter('due_date', 'w', [''])
+    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}"
+    I18n.locale = :en
+  end
+  
+  def test_range_for_this_week_with_week_starting_on_sunday
+    I18n.locale = :en
+    assert_equal '7', I18n.t(:general_first_day_of_week)
+    
+    Date.stubs(:today).returns(Date.parse('2011-04-29'))
+    
+    query = Query.new(:project => Project.find(1), :name => '_')
+    query.add_filter('due_date', 'w', [''])
+    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}"
+  end
+  
   def test_operator_does_not_contains
     query = Query.new(:project => Project.find(1), :name => '_')
     query.add_filter('subject', '!~', ['uNable'])
@@ -218,6 +241,14 @@
     User.current = nil
   end
   
+  def test_statement_should_be_nil_with_no_filters
+    q = Query.new(:name => '_')
+    q.filters = {}
+    
+    assert q.valid?
+    assert_nil q.statement
+  end
+  
   def test_default_columns
     q = Query.new
     assert !q.columns.empty?