From 8de7df5b22e853f028e5a71b26d45a0ce7a2c0f4 Mon Sep 17 00:00:00 2001
From: Matthew Draper <matthew@trebex.net>
Date: Wed, 12 Apr 2017 03:14:09 +0930
Subject: Don't freeze input strings

See 34321e4a433bb7eef48fd743286601403f8f7d82 for background on
ImmutableString vs String.

Our String type cannot delegate typecasting to ImmutableString, because
the latter freezes its input: duplicating the value after that gives us
an unfrozen result, but still mutates the originally passed object.
---
 activemodel/test/cases/type/string_test.rb | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

(limited to 'activemodel/test')

diff --git a/activemodel/test/cases/type/string_test.rb b/activemodel/test/cases/type/string_test.rb
index 222083817e..47d412e27e 100644
--- a/activemodel/test/cases/type/string_test.rb
+++ b/activemodel/test/cases/type/string_test.rb
@@ -12,16 +12,25 @@ module ActiveModel
       end
 
       test "cast strings are mutable" do
-        s = "foo"
         type = Type::String.new
+
+        s = "foo"
         assert_equal false, type.cast(s).frozen?
+        assert_equal false, s.frozen?
+
+        f = "foo".freeze
+        assert_equal false, type.cast(f).frozen?
+        assert_equal true, f.frozen?
       end
 
       test "values are duped coming out" do
-        s = "foo"
         type = Type::String.new
+
+        s = "foo"
         assert_not_same s, type.cast(s)
+        assert_equal s, type.cast(s)
         assert_not_same s, type.deserialize(s)
+        assert_equal s, type.deserialize(s)
       end
     end
   end
-- 
cgit v1.2.3


From faca40dfd4032bbe2373210255eb7aa1c6527503 Mon Sep 17 00:00:00 2001
From: Ryuta Kamizono <kamipo@gmail.com>
Date: Thu, 13 Apr 2017 07:15:04 +0900
Subject: :scissors:

[ci skip]
---
 activemodel/test/validators/email_validator.rb | 1 -
 1 file changed, 1 deletion(-)

(limited to 'activemodel/test')

diff --git a/activemodel/test/validators/email_validator.rb b/activemodel/test/validators/email_validator.rb
index 9b74d83b37..f733c45cf0 100644
--- a/activemodel/test/validators/email_validator.rb
+++ b/activemodel/test/validators/email_validator.rb
@@ -1,4 +1,3 @@
-
 class EmailValidator < ActiveModel::EachValidator
   def validate_each(record, attribute, value)
     record.errors[attribute] << (options[:message] || "is not an email") unless
-- 
cgit v1.2.3