Defect #33941 » fixed-33941.patch
| app/controllers/account_controller.rb | ||
|---|---|---|
| 441 | 441 |
def register_automatically(user, &block) |
| 442 | 442 |
# Automatic activation |
| 443 | 443 |
user.activate |
| 444 |
user.last_login_on = Time.now
|
|
| 444 |
user.last_login_on = Time.current
|
|
| 445 | 445 |
if user.save |
| 446 | 446 |
self.logged_user = user |
| 447 | 447 |
flash[:notice] = l(:notice_account_activated) |
| app/controllers/activities_controller.rb | ||
|---|---|---|
| 55 | 55 |
end |
| 56 | 56 |
end |
| 57 | 57 | |
| 58 |
events = @activity.events(@date_from, @date_to)
|
|
| 58 |
events = @activity.events(@date_from.beginning_of_day, @date_to.end_of_day)
|
|
| 59 | 59 | |
| 60 | 60 |
if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, events.size, User.current, current_language]) |
| 61 | 61 |
respond_to do |format| |
| app/models/query.rb | ||
|---|---|---|
| 1454 | 1454 |
end |
| 1455 | 1455 | |
| 1456 | 1456 |
def date_for_user_time_zone(y, m, d) |
| 1457 |
if tz = User.current.time_zone |
|
| 1458 |
tz.local y, m, d |
|
| 1459 |
else |
|
| 1460 |
Time.local y, m, d |
|
| 1461 |
end |
|
| 1457 |
(User.current.time_zone || Time.current.time_zone).local y, m, d |
|
| 1462 | 1458 |
end |
| 1463 | 1459 | |
| 1464 | 1460 |
# Returns a SQL clause for a date or datetime field. |
| 1465 | 1461 |
def date_clause(table, field, from, to, is_custom_filter) |
| 1462 |
field_type = Module.const_get("#{table}".classify).columns_hash["#{field}"].type rescue nil
|
|
| 1466 | 1463 |
s = [] |
| 1467 |
if from |
|
| 1468 |
if from.is_a?(Date) |
|
| 1469 |
from = date_for_user_time_zone(from.year, from.month, from.day).yesterday.end_of_day |
|
| 1470 |
else |
|
| 1471 |
from = from - 1 # second |
|
| 1472 |
end |
|
| 1473 |
if self.class.default_timezone == :utc |
|
| 1474 |
from = from.utc |
|
| 1475 |
end |
|
| 1476 |
s << ("#{table}.#{field} > '%s'" % [quoted_time(from, is_custom_filter)])
|
|
| 1477 |
end |
|
| 1478 |
if to |
|
| 1479 |
if to.is_a?(Date) |
|
| 1480 |
to = date_for_user_time_zone(to.year, to.month, to.day).end_of_day |
|
| 1464 |
if field_type == :date |
|
| 1465 |
{
|
|
| 1466 |
:from => from, |
|
| 1467 |
:to => to, |
|
| 1468 |
}.each do |key, val| |
|
| 1469 |
next unless val |
|
| 1470 |
val = val.to_date |
|
| 1471 |
s << ("#{table}.#{field} #{key == :from ? '>=' : '<='} '%s'" % [self.class.connection.quoted_date(val)])
|
|
| 1481 | 1472 |
end |
| 1482 |
if self.class.default_timezone == :utc |
|
| 1483 |
to = to.utc |
|
| 1473 |
else |
|
| 1474 |
{
|
|
| 1475 |
:from => from, |
|
| 1476 |
:to => to, |
|
| 1477 |
}.each do |key, val| |
|
| 1478 |
next unless val |
|
| 1479 |
if val.is_a?(Date) |
|
| 1480 |
val = date_for_user_time_zone(val.year, val.month, val.day) |
|
| 1481 |
val = val.yesterday if key == :from |
|
| 1482 |
val = val.end_of_day |
|
| 1483 |
else |
|
| 1484 |
val = val + (key == :from ? -1 : 0) # second |
|
| 1485 |
end |
|
| 1486 |
if self.class.default_timezone == :utc |
|
| 1487 |
val = val.utc |
|
| 1488 |
end |
|
| 1489 |
s << ("#{table}.#{field} #{key == :from ? '>' : '<='} '%s'" % [quoted_time(val, is_custom_filter)])
|
|
| 1484 | 1490 |
end |
| 1485 |
s << ("#{table}.#{field} <= '%s'" % [quoted_time(to, is_custom_filter)])
|
|
| 1486 | 1491 |
end |
| 1487 | 1492 |
s.join(' AND ')
|
| 1488 | 1493 |
end |
| app/models/setting.rb | ||
|---|---|---|
| 93 | 93 | |
| 94 | 94 |
# Hash used to cache setting values |
| 95 | 95 |
@cached_settings = {}
|
| 96 |
@cached_cleared_on = Time.now
|
|
| 96 |
@cached_cleared_on = Time.current
|
|
| 97 | 97 | |
| 98 | 98 |
def value |
| 99 | 99 |
v = read_attribute(:value) |
| ... | ... | |
| 269 | 269 |
# Clears the settings cache |
| 270 | 270 |
def self.clear_cache |
| 271 | 271 |
@cached_settings.clear |
| 272 |
@cached_cleared_on = Time.now
|
|
| 272 |
@cached_cleared_on = Time.current
|
|
| 273 | 273 |
logger.info "Settings cache cleared." if logger |
| 274 | 274 |
end |
| 275 | 275 | |
| app/models/token.rb | ||
|---|---|---|
| 67 | 67 |
end |
| 68 | 68 | |
| 69 | 69 |
if validity_time |
| 70 |
Time.now - validity_time
|
|
| 70 |
Time.current - validity_time
|
|
| 71 | 71 |
end |
| 72 | 72 |
end |
| 73 | 73 | |
| app/models/user.rb | ||
|---|---|---|
| 342 | 342 |
def salt_password(clear_password) |
| 343 | 343 |
self.salt = User.generate_salt |
| 344 | 344 |
self.hashed_password = User.hash_password("#{salt}#{User.hash_password clear_password}")
|
| 345 |
self.passwd_changed_on = Time.now.change(:usec => 0)
|
|
| 345 |
self.passwd_changed_on = Time.current.change(:usec => 0)
|
|
| 346 | 346 |
end |
| 347 | 347 | |
| 348 | 348 |
# Does the backend storage allow this user to change their password? |
| ... | ... | |
| 405 | 405 |
end |
| 406 | 406 | |
| 407 | 407 |
def time_zone |
| 408 |
@time_zone ||= (self.pref.time_zone.blank? ? nil : ActiveSupport::TimeZone[self.pref.time_zone])
|
|
| 408 |
@time_zone ||= (self.pref.time_zone.blank? ? Time.current.time_zone : ActiveSupport::TimeZone[self.pref.time_zone])
|
|
| 409 | 409 |
end |
| 410 | 410 | |
| 411 | 411 |
def force_default_language? |
| ... | ... | |
| 567 | 567 | |
| 568 | 568 |
# Returns the current day according to user's time zone |
| 569 | 569 |
def today |
| 570 |
if time_zone.nil? |
|
| 571 |
Date.today |
|
| 572 |
else |
|
| 573 |
time_zone.today |
|
| 574 |
end |
|
| 570 |
time_zone&.today || Date.current |
|
| 575 | 571 |
end |
| 576 | 572 | |
| 577 | 573 |
# Returns the day of +time+ according to user's time zone |
| ... | ... | |
| 580 | 576 |
end |
| 581 | 577 | |
| 582 | 578 |
def convert_time_to_user_timezone(time) |
| 583 |
if self.time_zone |
|
| 584 |
time.in_time_zone(self.time_zone) |
|
| 585 |
else |
|
| 586 |
time.utc? ? time.localtime : time |
|
| 587 |
end |
|
| 579 |
time.in_time_zone(self.time_zone || Time.current.time_zone) |
|
| 588 | 580 |
end |
| 589 | 581 | |
| 590 | 582 |
def logged? |
| app/views/common/feed.atom.builder | ||
|---|---|---|
| 9 | 9 |
xml.link "rel" => "alternate", "href" => url_for(:params => request.query_parameters.merge(:format => nil, :key => nil), :only_path => false, :protocol => protocol, :host => host) |
| 10 | 10 |
xml.id home_url |
| 11 | 11 |
xml.icon favicon_url |
| 12 |
xml.updated((@items.first ? @items.first.event_datetime : Time.now).xmlschema)
|
|
| 12 |
xml.updated((@items.first ? @items.first.event_datetime : Time.current).xmlschema)
|
|
| 13 | 13 |
xml.author { xml.name "#{Setting.app_title}" }
|
| 14 | 14 |
xml.generator(:uri => Redmine::Info.url) { xml.text! Redmine::Info.app_name; }
|
| 15 | 15 |
@items.each do |item| |
| app/views/journals/index.builder | ||
|---|---|---|
| 7 | 7 |
xml.link "rel" => "alternate", "href" => home_url |
| 8 | 8 |
xml.id home_url |
| 9 | 9 |
xml.icon favicon_url |
| 10 |
xml.updated((@journals.first ? @journals.first.event_datetime : Time.now).xmlschema)
|
|
| 10 |
xml.updated((@journals.first ? @journals.first.event_datetime : Time.current).xmlschema)
|
|
| 11 | 11 |
xml.author { xml.name "#{Setting.app_title}" }
|
| 12 | 12 |
@journals.each do |change| |
| 13 | 13 |
issue = change.issue |
| lib/redmine/database.rb | ||
|---|---|---|
| 76 | 76 |
def timestamp_to_date(column, time_zone) |
| 77 | 77 |
if postgresql? |
| 78 | 78 |
if time_zone |
| 79 |
identifier = ActiveSupport::TimeZone.find_tzinfo(time_zone.name).identifier |
|
| 80 |
"(#{column}::timestamptz AT TIME ZONE '#{identifier}')::date"
|
|
| 79 |
offset_tz = time_zone.utc_offset |
|
| 80 |
offset_default = |
|
| 81 |
Time.now.__send__(ActiveRecord::Base.default_timezone == :utc ? :utc : :localtime).utc_offset |
|
| 82 |
"(#{column} + INTERVAL '#{offset_tz - offset_default} SECOND')::date"
|
|
| 81 | 83 |
else |
| 82 | 84 |
"#{column}::date"
|
| 83 | 85 |
end |
| 84 | 86 |
elsif mysql? |
| 85 | 87 |
if time_zone |
| 86 |
user_identifier = ActiveSupport::TimeZone.find_tzinfo(time_zone.name).identifier |
|
| 87 |
local_identifier = ActiveSupport::TimeZone.find_tzinfo(Time.zone.name).identifier |
|
| 88 |
"DATE(CONVERT_TZ(#{column},'#{local_identifier}', '#{user_identifier}'))"
|
|
| 88 |
offset_tz = time_zone.utc_offset |
|
| 89 |
offset_default = |
|
| 90 |
Time.now.__send__(ActiveRecord::Base.default_timezone == :utc ? :utc : :localtime).utc_offset |
|
| 91 |
"DATE(#{column} + INTERVAL #{offset_tz - offset_default} SECOND)"
|
|
| 89 | 92 |
else |
| 90 | 93 |
"DATE(#{column})"
|
| 91 | 94 |
end |
| test/fixtures/issues.yml | ||
|---|---|---|
| 111 | 111 |
assigned_to_id: |
| 112 | 112 |
author_id: 2 |
| 113 | 113 |
status_id: 1 |
| 114 |
start_date: <%= Date.today.to_s(:db) %>
|
|
| 114 |
start_date: <%= Date.current.to_s(:db) %>
|
|
| 115 | 115 |
due_date: <%= 1.days.from_now.to_date.to_s(:db) %> |
| 116 | 116 |
root_id: 6 |
| 117 | 117 |
lft: 1 |
| ... | ... | |
| 131 | 131 |
author_id: 2 |
| 132 | 132 |
status_id: 1 |
| 133 | 133 |
start_date: <%= 10.days.ago.to_s(:db) %> |
| 134 |
due_date: <%= Date.today.to_s(:db) %>
|
|
| 134 |
due_date: <%= Date.current.to_s(:db) %>
|
|
| 135 | 135 |
lock_version: 0 |
| 136 | 136 |
root_id: 7 |
| 137 | 137 |
lft: 1 |
| ... | ... | |
| 171 | 171 |
assigned_to_id: |
| 172 | 172 |
author_id: 2 |
| 173 | 173 |
status_id: 1 |
| 174 |
start_date: <%= Date.today.to_s(:db) %>
|
|
| 174 |
start_date: <%= Date.current.to_s(:db) %>
|
|
| 175 | 175 |
due_date: <%= 1.days.from_now.to_date.to_s(:db) %> |
| 176 | 176 |
root_id: 9 |
| 177 | 177 |
lft: 1 |
| ... | ... | |
| 190 | 190 |
assigned_to_id: |
| 191 | 191 |
author_id: 2 |
| 192 | 192 |
status_id: 1 |
| 193 |
start_date: <%= Date.today.to_s(:db) %>
|
|
| 193 |
start_date: <%= Date.current.to_s(:db) %>
|
|
| 194 | 194 |
due_date: <%= 1.days.from_now.to_date.to_s(:db) %> |
| 195 | 195 |
root_id: 10 |
| 196 | 196 |
lft: 1 |
| test/functional/issues_controller_test.rb | ||
|---|---|---|
| 408 | 408 |
end |
| 409 | 409 | |
| 410 | 410 |
def test_index_grouped_by_created_on_if_time_zone_is_utc |
| 411 |
# TODO: test fails with mysql |
|
| 412 |
skip if mysql? |
|
| 413 | 411 |
skip unless IssueQuery.new.groupable_columns.detect {|c| c.name == :created_on}
|
| 414 | ||
| 415 |
@request.session[:user_id] = 2
|
|
| 416 |
User.find(2).pref.update(time_zone: 'UTC')
|
|
| 412 |
current_user = User.find(2) |
|
| 413 |
@request.session[:user_id] = current_user.id
|
|
| 414 |
current_user.pref.update(time_zone: 'UTC')
|
|
| 417 | 415 | |
| 418 | 416 |
get( |
| 419 | 417 |
:index, |
| ... | ... | |
| 424 | 422 |
) |
| 425 | 423 |
assert_response :success |
| 426 | 424 | |
| 427 |
assert_select 'tr.group span.name', :text => '07/19/2006' do |
|
| 425 |
group_name = format_date(current_user.convert_time_to_user_timezone(issues(:issues_002).created_on)) |
|
| 426 |
assert_select 'tr.group span.name', :text => group_name do |
|
| 428 | 427 |
assert_select '+ span.count', :text => '2' |
| 429 | 428 |
end |
| 430 | 429 |
end |
| ... | ... | |
| 444 | 443 |
) |
| 445 | 444 |
assert_response :success |
| 446 | 445 | |
| 447 |
# group_name depends on localtime |
|
| 448 |
group_name = format_date(Issue.second.created_on.localtime) |
|
| 446 |
group_name = format_date(current_user.convert_time_to_user_timezone(issues(:issues_002).created_on)) |
|
| 449 | 447 |
assert_select 'tr.group span.name', :text => group_name do |
| 450 | 448 |
assert_select '+ span.count', :text => '2' |
| 451 | 449 |
end |
| ... | ... | |
| 3381 | 3379 |
) |
| 3382 | 3380 |
assert_response :success |
| 3383 | 3381 |
assert_select 'input[name=?][value=?]', 'issue[start_date]', |
| 3384 |
Date.today.to_s
|
|
| 3382 |
Date.current.to_s
|
|
| 3385 | 3383 |
end |
| 3386 | 3384 |
end |
| 3387 | 3385 | |
| ... | ... | |
| 3831 | 3829 |
:id => Issue.last.id |
| 3832 | 3830 |
issue = Issue.find_by_subject('This is the test_new issue')
|
| 3833 | 3831 |
assert_not_nil issue |
| 3834 |
assert_equal Date.today, issue.start_date
|
|
| 3832 |
assert_equal Date.current, issue.start_date
|
|
| 3835 | 3833 |
end |
| 3836 | 3834 |
end |
| 3837 | 3835 | |
| test/helpers/application_helper_test.rb | ||
|---|---|---|
| 1505 | 1505 | |
| 1506 | 1506 |
def test_due_date_distance_in_words |
| 1507 | 1507 |
to_test = {
|
| 1508 |
Date.today => 'Due in 0 days',
|
|
| 1509 |
Date.today + 1 => 'Due in 1 day',
|
|
| 1510 |
Date.today + 100 => 'Due in about 3 months',
|
|
| 1511 |
Date.today + 20000 => 'Due in over 54 years',
|
|
| 1512 |
Date.today - 1 => '1 day late',
|
|
| 1513 |
Date.today - 100 => 'about 3 months late',
|
|
| 1514 |
Date.today - 20000 => 'over 54 years late',
|
|
| 1508 |
Date.current => 'Due in 0 days',
|
|
| 1509 |
Date.current + 1 => 'Due in 1 day',
|
|
| 1510 |
Date.current + 100 => 'Due in about 3 months',
|
|
| 1511 |
Date.current + 20000 => 'Due in over 54 years',
|
|
| 1512 |
Date.current - 1 => '1 day late',
|
|
| 1513 |
Date.current - 100 => 'about 3 months late',
|
|
| 1514 |
Date.current - 20000 => 'over 54 years late',
|
|
| 1515 | 1515 |
} |
| 1516 | 1516 |
::I18n.locale = :en |
| 1517 | 1517 |
to_test.each do |date, expected| |
| test/helpers/settings_helper_test.rb | ||
|---|---|---|
| 24 | 24 |
include ERB::Util |
| 25 | 25 | |
| 26 | 26 |
def test_date_format_setting_options_should_include_human_readable_format |
| 27 |
Date.stubs(:today).returns(Date.parse("2015-07-14"))
|
|
| 28 | ||
| 29 |
options = date_format_setting_options('en')
|
|
| 30 |
assert_include ["2015-07-14 (yyyy-mm-dd)", "%Y-%m-%d"], options
|
|
| 27 |
travel_to Date.parse("2015-07-14") do
|
|
| 28 |
options = date_format_setting_options('en')
|
|
| 29 |
assert_include ["2015-07-14 (yyyy-mm-dd)", "%Y-%m-%d"], options
|
|
| 30 |
end
|
|
| 31 | 31 |
end |
| 32 | 32 |
end |
| test/unit/lib/redmine/helpers/gantt_test.rb | ||
|---|---|---|
| 37 | 37 |
end |
| 38 | 38 | |
| 39 | 39 |
def today |
| 40 |
@today ||= Date.today
|
|
| 40 |
@today ||= Date.current
|
|
| 41 | 41 |
end |
| 42 | 42 |
private :today |
| 43 | 43 | |
| ... | ... | |
| 364 | 364 |
create_gantt |
| 365 | 365 |
[gantt_start - 1, gantt_start].each do |start_date| |
| 366 | 366 |
@output_buffer = @gantt.line(start_date, gantt_start, 30, false, 'line', :format => :html, :zoom => 4) |
| 367 |
# the leftmost date (Date.today - 14 days)
|
|
| 367 |
# the leftmost date (Date.current - 14 days)
|
|
| 368 | 368 |
assert_select 'div.task_todo[style*="left:0px"]', 1, @output_buffer |
| 369 | 369 |
assert_select 'div.task_todo[style*="width:2px"]', 1, @output_buffer |
| 370 | 370 |
end |
| ... | ... | |
| 374 | 374 |
create_gantt |
| 375 | 375 |
[gantt_end, gantt_end + 1].each do |end_date| |
| 376 | 376 |
@output_buffer = @gantt.line(gantt_end, end_date, 30, false, 'line', :format => :html, :zoom => 4) |
| 377 |
# the rightmost date (Date.today + 14 days)
|
|
| 377 |
# the rightmost date (Date.current + 14 days)
|
|
| 378 | 378 |
assert_select 'div.task_todo[style*="left:112px"]', 1, @output_buffer |
| 379 | 379 |
assert_select 'div.task_todo[style*="width:2px"]', 1, @output_buffer |
| 380 | 380 |
end |
| test/unit/lib/redmine/i18n_test.rb | ||
|---|---|---|
| 88 | 88 | |
| 89 | 89 |
def test_time_format |
| 90 | 90 |
set_language_if_valid 'en' |
| 91 |
now = Time.parse('2011-02-20 15:45:22')
|
|
| 91 |
now = Time.zone.parse('2011-02-20 15:45:22')
|
|
| 92 | 92 |
with_settings :time_format => '%H:%M' do |
| 93 | 93 |
with_settings :date_format => '' do |
| 94 |
assert_equal '02/20/2011 15:45', format_time(now)
|
|
| 95 |
assert_equal '15:45', format_time(now, false)
|
|
| 94 |
assert_equal now.strftime('%m/%d/%Y %H:%M'), format_time(now)
|
|
| 95 |
assert_equal now.strftime('%H:%M'), format_time(now, false)
|
|
| 96 | 96 |
end |
| 97 | 97 |
with_settings :date_format => '%Y-%m-%d' do |
| 98 |
assert_equal '2011-02-20 15:45', format_time(now)
|
|
| 99 |
assert_equal '15:45', format_time(now, false)
|
|
| 98 |
assert_equal now.strftime('%Y-%m-%d %H:%M'), format_time(now)
|
|
| 99 |
assert_equal now.strftime('%H:%M'), format_time(now, false)
|
|
| 100 | 100 |
end |
| 101 | 101 |
end |
| 102 | 102 |
end |
| 103 | 103 | |
| 104 | 104 |
def test_time_format_default |
| 105 | 105 |
set_language_if_valid 'en' |
| 106 |
now = Time.parse('2011-02-20 15:45:22')
|
|
| 106 |
now = Time.zone.parse('2011-02-20 15:45:22')
|
|
| 107 | 107 |
with_settings :time_format => '' do |
| 108 | 108 |
with_settings :date_format => '' do |
| 109 |
assert_equal '02/20/2011 03:45 PM', format_time(now)
|
|
| 110 |
assert_equal '03:45 PM', format_time(now, false)
|
|
| 109 |
assert_equal now.strftime('%m/%d/%Y %I:%M %p'), format_time(now)
|
|
| 110 |
assert_equal now.strftime('%I:%M %p'), format_time(now, false)
|
|
| 111 | 111 |
end |
| 112 | 112 |
with_settings :date_format => '%Y-%m-%d' do |
| 113 |
assert_equal '2011-02-20 03:45 PM', format_time(now)
|
|
| 114 |
assert_equal '03:45 PM', format_time(now, false)
|
|
| 113 |
assert_equal now.strftime('%Y-%m-%d %I:%M %p'), format_time(now)
|
|
| 114 |
assert_equal now.strftime('%I:%M %p'), format_time(now, false)
|
|
| 115 | 115 |
end |
| 116 | 116 |
end |
| 117 | 117 |
end |
| 118 | 118 | |
| 119 | 119 |
def test_utc_time_format |
| 120 | 120 |
set_language_if_valid 'en' |
| 121 |
now = Time.now
|
|
| 121 |
now = Time.current
|
|
| 122 | 122 |
with_settings :date_format => '%d %m %Y', :time_format => '%H %M' do |
| 123 |
assert_equal now.localtime.strftime('%d %m %Y %H %M'), format_time(now.utc), "User time zone was #{User.current.time_zone}"
|
|
| 124 |
assert_equal now.localtime.strftime('%H %M'), format_time(now.utc, false)
|
|
| 123 |
assert_equal now.strftime('%d %m %Y %H %M'), format_time(now.utc), "User time zone was #{User.current.time_zone}"
|
|
| 124 |
assert_equal now.strftime('%H %M'), format_time(now.utc, false)
|
|
| 125 | 125 |
end |
| 126 | 126 |
end |
| 127 | 127 | |
| test/unit/mail_handler_test.rb | ||
|---|---|---|
| 289 | 289 |
with_settings :default_issue_start_date_to_creation_date => '1' do |
| 290 | 290 |
issue = submit_email('ticket_with_cc.eml', :issue => {:project => 'ecookbook'})
|
| 291 | 291 |
assert issue.is_a?(Issue) |
| 292 |
assert_equal Date.today, issue.start_date
|
|
| 292 |
assert_equal Date.current, issue.start_date
|
|
| 293 | 293 |
end |
| 294 | 294 |
end |
| 295 | 295 | |
| test/unit/mailer_test.rb | ||
|---|---|---|
| 685 | 685 |
end |
| 686 | 686 | |
| 687 | 687 |
def test_reminders |
| 688 |
users(:users_003).pref.update_attribute :time_zone, 'UTC' # dlopper |
|
| 689 | 688 |
days = 42 |
| 690 | 689 |
Mailer.reminders(:days => days) |
| 691 | 690 |
assert_equal 1, ActionMailer::Base.deliveries.size |
| ... | ... | |
| 709 | 708 |
with_settings :default_language => 'fr' do |
| 710 | 709 |
user = User.find(3) |
| 711 | 710 |
user.update_attribute :language, '' |
| 712 |
user.pref.update_attribute :time_zone, 'UTC' |
|
| 713 | 711 |
Mailer.reminders(:days => 42) |
| 714 | 712 |
assert_equal 1, ActionMailer::Base.deliveries.size |
| 715 | 713 |
mail = last_email |
| ... | ... | |
| 736 | 734 |
end |
| 737 | 735 | |
| 738 | 736 |
def test_reminders_for_users |
| 739 |
users(:users_003).pref.update_attribute :time_zone, 'UTC' # dlopper |
|
| 740 | 737 |
Mailer.reminders(:days => 42, :users => ['5']) |
| 741 | 738 |
assert_equal 0, ActionMailer::Base.deliveries.size # No mail for dlopper |
| 742 | 739 |
Mailer.reminders(:days => 42, :users => ['3']) |
| ... | ... | |
| 752 | 749 |
Member.create!(:project_id => 1, :principal => group, :role_ids => [1]) |
| 753 | 750 |
[users(:users_002), users(:users_003)].each do |user| # jsmith, dlopper |
| 754 | 751 |
group.users << user |
| 755 |
user.pref.update_attribute :time_zone, 'UTC' |
|
| 756 | 752 |
end |
| 757 | 753 | |
| 758 | 754 |
Issue.update_all(:assigned_to_id => nil) |
| ... | ... | |
| 810 | 806 | |
| 811 | 807 |
def test_reminders_should_sort_issues_by_due_date |
| 812 | 808 |
user = User.find(2) |
| 813 |
user.pref.update_attribute :time_zone, 'UTC' |
|
| 814 | 809 |
Issue.generate!(:assigned_to => user, :due_date => 2.days.from_now, :subject => 'quux') |
| 815 | 810 |
Issue.generate!(:assigned_to => user, :due_date => 0.days.from_now, :subject => 'baz') |
| 816 | 811 |
Issue.generate!(:assigned_to => user, :due_date => 1.days.from_now, :subject => 'qux') |
| test/unit/query_test.rb | ||
|---|---|---|
| 523 | 523 |
assert !query.valid? |
| 524 | 524 |
end |
| 525 | 525 | |
| 526 |
def test_date_filter_should_not_accept_invalid_timestamp_values |
|
| 527 |
query = IssueQuery.new(:name => '_') |
|
| 528 |
query.add_filter('created_on', '=', ['2011-01-30T24:00:01'])
|
|
| 529 | ||
| 530 |
assert query.has_filter?('created_on')
|
|
| 531 |
assert !query.valid? |
|
| 532 |
end |
|
| 533 | ||
| 526 | 534 |
def test_relative_date_filter_should_not_accept_non_integer_values |
| 527 | 535 |
query = IssueQuery.new(:name => '_') |
| 528 | 536 |
query.add_filter('created_on', '>t-', ['a'])
|
| ... | ... | |
| 534 | 542 |
def test_operator_date_equals |
| 535 | 543 |
query = IssueQuery.new(:name => '_') |
| 536 | 544 |
query.add_filter('due_date', '=', ['2011-07-10'])
|
| 537 |
assert_match /issues\.due_date > '#{quoted_date "2011-07-09"} 23:59:59(\.\d+)?' AND issues\.due_date <= '#{quoted_date "2011-07-10"} 23:59:59(\.\d+)?/,
|
|
| 545 |
assert_match /issues\.due_date >= '#{quoted_date '2011-07-10'}' AND issues\.due_date <= '#{quoted_date '2011-07-10'}'/,
|
|
| 538 | 546 |
query.statement |
| 539 | 547 |
find_issues_with_query(query) |
| 548 | ||
| 549 |
query = IssueQuery.new(:name => '_') |
|
| 550 |
query.add_filter('updated_on', '=', ['2011-07-10'])
|
|
| 551 |
assert_match /issues\.updated_on > '#{quoted_date Time.zone.parse('2011-07-09').end_of_day}' AND issues\.updated_on <= '#{quoted_date Time.zone.parse('2011-07-10').end_of_day}'/,
|
|
| 552 |
query.statement |
|
| 553 |
find_issues_with_query(query) |
|
| 554 |
end |
|
| 555 | ||
| 556 |
def test_operator_date_equals_with_timestamp |
|
| 557 |
query = IssueQuery.new(:name => '_') |
|
| 558 |
query.add_filter('due_date', '=', ['2011-07-10T19:13:52'])
|
|
| 559 |
assert_match /issues\.due_date >= '#{quoted_date '2011-07-10T19:13:52'}' AND issues\.due_date <= '#{quoted_date '2011-07-10T19:13:52'}'/, query.statement
|
|
| 560 |
find_issues_with_query(query) |
|
| 561 | ||
| 562 |
query = IssueQuery.new(:name => '_') |
|
| 563 |
query.add_filter('updated_on', '=', ['2011-07-10T19:13:52'])
|
|
| 564 |
assert_match /issues\.updated_on > '#{quoted_date '2011-07-10T19:13:51'.to_time}' AND issues\.updated_on <= '#{quoted_date '2011-07-10T19:13:52'.to_time}'/, query.statement
|
|
| 565 |
find_issues_with_query(query) |
|
| 540 | 566 |
end |
| 541 | 567 | |
| 542 | 568 |
def test_operator_date_lesser_than |
| 543 | 569 |
query = IssueQuery.new(:name => '_') |
| 544 | 570 |
query.add_filter('due_date', '<=', ['2011-07-10'])
|
| 545 |
assert_match /issues\.due_date <= '#{quoted_date "2011-07-10"} 23:59:59(\.\d+)?/, query.statement
|
|
| 571 |
assert_match /issues\.due_date <= '#{quoted_date '2011-07-10'}'/, query.statement
|
|
| 572 |
find_issues_with_query(query) |
|
| 573 | ||
| 574 |
query = IssueQuery.new(:name => '_') |
|
| 575 |
query.add_filter('updated_on', '<=', ['2011-07-10'])
|
|
| 576 |
assert_match /issues\.updated_on <= '#{quoted_date Time.zone.parse('2011-07-10').end_of_day}'/, query.statement
|
|
| 546 | 577 |
find_issues_with_query(query) |
| 547 | 578 |
end |
| 548 | 579 | |
| 549 | 580 |
def test_operator_date_lesser_than_with_timestamp |
| 581 |
query = IssueQuery.new(:name => '_') |
|
| 582 |
query.add_filter('due_date', '<=', ['2011-07-10T19:13:52'])
|
|
| 583 |
assert_match /issues\.due_date <= '#{quoted_date '2011-07-10T19:13:52'}/, query.statement
|
|
| 584 |
find_issues_with_query(query) |
|
| 585 | ||
| 550 | 586 |
query = IssueQuery.new(:name => '_') |
| 551 | 587 |
query.add_filter('updated_on', '<=', ['2011-07-10T19:13:52'])
|
| 552 |
assert_match /issues\.updated_on <= '#{quoted_date "2011-07-10"} 19:13:52/, query.statement
|
|
| 588 |
assert_match /issues\.updated_on <= '#{quoted_date '2011-07-10T19:13:52'.to_time}/, query.statement
|
|
| 553 | 589 |
find_issues_with_query(query) |
| 554 | 590 |
end |
| 555 | 591 | |
| 556 | 592 |
def test_operator_date_greater_than |
| 557 | 593 |
query = IssueQuery.new(:name => '_') |
| 558 | 594 |
query.add_filter('due_date', '>=', ['2011-07-10'])
|
| 559 |
assert_match /issues\.due_date > '#{quoted_date "2011-07-09"} 23:59:59(\.\d+)?'/, query.statement
|
|
| 595 |
assert_match /issues\.due_date >= '#{quoted_date '2011-07-10'}'/, query.statement
|
|
| 596 |
find_issues_with_query(query) |
|
| 597 | ||
| 598 |
query = IssueQuery.new(:name => '_') |
|
| 599 |
query.add_filter('updated_on', '>=', ['2011-07-10'])
|
|
| 600 |
assert_match /issues\.updated_on > '#{quoted_date Time.zone.parse('2011-07-09').end_of_day}'/, query.statement
|
|
| 560 | 601 |
find_issues_with_query(query) |
| 561 | 602 |
end |
| 562 | 603 | |
| 563 | 604 |
def test_operator_date_greater_than_with_timestamp |
| 605 |
query = IssueQuery.new(:name => '_') |
|
| 606 |
query.add_filter('due_date', '>=', ['2011-07-10T19:13:52'])
|
|
| 607 |
assert_match /issues\.due_date >= '#{quoted_date '2011-07-10T19:13:52'}'/, query.statement
|
|
| 608 |
find_issues_with_query(query) |
|
| 609 | ||
| 564 | 610 |
query = IssueQuery.new(:name => '_') |
| 565 | 611 |
query.add_filter('updated_on', '>=', ['2011-07-10T19:13:52'])
|
| 566 |
assert_match /issues\.updated_on > '#{quoted_date "2011-07-10"} 19:13:51(\.0+)?'/, query.statement
|
|
| 612 |
assert_match /issues\.updated_on > '#{quoted_date '2011-07-10T19:13:51'.to_time}'/, query.statement
|
|
| 567 | 613 |
find_issues_with_query(query) |
| 568 | 614 |
end |
| 569 | 615 | |
| 570 | 616 |
def test_operator_date_between |
| 571 | 617 |
query = IssueQuery.new(:name => '_') |
| 572 | 618 |
query.add_filter('due_date', '><', ['2011-06-23', '2011-07-10'])
|
| 573 |
assert_match /issues\.due_date > '#{quoted_date "2011-06-22"} 23:59:59(\.\d+)?' AND issues\.due_date <= '#{quoted_date "2011-07-10"} 23:59:59(\.\d+)?'/,
|
|
| 619 |
assert_match /issues\.due_date >= '#{quoted_date '2011-06-23'}' AND issues\.due_date <= '#{quoted_date '2011-07-10'}'/,
|
|
| 620 |
query.statement |
|
| 621 |
find_issues_with_query(query) |
|
| 622 | ||
| 623 |
query = IssueQuery.new(:name => '_') |
|
| 624 |
query.add_filter('updated_on', '><', ['2011-06-23', '2011-07-10'])
|
|
| 625 |
assert_match /issues\.updated_on > '#{quoted_date Time.zone.parse('2011-06-22').end_of_day}' AND issues\.updated_on <= '#{quoted_date Time.zone.parse('2011-07-10').end_of_day}'/,
|
|
| 626 |
query.statement |
|
| 627 |
find_issues_with_query(query) |
|
| 628 |
end |
|
| 629 | ||
| 630 |
def test_operator_date_between_with_timestamp |
|
| 631 |
query = IssueQuery.new(:name => '_') |
|
| 632 |
query.add_filter('due_date', '><', ['2011-06-23T19:13:52', '2011-07-10T19:13:52'])
|
|
| 633 |
assert_match /issues\.due_date >= '#{quoted_date '2011-06-23T19:13:52'}' AND issues\.due_date <= '#{quoted_date '2011-07-10T19:13:52'}'/,
|
|
| 634 |
query.statement |
|
| 635 |
find_issues_with_query(query) |
|
| 636 | ||
| 637 |
query = IssueQuery.new(:name => '_') |
|
| 638 |
query.add_filter('updated_on', '><', ['2011-06-23T19:13:52', '2011-07-10T19:13:52'])
|
|
| 639 |
assert_match /issues\.updated_on > '#{quoted_date '2011-06-23T19:13:51'.to_time}' AND issues\.updated_on <= '#{quoted_date '2011-07-10T19:13:52'.to_time}'/,
|
|
| 574 | 640 |
query.statement |
| 575 | 641 |
find_issues_with_query(query) |
| 576 | 642 |
end |
| 577 | 643 | |
| 578 | 644 |
def test_operator_in_more_than |
| 579 |
Issue.find(7).update_attribute(:due_date, (Date.today + 15))
|
|
| 645 |
Issue.find(7).update_attribute(:due_date, (Date.current + 15))
|
|
| 580 | 646 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
| 581 | 647 |
query.add_filter('due_date', '>t+', ['15'])
|
| 582 | 648 |
issues = find_issues_with_query(query) |
| 583 | 649 |
assert !issues.empty? |
| 584 |
issues.each {|issue| assert(issue.due_date >= (Date.today + 15))}
|
|
| 650 |
issues.each {|issue| assert(issue.due_date >= (Date.current + 15))}
|
|
| 585 | 651 |
end |
| 586 | 652 | |
| 587 | 653 |
def test_operator_in_less_than |
| ... | ... | |
| 589 | 655 |
query.add_filter('due_date', '<t+', ['15'])
|
| 590 | 656 |
issues = find_issues_with_query(query) |
| 591 | 657 |
assert !issues.empty? |
| 592 |
issues.each {|issue| assert(issue.due_date <= (Date.today + 15))}
|
|
| 658 |
issues.each {|issue| assert(issue.due_date <= (Date.current + 15))}
|
|
| 593 | 659 |
end |
| 594 | 660 | |
| 595 | 661 |
def test_operator_in_the_next_days |
| ... | ... | |
| 597 | 663 |
query.add_filter('due_date', '><t+', ['15'])
|
| 598 | 664 |
issues = find_issues_with_query(query) |
| 599 | 665 |
assert !issues.empty? |
| 600 |
issues.each {|issue| assert(issue.due_date >= Date.today && issue.due_date <= (Date.today + 15))}
|
|
| 666 |
issues.each {|issue| assert(issue.due_date >= Date.current && issue.due_date <= (Date.current + 15))}
|
|
| 601 | 667 |
end |
| 602 | 668 | |
| 603 | 669 |
def test_operator_less_than_ago |
| 604 |
Issue.find(7).update_attribute(:due_date, (Date.today - 3))
|
|
| 670 |
Issue.find(7).update_attribute(:due_date, (Date.current - 3))
|
|
| 605 | 671 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
| 606 | 672 |
query.add_filter('due_date', '>t-', ['3'])
|
| 607 | 673 |
issues = find_issues_with_query(query) |
| 608 | 674 |
assert !issues.empty? |
| 609 |
issues.each {|issue| assert(issue.due_date >= (Date.today - 3))}
|
|
| 675 |
issues.each {|issue| assert(issue.due_date >= (Date.current - 3))}
|
|
| 610 | 676 |
end |
| 611 | 677 | |
| 612 | 678 |
def test_operator_in_the_past_days |
| 613 |
Issue.find(7).update_attribute(:due_date, (Date.today - 3))
|
|
| 679 |
Issue.find(7).update_attribute(:due_date, (Date.current - 3))
|
|
| 614 | 680 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
| 615 | 681 |
query.add_filter('due_date', '><t-', ['3'])
|
| 616 | 682 |
issues = find_issues_with_query(query) |
| 617 | 683 |
assert !issues.empty? |
| 618 |
issues.each {|issue| assert(issue.due_date >= (Date.today - 3) && issue.due_date <= Date.today)}
|
|
| 684 |
issues.each {|issue| assert(issue.due_date >= (Date.current - 3) && issue.due_date <= Date.current)}
|
|
| 619 | 685 |
end |
| 620 | 686 | |
| 621 | 687 |
def test_operator_more_than_ago |
| 622 |
Issue.find(7).update_attribute(:due_date, (Date.today - 10))
|
|
| 688 |
Issue.find(7).update_attribute(:due_date, (Date.current - 10))
|
|
| 623 | 689 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
| 624 | 690 |
query.add_filter('due_date', '<t-', ['10'])
|
| 625 | 691 |
assert query.statement.include?("#{Issue.table_name}.due_date <=")
|
| 626 | 692 |
issues = find_issues_with_query(query) |
| 627 | 693 |
assert !issues.empty? |
| 628 |
issues.each {|issue| assert(issue.due_date <= (Date.today - 10))}
|
|
| 694 |
issues.each {|issue| assert(issue.due_date <= (Date.current - 10))}
|
|
| 629 | 695 |
end |
| 630 | 696 | |
| 631 | 697 |
def test_operator_in |
| 632 |
Issue.find(7).update_attribute(:due_date, (Date.today + 2))
|
|
| 698 |
Issue.find(7).update_attribute(:due_date, (Date.current + 2))
|
|
| 633 | 699 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
| 634 | 700 |
query.add_filter('due_date', 't+', ['2'])
|
| 635 | 701 |
issues = find_issues_with_query(query) |
| 636 | 702 |
assert !issues.empty? |
| 637 |
issues.each {|issue| assert_equal((Date.today + 2), issue.due_date)}
|
|
| 703 |
issues.each {|issue| assert_equal((Date.current + 2), issue.due_date)}
|
|
| 638 | 704 |
end |
| 639 | 705 | |
| 640 | 706 |
def test_operator_ago |
| 641 |
Issue.find(7).update_attribute(:due_date, (Date.today - 3))
|
|
| 707 |
Issue.find(7).update_attribute(:due_date, (Date.current - 3))
|
|
| 642 | 708 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
| 643 | 709 |
query.add_filter('due_date', 't-', ['3'])
|
| 644 | 710 |
issues = find_issues_with_query(query) |
| 645 | 711 |
assert !issues.empty? |
| 646 |
issues.each {|issue| assert_equal((Date.today - 3), issue.due_date)}
|
|
| 712 |
issues.each {|issue| assert_equal((Date.current - 3), issue.due_date)}
|
|
| 647 | 713 |
end |
| 648 | 714 | |
| 649 | 715 |
def test_operator_today |
| ... | ... | |
| 651 | 717 |
query.add_filter('due_date', 't', [''])
|
| 652 | 718 |
issues = find_issues_with_query(query) |
| 653 | 719 |
assert !issues.empty? |
| 654 |
issues.each {|issue| assert_equal Date.today, issue.due_date}
|
|
| 720 |
issues.each {|issue| assert_equal Date.current, issue.due_date}
|
|
| 655 | 721 |
end |
| 656 | 722 | |
| 657 | 723 |
def test_operator_tomorrow |
| ... | ... | |
| 714 | 780 |
end |
| 715 | 781 | |
| 716 | 782 |
def test_range_for_this_week_with_week_starting_on_monday |
| 717 |
I18n.locale = :fr
|
|
| 718 |
assert_equal '1', I18n.t(:general_first_day_of_week) |
|
| 719 | ||
| 720 |
Date.stubs(:today).returns(Date.parse('2011-04-29'))
|
|
| 721 | ||
| 722 |
query = IssueQuery.new(:project => Project.find(1), :name => '_')
|
|
| 723 |
query.add_filter('due_date', 'w', [''])
|
|
| 724 |
assert_match /issues\.due_date > '#{quoted_date "2011-04-24"} 23:59:59(\.\d+)?' AND issues\.due_date <= '#{quoted_date "2011-05-01"} 23:59:59(\.\d+)?/,
|
|
| 725 |
query.statement
|
|
| 726 |
I18n.locale = :en
|
|
| 783 |
with_locale :fr do
|
|
| 784 |
assert_equal '1', I18n.t(:general_first_day_of_week)
|
|
| 785 | ||
| 786 |
travel_to Date.parse('2011-04-29') do
|
|
| 787 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
|
| 788 |
query.add_filter('due_date', 'w', [''])
|
|
| 789 |
assert_match /issues\.due_date >= '#{quoted_date '2011-04-25'}' AND issues\.due_date <= '#{quoted_date '2011-05-01'}'/,
|
|
| 790 |
query.statement
|
|
| 791 |
end
|
|
| 792 |
end
|
|
| 727 | 793 |
end |
| 728 | 794 | |
| 729 | 795 |
def test_range_for_this_week_with_week_starting_on_sunday |
| 730 |
I18n.locale = :en |
|
| 731 |
assert_equal '7', I18n.t(:general_first_day_of_week) |
|
| 732 | ||
| 733 |
Date.stubs(:today).returns(Date.parse('2011-04-29'))
|
|
| 734 | ||
| 735 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
|
| 736 |
query.add_filter('due_date', 'w', [''])
|
|
| 737 |
assert_match /issues\.due_date > '#{quoted_date "2011-04-23"} 23:59:59(\.\d+)?' AND issues\.due_date <= '#{quoted_date "2011-04-30"} 23:59:59(\.\d+)?/,
|
|
| 738 |
query.statement |
|
| 796 |
with_locale :en do |
|
| 797 |
assert_equal '7', I18n.t(:general_first_day_of_week) |
|
| 798 | ||
| 799 |
travel_to Date.parse('2011-04-29') do
|
|
| 800 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
|
| 801 |
query.add_filter('due_date', 'w', [''])
|
|
| 802 |
assert_match /issues\.due_date >= '#{quoted_date '2011-04-24'}' AND issues\.due_date <= '#{quoted_date '2011-04-30'}'/,
|
|
| 803 |
query.statement |
|
| 804 |
end |
|
| 805 |
end |
|
| 739 | 806 |
end |
| 740 | 807 | |
| 741 | 808 |
def test_range_for_next_week_with_week_starting_on_monday |
| 742 |
I18n.locale = :fr
|
|
| 743 |
assert_equal '1', I18n.t(:general_first_day_of_week) |
|
| 744 | ||
| 745 |
Date.stubs(:today).returns(Date.parse('2011-04-29')) # Friday
|
|
| 746 | ||
| 747 |
query = IssueQuery.new(:project => Project.find(1), :name => '_')
|
|
| 748 |
query.add_filter('due_date', 'nw', [''])
|
|
| 749 |
assert_match /issues\.due_date > '#{quoted_date "2011-05-01"} 23:59:59(\.\d+)?' AND issues\.due_date <= '#{quoted_date "2011-05-08"} 23:59:59(\.\d+)?/,
|
|
| 750 |
query.statement
|
|
| 751 |
I18n.locale = :en
|
|
| 809 |
with_locale :fr do
|
|
| 810 |
assert_equal '1', I18n.t(:general_first_day_of_week)
|
|
| 811 | ||
| 812 |
travel_to Date.parse('2011-04-29') do
|
|
| 813 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
|
| 814 |
query.add_filter('due_date', 'nw', [''])
|
|
| 815 |
assert_match /issues\.due_date >= '#{quoted_date '2011-05-02'}' AND issues\.due_date <= '#{quoted_date '2011-05-08'}'/,
|
|
| 816 |
query.statement
|
|
| 817 |
end
|
|
| 818 |
end
|
|
| 752 | 819 |
end |
| 753 | 820 | |
| 754 | 821 |
def test_range_for_next_week_with_week_starting_on_sunday |
| 755 |
I18n.locale = :en |
|
| 756 |
assert_equal '7', I18n.t(:general_first_day_of_week) |
|
| 757 | ||
| 758 |
Date.stubs(:today).returns(Date.parse('2011-04-29')) # Friday
|
|
| 759 | ||
| 760 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
|
| 761 |
query.add_filter('due_date', 'nw', [''])
|
|
| 762 |
assert_match /issues\.due_date > '#{quoted_date "2011-04-30"} 23:59:59(\.\d+)?' AND issues\.due_date <= '#{quoted_date "2011-05-07"} 23:59:59(\.\d+)?/,
|
|
| 763 |
query.statement |
|
| 822 |
with_locale :en do |
|
| 823 |
assert_equal '7', I18n.t(:general_first_day_of_week) |
|
| 824 | ||
| 825 |
travel_to Date.parse('2011-04-29') do
|
|
| 826 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
|
| 827 |
query.add_filter('due_date', 'nw', [''])
|
|
| 828 |
assert_match /issues\.due_date >= '#{quoted_date '2011-05-01'}' AND issues\.due_date <= '#{quoted_date '2011-05-07'}'/,
|
|
| 829 |
query.statement |
|
| 830 |
end |
|
| 831 |
end |
|
| 764 | 832 |
end |
| 765 | 833 | |
| 766 | 834 |
def test_range_for_next_month |
| 767 |
Date.stubs(:today).returns(Date.parse('2011-04-29')) # Friday
|
|
| 768 | ||
| 769 |
query = IssueQuery.new(:project => Project.find(1), :name => '_')
|
|
| 770 |
query.add_filter('due_date', 'nm', [''])
|
|
| 771 |
assert_match /issues\.due_date > '#{quoted_date "2011-04-30"} 23:59:59(\.\d+)?' AND issues\.due_date <= '#{quoted_date "2011-05-31"} 23:59:59(\.\d+)?/,
|
|
| 772 |
query.statement
|
|
| 835 |
travel_to Date.parse('2011-04-29') do
|
|
| 836 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
|
| 837 |
query.add_filter('due_date', 'nm', [''])
|
|
| 838 |
assert_match /issues\.due_date >= '#{quoted_date '2011-05-01'}' AND issues\.due_date <= '#{quoted_date '2011-05-31'}'/,
|
|
| 839 |
query.statement
|
|
| 840 |
end
|
|
| 773 | 841 |
end |
| 774 | 842 | |
| 775 | 843 |
def test_filter_assigned_to_me |
| test/unit/user_test.rb | ||
|---|---|---|
| 578 | 578 | |
| 579 | 579 |
def test_today_should_return_the_day_according_to_user_time_zone |
| 580 | 580 |
preference = User.find(1).pref |
| 581 |
date = Date.new(2012, 05, 15) |
|
| 582 |
time = Time.gm(2012, 05, 15, 23, 30).utc # 2012-05-15 23:30 UTC |
|
| 583 |
Date.stubs(:today).returns(date) |
|
| 584 |
Time.stubs(:now).returns(time) |
|
| 585 | ||
| 586 |
preference.update_attribute :time_zone, 'Baku' # UTC+4 |
|
| 587 |
assert_equal '2012-05-16', User.find(1).today.to_s |
|
| 581 |
travel_to Time.gm(2012, 05, 15, 23, 30).utc do |
|
| 582 |
preference.update_attribute :time_zone, 'Baku' # UTC+4 |
|
| 583 |
assert_equal '2012-05-16', User.find(1).today.to_s |
|
| 588 | 584 | |
| 589 |
preference.update_attribute :time_zone, 'La Paz' # UTC-4 |
|
| 590 |
assert_equal '2012-05-15', User.find(1).today.to_s |
|
| 585 |
preference.update_attribute :time_zone, 'La Paz' # UTC-4
|
|
| 586 |
assert_equal '2012-05-15', User.find(1).today.to_s
|
|
| 591 | 587 | |
| 592 |
preference.update_attribute :time_zone, '' |
|
| 593 |
assert_equal '2012-05-15', User.find(1).today.to_s |
|
| 588 |
preference.update_attribute :time_zone, '' |
|
| 589 |
assert_equal Date.current.to_s, User.find(1).today.to_s |
|
| 590 |
end |
|
| 594 | 591 |
end |
| 595 | 592 | |
| 596 | 593 |
def test_time_to_date_should_return_the_date_according_to_user_time_zone |
| ... | ... | |
| 604 | 601 |
assert_equal '2012-05-15', User.find(1).time_to_date(time).to_s |
| 605 | 602 | |
| 606 | 603 |
preference.update_attribute :time_zone, '' |
| 607 |
assert_equal time.localtime.to_date.to_s, User.find(1).time_to_date(time).to_s |
|
| 604 |
user = User.find(1) |
|
| 605 |
assert_equal time.in_time_zone(user.time_zone).to_date.to_s, user.time_to_date(time).to_s |
|
| 608 | 606 |
end |
| 609 | 607 | |
| 610 | 608 |
def test_convert_time_to_user_timezone_should_return_the_time_according_to_user_time_zone |
| ... | ... | |
| 619 | 617 |
assert_equal '2012-05-15 19:30:00 -0400', User.find(1).convert_time_to_user_timezone(time).to_s |
| 620 | 618 | |
| 621 | 619 |
preference.update_attribute :time_zone, '' |
| 622 |
assert_equal time.localtime.to_s, User.find(1).convert_time_to_user_timezone(time).to_s |
|
| 623 |
assert_equal time_not_utc, User.find(1).convert_time_to_user_timezone(time_not_utc) |
|
| 620 |
user = User.find(1) |
|
| 621 |
assert_equal time.in_time_zone(user.time_zone).to_s, user.convert_time_to_user_timezone(time).to_s |
|
| 622 |
assert_equal time_not_utc, user.convert_time_to_user_timezone(time_not_utc) |
|
| 624 | 623 |
end |
| 625 | 624 | |
| 626 | 625 |
def test_fields_for_order_statement_should_return_fields_according_user_format_setting |
| test/unit/version_test.rb | ||
|---|---|---|
| 158 | 158 |
end |
| 159 | 159 | |
| 160 | 160 |
def test_completed_should_be_false_when_due_today |
| 161 |
version = Version.create!(:project_id => 1, :effective_date => Date.today, :name => 'Due today')
|
|
| 161 |
version = Version.create!(:project_id => 1, :effective_date => Date.current, :name => 'Due today')
|
|
| 162 | 162 |
assert_equal false, version.completed? |
| 163 | 163 |
end |
| 164 | 164 | |