1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Make ActionMailer frozen string literal friendly.

This commit is contained in:
Pat Allan 2017-06-20 19:45:46 +10:00
parent b86e313df5
commit dd491b24ff
5 changed files with 7 additions and 7 deletions

View file

@ -120,7 +120,7 @@ class BaseTest < ActiveSupport::TestCase
email = BaseMailer.attachment_with_hash
assert_equal(1, email.attachments.length)
assert_equal("invoice.jpg", email.attachments[0].filename)
expected = "\312\213\254\232)b"
expected = "\312\213\254\232)b".dup
expected.force_encoding(Encoding::BINARY)
assert_equal expected, email.attachments["invoice.jpg"].decoded
end
@ -129,7 +129,7 @@ class BaseTest < ActiveSupport::TestCase
email = BaseMailer.attachment_with_hash_default_encoding
assert_equal(1, email.attachments.length)
assert_equal("invoice.jpg", email.attachments[0].filename)
expected = "\312\213\254\232)b"
expected = "\312\213\254\232)b".dup
expected.force_encoding(Encoding::BINARY)
assert_equal expected, email.attachments["invoice.jpg"].decoded
end

View file

@ -103,7 +103,7 @@ module ActionDispatch # :nodoc:
def body
@str_body ||= begin
buf = ""
buf = "".dup
each { |chunk| buf << chunk }
buf
end

View file

@ -14,7 +14,7 @@ module ActionDispatch
# normalize_path("/%ab") # => "/%AB"
def self.normalize_path(path)
encoding = path.encoding
path = "/#{path}"
path = "/#{path}".dup
path.squeeze!("/".freeze)
path.sub!(%r{/+\Z}, "".freeze)
path.gsub!(/(%[a-f0-9]{2})/) { $1.upcase }

View file

@ -282,7 +282,7 @@ module ActionView
# Make sure that the resulting String to be eval'd is in the
# encoding of the code
source = <<-end_src
source = <<-end_src.dup
def #{method_name}(local_assigns, output_buffer)
_old_virtual_path, @virtual_path = @virtual_path, #{@virtual_path.inspect};_old_output_buffer = @output_buffer;#{locals_code};#{code}
ensure
@ -334,7 +334,7 @@ module ActionView
def method_name
@method_name ||= begin
m = "_#{identifier_method_name}__#{@identifier.hash}_#{__id__}"
m = "_#{identifier_method_name}__#{@identifier.hash}_#{__id__}".dup
m.tr!("-".freeze, "_".freeze)
m
end

View file

@ -14,7 +14,7 @@ module ActionView
alias_method :partial?, :partial
def self.build(name, prefix, partial)
virtual = ""
virtual = "".dup
virtual << "#{prefix}/" unless prefix.empty?
virtual << (partial ? "_#{name}" : name)
new name, prefix, partial, virtual