aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/types_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/types_test.rb')
-rw-r--r--activerecord/test/cases/types_test.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/activerecord/test/cases/types_test.rb b/activerecord/test/cases/types_test.rb
new file mode 100644
index 0000000000..3f7fb0a604
--- /dev/null
+++ b/activerecord/test/cases/types_test.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+require "cases/helper"
+
+module ActiveRecord
+ module ConnectionAdapters
+ class TypesTest < ActiveRecord::TestCase
+ def test_attributes_which_are_invalid_for_database_can_still_be_reassigned
+ type_which_cannot_go_to_the_database = Type::Value.new
+ def type_which_cannot_go_to_the_database.serialize(*)
+ raise
+ end
+ klass = Class.new(ActiveRecord::Base) do
+ self.table_name = "posts"
+ attribute :foo, type_which_cannot_go_to_the_database
+ end
+ model = klass.new
+
+ model.foo = "foo"
+ model.foo = "bar"
+
+ assert_equal "bar", model.foo
+ end
+ end
+ end
+end