blob: 22e8873333377c5b25a61b041745fdc629954811 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
require "cases/helper"
class PostgresqlInfinityTest < ActiveRecord::TestCase
class PostgresqlInfinity < ActiveRecord::Base
end
setup do
@connection = ActiveRecord::Base.connection
@connection.create_table(:postgresql_infinities) do |t|
t.float :float
t.datetime :datetime
end
end
teardown do
@connection.execute("DROP TABLE IF EXISTS postgresql_infinities")
end
test "type casting infinity on a float column" do
record = PostgresqlInfinity.create!(float: Float::INFINITY)
record.reload
assert_equal Float::INFINITY, record.float
end
test "update_all with infinity on a float column" do
record = PostgresqlInfinity.create!
PostgresqlInfinity.update_all(float: Float::INFINITY)
record.reload
assert_equal Float::INFINITY, record.float
end
test "type casting infinity on a datetime column" do
record = PostgresqlInfinity.create!(datetime: Float::INFINITY)
record.reload
assert_equal Float::INFINITY, record.datetime
end
test "update_all with infinity on a datetime column" do
record = PostgresqlInfinity.create!
PostgresqlInfinity.update_all(datetime: Float::INFINITY)
record.reload
assert_equal Float::INFINITY, record.datetime
end
end
|