aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/attributes_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/test/cases/attributes_test.rb')
-rw-r--r--activemodel/test/cases/attributes_test.rb28
1 files changed, 1 insertions, 27 deletions
diff --git a/activemodel/test/cases/attributes_test.rb b/activemodel/test/cases/attributes_test.rb
index 064cba40e3..914aee1ac0 100644
--- a/activemodel/test/cases/attributes_test.rb
+++ b/activemodel/test/cases/attributes_test.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require "cases/helper"
-require "active_model/attributes"
module ActiveModel
class AttributesTest < ActiveModel::TestCase
@@ -13,7 +12,7 @@ module ActiveModel
attribute :string_field, :string
attribute :decimal_field, :decimal
attribute :string_with_default, :string, default: "default string"
- attribute :date_field, :string, default: -> { Date.new(2016, 1, 1) }
+ attribute :date_field, :date, default: -> { Date.new(2016, 1, 1) }
attribute :boolean_field, :boolean
end
@@ -48,31 +47,6 @@ module ActiveModel
assert_equal true, data.boolean_field
end
- test "dirty" do
- data = ModelForAttributesTest.new(
- integer_field: "2.3",
- string_field: "Rails FTW",
- decimal_field: "12.3",
- boolean_field: "0"
- )
-
- assert_equal false, data.changed?
-
- data.integer_field = "2.1"
-
- assert_equal false, data.changed?
-
- data.string_with_default = "default string"
-
- assert_equal false, data.changed?
-
- data.integer_field = "5.1"
-
- assert_equal true, data.changed?
- assert_equal true, data.integer_field_changed?
- assert_equal({ "integer_field" => [2, 5] }, data.changes)
- end
-
test "nonexistent attribute" do
assert_raise ActiveModel::UnknownAttributeError do
ModelForAttributesTest.new(nonexistent: "nonexistent")