aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/attributes_test.rb
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2019-03-20 12:20:51 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2019-03-20 15:05:31 -0400
commit15b11ce505b9e94031c640d8488d6237f860d08b (patch)
tree9c6c79654c24b00b783d292c89214c7858dbf675 /activerecord/test/cases/attributes_test.rb
parentc11d115fa3c58ec6bde5e9799673cee381d22d47 (diff)
downloadrails-15b11ce505b9e94031c640d8488d6237f860d08b.tar.gz
rails-15b11ce505b9e94031c640d8488d6237f860d08b.tar.bz2
rails-15b11ce505b9e94031c640d8488d6237f860d08b.zip
Document option forwarding in ActiveRecord::Base.attribute
This has been supported for a while but we didn't have documentation for it.
Diffstat (limited to 'activerecord/test/cases/attributes_test.rb')
-rw-r--r--activerecord/test/cases/attributes_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/attributes_test.rb b/activerecord/test/cases/attributes_test.rb
index 2632aec7ab..a6fb9f0af7 100644
--- a/activerecord/test/cases/attributes_test.rb
+++ b/activerecord/test/cases/attributes_test.rb
@@ -56,6 +56,17 @@ module ActiveRecord
assert_equal 255, UnoverloadedType.type_for_attribute("overloaded_string_with_limit").limit
end
+ test "extra options are forwarded to the type caster constructor" do
+ klass = Class.new(OverloadedType) do
+ attribute :starts_at, :datetime, precision: 3, limit: 2, scale: 1
+ end
+
+ starts_at_type = klass.type_for_attribute(:starts_at)
+ assert_equal 3, starts_at_type.precision
+ assert_equal 2, starts_at_type.limit
+ assert_equal 1, starts_at_type.scale
+ end
+
test "nonexistent attribute" do
data = OverloadedType.new(non_existent_decimal: 1)