aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/type/immutable_string_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/test/cases/type/immutable_string_test.rb')
-rw-r--r--activemodel/test/cases/type/immutable_string_test.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/activemodel/test/cases/type/immutable_string_test.rb b/activemodel/test/cases/type/immutable_string_test.rb
new file mode 100644
index 0000000000..751f753ddb
--- /dev/null
+++ b/activemodel/test/cases/type/immutable_string_test.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+require "cases/helper"
+
+module ActiveModel
+ module Type
+ class ImmutableStringTest < ActiveModel::TestCase
+ test "cast strings are frozen" do
+ s = "foo"
+ type = Type::ImmutableString.new
+ assert_equal true, type.cast(s).frozen?
+ end
+
+ test "immutable strings are not duped coming out" do
+ s = "foo"
+ type = Type::ImmutableString.new
+ assert_same s, type.cast(s)
+ assert_same s, type.deserialize(s)
+ end
+ end
+ end
+end