|
Revision 8326, 0.9 kB
(checked in by gbuesing, 1 year ago)
|
Anchor DateTimeTest to fixed DateTime instead of a variable value based on Time.now#advance#to_datetime. Works around issue on 64-bit platforms with Ruby's Time#to_datetime respecting fractional seconds, and database adapters not respecting them for DateTimes, throwing off before-and-after-save equality test. References #10080, #10073
|
| Line | |
|---|
| 1 |
require 'abstract_unit' |
|---|
| 2 |
require 'fixtures/topic' |
|---|
| 3 |
require 'fixtures/task' |
|---|
| 4 |
|
|---|
| 5 |
class DateTimeTest < Test::Unit::TestCase |
|---|
| 6 |
def test_saves_both_date_and_time |
|---|
| 7 |
time_values = [1807, 2, 10, 15, 30, 45] |
|---|
| 8 |
now = DateTime.civil(*time_values) |
|---|
| 9 |
|
|---|
| 10 |
task = Task.new |
|---|
| 11 |
task.starting = now |
|---|
| 12 |
task.save! |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
assert_equal Time.local_time(*time_values), Task.find(task.id).starting |
|---|
| 16 |
end |
|---|
| 17 |
|
|---|
| 18 |
def test_assign_empty_date_time |
|---|
| 19 |
task = Task.new |
|---|
| 20 |
task.starting = '' |
|---|
| 21 |
task.ending = nil |
|---|
| 22 |
assert_nil task.starting |
|---|
| 23 |
assert_nil task.ending |
|---|
| 24 |
end |
|---|
| 25 |
|
|---|
| 26 |
def test_assign_empty_date |
|---|
| 27 |
topic = Topic.new |
|---|
| 28 |
topic.last_read = '' |
|---|
| 29 |
assert_nil topic.last_read |
|---|
| 30 |
end |
|---|
| 31 |
|
|---|
| 32 |
def test_assign_empty_time |
|---|
| 33 |
topic = Topic.new |
|---|
| 34 |
topic.bonus_time = '' |
|---|
| 35 |
assert_nil topic.bonus_time |
|---|
| 36 |
end |
|---|
| 37 |
end |
|---|