提交 4ff30d9b 编写于 作者: P Pat Allan

Make ActiveModel frozen string literal friendly.

Includes two external changes because they're referenced within the ActiveModel test suite.
上级 036bdee4
......@@ -29,7 +29,7 @@ class UriEncoder # :nodoc:
ENCODE = "%%%02X".freeze
US_ASCII = Encoding::US_ASCII
UTF_8 = Encoding::UTF_8
EMPTY = "".force_encoding(US_ASCII).freeze
EMPTY = "".dup.force_encoding(US_ASCII).freeze
DEC2HEX = (0..255).to_a.map { |i| ENCODE % i }.map { |s| s.force_encoding(US_ASCII) }
ALPHA = "a-zA-Z".freeze
......
......@@ -13,8 +13,8 @@ module JavaScriptHelper
"'" => "\\'"
}
JS_ESCAPE_MAP["\342\200\250".force_encoding(Encoding::UTF_8).encode!] = "
"
JS_ESCAPE_MAP["\342\200\251".force_encoding(Encoding::UTF_8).encode!] = "
"
JS_ESCAPE_MAP["\342\200\250".dup.force_encoding(Encoding::UTF_8).encode!] = "
"
JS_ESCAPE_MAP["\342\200\251".dup.force_encoding(Encoding::UTF_8).encode!] = "
"
# Escapes carriage returns and single and double quotes for JavaScript segments.
#
......
......@@ -96,7 +96,7 @@ def reload
end
test "attribute mutation" do
@model.instance_variable_set("@name", "Yam")
@model.instance_variable_set("@name", "Yam".dup)
assert !@model.name_changed?
@model.name.replace("Hadad")
assert !@model.name_changed?
......
......@@ -14,7 +14,7 @@ class StringTest < ActiveModel::TestCase
test "cast strings are mutable" do
type = Type::String.new
s = "foo"
s = "foo".dup
assert_equal false, type.cast(s).frozen?
assert_equal false, s.frozen?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册