Fixed test failure with ruby1.8 (#8842).

git-svn-id: http://svn.redmine.org/redmine/trunk@12479 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2014-01-03 19:42:43 +00:00
parent 429b3a5dae
commit 3c540594dc
2 changed files with 15 additions and 1 deletions

View File

@ -243,7 +243,7 @@ class Query < ActiveRecord::Base
case operator_for(field)
when "=", ">=", "<=", "><"
add_filter_error(field, :invalid) if values_for(field).detect {|v|
v.present? && (!v.match(/\A\d{4}-\d{2}-\d{2}(T\d{2}((:)?\d{2}){,2}(Z|\d{2}:?\d{2})?)?\z/) || parse_date(v).nil?)
v.present? && (!v.match(/\A\d{4}-\d{2}-\d{2}(T\d{2}((:)?\d{2}){0,2}(Z|\d{2}:?\d{2})?)?\z/) || parse_date(v).nil?)
}
when ">t-", "<t-", "t-", ">t+", "<t+", "t+", "><t+", "><t-"
add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^\d+$/) }

View File

@ -449,6 +449,13 @@ class QueryTest < ActiveSupport::TestCase
find_issues_with_query(query)
end
def test_operator_date_lesser_than_with_timestamp
query = IssueQuery.new(:name => '_')
query.add_filter('updated_on', '<=', ['2011-07-10T19:13:52'])
assert_match /issues\.updated_on <= '2011-07-10 19:13:52/, query.statement
find_issues_with_query(query)
end
def test_operator_date_greater_than
query = IssueQuery.new(:name => '_')
query.add_filter('due_date', '>=', ['2011-07-10'])
@ -456,6 +463,13 @@ class QueryTest < ActiveSupport::TestCase
find_issues_with_query(query)
end
def test_operator_date_greater_than_with_timestamp
query = IssueQuery.new(:name => '_')
query.add_filter('updated_on', '>=', ['2011-07-10T19:13:52'])
assert_match /issues\.updated_on > '2011-07-10 19:13:51'/, query.statement
find_issues_with_query(query)
end
def test_operator_date_between
query = IssueQuery.new(:name => '_')
query.add_filter('due_date', '><', ['2011-06-23', '2011-07-10'])