aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/type/integer_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/test/cases/type/integer_test.rb')
-rw-r--r--activemodel/test/cases/type/integer_test.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/activemodel/test/cases/type/integer_test.rb b/activemodel/test/cases/type/integer_test.rb
index e00246b602..2b9b03f3cf 100644
--- a/activemodel/test/cases/type/integer_test.rb
+++ b/activemodel/test/cases/type/integer_test.rb
@@ -1,5 +1,6 @@
require "cases/helper"
require "active_model/type"
+require "active_support/core_ext/numeric/time"
module ActiveModel
module Type
@@ -19,7 +20,7 @@ module ActiveModel
test "random objects cast to nil" do
type = Type::Integer.new
- assert_nil type.cast([1,2])
+ assert_nil type.cast([1, 2])
assert_nil type.cast(1 => 2)
assert_nil type.cast(1..2)
end
@@ -32,7 +33,7 @@ module ActiveModel
test "casting nan and infinity" do
type = Type::Integer.new
assert_nil type.cast(::Float::NAN)
- assert_nil type.cast(1.0/0.0)
+ assert_nil type.cast(1.0 / 0.0)
end
test "casting booleans for database" do
@@ -41,6 +42,12 @@ module ActiveModel
assert_equal 0, type.serialize(false)
end
+ test "casting duration" do
+ type = Type::Integer.new
+ assert_equal 1800, type.cast(30.minutes)
+ assert_equal 7200, type.cast(2.hours)
+ end
+
test "changed?" do
type = Type::Integer.new