Railties updates for frozen string literals.
This commit is contained in:
parent
5949cc05d3
commit
d435c92721
@ -73,7 +73,7 @@ def executable
|
|||||||
|
|
||||||
# Use Rails' default banner.
|
# Use Rails' default banner.
|
||||||
def banner(*)
|
def banner(*)
|
||||||
"#{executable} #{arguments.map(&:usage).join(' ')} [options]".squish!
|
"#{executable} #{arguments.map(&:usage).join(' ')} [options]".squish
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets the base_name taking into account the current class namespace.
|
# Sets the base_name taking into account the current class namespace.
|
||||||
|
@ -58,7 +58,7 @@ def start
|
|||||||
logon = ""
|
logon = ""
|
||||||
|
|
||||||
if config["username"]
|
if config["username"]
|
||||||
logon = config["username"]
|
logon = config["username"].dup
|
||||||
logon << "/#{config['password']}" if config["password"] && @options["include_password"]
|
logon << "/#{config['password']}" if config["password"] && @options["include_password"]
|
||||||
logon << "@#{config['database']}" if config["database"]
|
logon << "@#{config['database']}" if config["database"]
|
||||||
end
|
end
|
||||||
|
@ -271,7 +271,7 @@ def invoke(namespace, args = ARGV, config = {})
|
|||||||
else
|
else
|
||||||
options = sorted_groups.flat_map(&:last)
|
options = sorted_groups.flat_map(&:last)
|
||||||
suggestions = options.sort_by { |suggested| levenshtein_distance(namespace.to_s, suggested) }.first(3)
|
suggestions = options.sort_by { |suggested| levenshtein_distance(namespace.to_s, suggested) }.first(3)
|
||||||
msg = "Could not find generator '#{namespace}'. "
|
msg = "Could not find generator '#{namespace}'. ".dup
|
||||||
msg << "Maybe you meant #{ suggestions.map { |s| "'#{s}'" }.to_sentence(last_word_connector: " or ", locale: :en) }\n"
|
msg << "Maybe you meant #{ suggestions.map { |s| "'#{s}'" }.to_sentence(last_word_connector: " or ", locale: :en) }\n"
|
||||||
msg << "Run `rails generate --help` for more options."
|
msg << "Run `rails generate --help` for more options."
|
||||||
puts msg
|
puts msg
|
||||||
|
@ -151,7 +151,7 @@ def token?
|
|||||||
end
|
end
|
||||||
|
|
||||||
def inject_options
|
def inject_options
|
||||||
"".tap { |s| options_for_migration.each { |k, v| s << ", #{k}: #{v.inspect}" } }
|
"".dup.tap { |s| options_for_migration.each { |k, v| s << ", #{k}: #{v.inspect}" } }
|
||||||
end
|
end
|
||||||
|
|
||||||
def inject_index_options
|
def inject_index_options
|
||||||
|
@ -36,7 +36,7 @@ def add_resource_route
|
|||||||
|
|
||||||
private
|
private
|
||||||
def route_string
|
def route_string
|
||||||
@route_string ||= ""
|
@route_string ||= "".dup
|
||||||
end
|
end
|
||||||
|
|
||||||
def write(str, indent)
|
def write(str, indent)
|
||||||
|
@ -39,7 +39,7 @@ def to_s
|
|||||||
alias inspect to_s
|
alias inspect to_s
|
||||||
|
|
||||||
def to_html
|
def to_html
|
||||||
"<table>".tap do |table|
|
"<table>".dup.tap do |table|
|
||||||
properties.each do |(name, value)|
|
properties.each do |(name, value)|
|
||||||
table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>)
|
table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>)
|
||||||
formatted_value = if value.kind_of?(Array)
|
formatted_value = if value.kind_of?(Array)
|
||||||
|
@ -45,7 +45,7 @@ def self.register_extensions(*exts, &block)
|
|||||||
# If +options+ has a flag <tt>:tag</tt> the tag is shown as in the example above.
|
# If +options+ has a flag <tt>:tag</tt> the tag is shown as in the example above.
|
||||||
# Otherwise the string contains just line and text.
|
# Otherwise the string contains just line and text.
|
||||||
def to_s(options = {})
|
def to_s(options = {})
|
||||||
s = "[#{line.to_s.rjust(options[:indent])}] "
|
s = "[#{line.to_s.rjust(options[:indent])}] ".dup
|
||||||
s << "[#{tag}] " if options[:tag]
|
s << "[#{tag}] " if options[:tag]
|
||||||
s << text
|
s << text
|
||||||
end
|
end
|
||||||
|
@ -90,7 +90,8 @@ def teardown
|
|||||||
|
|
||||||
test "custom rake task finds specific notes in specific directories" do
|
test "custom rake task finds specific notes in specific directories" do
|
||||||
app_file "app/controllers/some_controller.rb", "# TODO: note in app directory"
|
app_file "app/controllers/some_controller.rb", "# TODO: note in app directory"
|
||||||
app_file "lib/some_file.rb", "# OPTIMIZE: note in lib directory\n" << "# FIXME: note in lib directory"
|
app_file "lib/some_file.rb", "# OPTIMIZE: note in lib directory\n" \
|
||||||
|
"# FIXME: note in lib directory"
|
||||||
app_file "test/some_test.rb", 1000.times.map { "" }.join("\n") << "# TODO: note in test directory"
|
app_file "test/some_test.rb", 1000.times.map { "" }.join("\n") << "# TODO: note in test directory"
|
||||||
|
|
||||||
app_file "lib/tasks/notes_custom.rake", <<-EOS
|
app_file "lib/tasks/notes_custom.rake", <<-EOS
|
||||||
|
@ -7,7 +7,7 @@ module ConsoleHelpers
|
|||||||
def assert_output(expected, io, timeout = 10)
|
def assert_output(expected, io, timeout = 10)
|
||||||
timeout = Time.now + timeout
|
timeout = Time.now + timeout
|
||||||
|
|
||||||
output = ""
|
output = "".dup
|
||||||
until output.include?(expected) || Time.now > timeout
|
until output.include?(expected) || Time.now > timeout
|
||||||
if IO.select([io], [], [], 0.1)
|
if IO.select([io], [], [], 0.1)
|
||||||
output << io.read(1)
|
output << io.read(1)
|
||||||
|
@ -880,7 +880,7 @@ def test_psych_gem
|
|||||||
|
|
||||||
def test_after_bundle_callback
|
def test_after_bundle_callback
|
||||||
path = "http://example.org/rails_template"
|
path = "http://example.org/rails_template"
|
||||||
template = %{ after_bundle { run 'echo ran after_bundle' } }
|
template = %{ after_bundle { run 'echo ran after_bundle' } }.dup
|
||||||
template.instance_eval "def read; self; end" # Make the string respond to read
|
template.instance_eval "def read; self; end" # Make the string respond to read
|
||||||
|
|
||||||
check_open = -> *args do
|
check_open = -> *args do
|
||||||
|
@ -77,7 +77,7 @@ def test_template_raises_an_error_with_invalid_path
|
|||||||
|
|
||||||
def test_template_is_executed_when_supplied_an_https_path
|
def test_template_is_executed_when_supplied_an_https_path
|
||||||
path = "https://gist.github.com/josevalim/103208/raw/"
|
path = "https://gist.github.com/josevalim/103208/raw/"
|
||||||
template = %{ say "It works!" }
|
template = %{ say "It works!" }.dup
|
||||||
template.instance_eval "def read; self; end" # Make the string respond to read
|
template.instance_eval "def read; self; end" # Make the string respond to read
|
||||||
|
|
||||||
check_open = -> *args do
|
check_open = -> *args do
|
||||||
|
@ -66,7 +66,7 @@ def app(env = "production")
|
|||||||
end
|
end
|
||||||
|
|
||||||
def extract_body(response)
|
def extract_body(response)
|
||||||
"".tap do |body|
|
"".dup.tap do |body|
|
||||||
response[2].each { |chunk| body << chunk }
|
response[2].each { |chunk| body << chunk }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -503,7 +503,7 @@ def initialize(app)
|
|||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
response = @app.call(env)
|
response = @app.call(env)
|
||||||
response[2].each(&:upcase!)
|
response[2] = response[2].collect(&:upcase)
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -133,7 +133,7 @@ def teardown
|
|||||||
api_key: 00112233445566778899aabbccddeeff…
|
api_key: 00112233445566778899aabbccddeeff…
|
||||||
end_of_secrets
|
end_of_secrets
|
||||||
|
|
||||||
Rails::Secrets.write(secrets.force_encoding(Encoding::ASCII_8BIT))
|
Rails::Secrets.write(secrets.dup.force_encoding(Encoding::ASCII_8BIT))
|
||||||
|
|
||||||
Rails::Secrets.read_for_editing do |tmp_path|
|
Rails::Secrets.read_for_editing do |tmp_path|
|
||||||
assert_match(/production:\n\s*api_key: 00112233445566778899aabbccddeeff…\n/, File.read(tmp_path))
|
assert_match(/production:\n\s*api_key: 00112233445566778899aabbccddeeff…\n/, File.read(tmp_path))
|
||||||
@ -153,7 +153,7 @@ def teardown
|
|||||||
Rails::Secrets.write(secrets)
|
Rails::Secrets.write(secrets)
|
||||||
|
|
||||||
Rails::Secrets.read_for_editing do |tmp_path|
|
Rails::Secrets.read_for_editing do |tmp_path|
|
||||||
assert_equal(secrets.force_encoding(Encoding::ASCII_8BIT), IO.binread(tmp_path))
|
assert_equal(secrets.dup.force_encoding(Encoding::ASCII_8BIT), IO.binread(tmp_path))
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal "00112233445566778899aabbccddeeff…\n", `bin/rails runner -e production "puts Rails.application.secrets.api_key"`
|
assert_equal "00112233445566778899aabbccddeeff…\n", `bin/rails runner -e production "puts Rails.application.secrets.api_key"`
|
||||||
|
Loading…
Reference in New Issue
Block a user