diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-02-06 20:01:00 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-02-06 23:15:22 +0900 |
commit | 71366209d56a62c90ef39fb00470305f7caa5a0f (patch) | |
tree | 7660302ebcfc264be05319f38de4acc8c6a32064 /activerecord | |
parent | b9a95456a5f73dd113c6656cdc447f0b3db4c737 (diff) | |
download | rails-71366209d56a62c90ef39fb00470305f7caa5a0f.tar.gz rails-71366209d56a62c90ef39fb00470305f7caa5a0f.tar.bz2 rails-71366209d56a62c90ef39fb00470305f7caa5a0f.zip |
Fix `assert_in_delta` test failure
`assert_in_delta` in `timestamp_test.rb` causes an intermittent test
failure. It looks like that caused by subseconds truncation in MySQL 5.5.
Example:
```
1) Failure:
TimestampTest#test_touching_many_attributes_updates_them [/home/travis/build/rails/rails/activerecord/test/cases/timestamp_test.rb:125]:
Expected |2016-02-06 09:22:10 +0000 - 2016-02-06 09:22:09 UTC| (1.000837185) to be <= 1.
```
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/timestamp_test.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb index 970f6bcf4a..937b84bccc 100644 --- a/activerecord/test/cases/timestamp_test.rb +++ b/activerecord/test/cases/timestamp_test.rb @@ -98,8 +98,11 @@ class TimestampTest < ActiveRecord::TestCase task = Task.first previous_value = task.ending task.touch(:ending) + + now = Time.now.change(usec: 0) + assert_not_equal previous_value, task.ending - assert_in_delta Time.now, task.ending, 1 + assert_in_delta now, task.ending, 1 end def test_touching_an_attribute_updates_timestamp_with_given_time @@ -120,10 +123,12 @@ class TimestampTest < ActiveRecord::TestCase previous_ending = task.ending task.touch(:starting, :ending) + now = Time.now.change(usec: 0) + assert_not_equal previous_starting, task.starting assert_not_equal previous_ending, task.ending - assert_in_delta Time.now, task.starting, 1 - assert_in_delta Time.now, task.ending, 1 + assert_in_delta now, task.starting, 1 + assert_in_delta now, task.ending, 1 end def test_touching_a_record_without_timestamps_is_unexceptional |