diff options
author | Pat Allan <pat@freelancing-gods.com> | 2017-07-22 22:45:53 +1000 |
---|---|---|
committer | Pat Allan <pat@freelancing-gods.com> | 2017-08-14 19:00:24 +0200 |
commit | d435c92721a1fbecf0bc6d1b6c5cf95d228c851a (patch) | |
tree | c08015501962c1f6c513e526ed8959880a9e921b | |
parent | 5949cc05d395f5e1435d04d4adee7b26f13a517d (diff) | |
download | rails-d435c92721a1fbecf0bc6d1b6c5cf95d228c851a.tar.gz rails-d435c92721a1fbecf0bc6d1b6c5cf95d228c851a.tar.bz2 rails-d435c92721a1fbecf0bc6d1b6c5cf95d228c851a.zip |
Railties updates for frozen string literals.
-rw-r--r-- | railties/lib/rails/command/base.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/commands/dbconsole/dbconsole_command.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/generated_attribute.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/info.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/source_annotation_extractor.rb | 2 | ||||
-rw-r--r-- | railties/test/application/rake/notes_test.rb | 3 | ||||
-rw-r--r-- | railties/test/console_helpers.rb | 2 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 2 | ||||
-rw-r--r-- | railties/test/generators/shared_generator_tests.rb | 2 | ||||
-rw-r--r-- | railties/test/isolation/abstract_unit.rb | 2 | ||||
-rw-r--r-- | railties/test/railties/engine_test.rb | 2 | ||||
-rw-r--r-- | railties/test/secrets_test.rb | 4 |
14 files changed, 16 insertions, 15 deletions
diff --git a/railties/lib/rails/command/base.rb b/railties/lib/rails/command/base.rb index cd0720be4e..d986df8a80 100644 --- a/railties/lib/rails/command/base.rb +++ b/railties/lib/rails/command/base.rb @@ -73,7 +73,7 @@ module Rails # Use Rails' default banner. def banner(*) - "#{executable} #{arguments.map(&:usage).join(' ')} [options]".squish! + "#{executable} #{arguments.map(&:usage).join(' ')} [options]".squish end # Sets the base_name taking into account the current class namespace. diff --git a/railties/lib/rails/commands/dbconsole/dbconsole_command.rb b/railties/lib/rails/commands/dbconsole/dbconsole_command.rb index 71b3455473..1c16c3f0eb 100644 --- a/railties/lib/rails/commands/dbconsole/dbconsole_command.rb +++ b/railties/lib/rails/commands/dbconsole/dbconsole_command.rb @@ -58,7 +58,7 @@ module Rails logon = "" if config["username"] - logon = config["username"] + logon = config["username"].dup logon << "/#{config['password']}" if config["password"] && @options["include_password"] logon << "@#{config['database']}" if config["database"] end diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 8915441d4c..dbc43159a6 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -271,7 +271,7 @@ module Rails else options = sorted_groups.flat_map(&:last) 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 << "Run `rails generate --help` for more options." puts msg diff --git a/railties/lib/rails/generators/generated_attribute.rb b/railties/lib/rails/generators/generated_attribute.rb index baed7bf1e3..d2c8ba9255 100644 --- a/railties/lib/rails/generators/generated_attribute.rb +++ b/railties/lib/rails/generators/generated_attribute.rb @@ -151,7 +151,7 @@ module Rails end 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 def inject_index_options diff --git a/railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb b/railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb index 42705107ae..56b85e1da1 100644 --- a/railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb +++ b/railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb @@ -36,7 +36,7 @@ module Rails private def route_string - @route_string ||= "" + @route_string ||= "".dup end def write(str, indent) diff --git a/railties/lib/rails/info.rb b/railties/lib/rails/info.rb index db08d578c0..cc2f75a1d3 100644 --- a/railties/lib/rails/info.rb +++ b/railties/lib/rails/info.rb @@ -39,7 +39,7 @@ module Rails alias inspect to_s def to_html - "<table>".tap do |table| + "<table>".dup.tap do |table| properties.each do |(name, value)| table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>) formatted_value = if value.kind_of?(Array) diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb index e9088c44ce..0412d725df 100644 --- a/railties/lib/rails/source_annotation_extractor.rb +++ b/railties/lib/rails/source_annotation_extractor.rb @@ -45,7 +45,7 @@ class SourceAnnotationExtractor # 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. 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 << text end diff --git a/railties/test/application/rake/notes_test.rb b/railties/test/application/rake/notes_test.rb index e7ffea2e71..b5fb98a539 100644 --- a/railties/test/application/rake/notes_test.rb +++ b/railties/test/application/rake/notes_test.rb @@ -90,7 +90,8 @@ module ApplicationTests 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 "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 "lib/tasks/notes_custom.rake", <<-EOS diff --git a/railties/test/console_helpers.rb b/railties/test/console_helpers.rb index 4b11afa511..4eaac37581 100644 --- a/railties/test/console_helpers.rb +++ b/railties/test/console_helpers.rb @@ -7,7 +7,7 @@ module ConsoleHelpers def assert_output(expected, io, timeout = 10) timeout = Time.now + timeout - output = "" + output = "".dup until output.include?(expected) || Time.now > timeout if IO.select([io], [], [], 0.1) output << io.read(1) diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index ff73014046..6f933a3edd 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -880,7 +880,7 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_after_bundle_callback 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 check_open = -> *args do diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb index 5e75879964..3ce0dd4b6f 100644 --- a/railties/test/generators/shared_generator_tests.rb +++ b/railties/test/generators/shared_generator_tests.rb @@ -77,7 +77,7 @@ module SharedGeneratorTests def test_template_is_executed_when_supplied_an_https_path 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 check_open = -> *args do diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 7fa523f58d..8bc3a15ccb 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -66,7 +66,7 @@ module TestHelpers end def extract_body(response) - "".tap do |body| + "".dup.tap do |body| response[2].each { |chunk| body << chunk } end end diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index ea942a3975..f3d64687d5 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -503,7 +503,7 @@ YAML def call(env) response = @app.call(env) - response[2].each(&:upcase!) + response[2] = response[2].collect(&:upcase) response end end diff --git a/railties/test/secrets_test.rb b/railties/test/secrets_test.rb index d78c253765..03cc7148f9 100644 --- a/railties/test/secrets_test.rb +++ b/railties/test/secrets_test.rb @@ -133,7 +133,7 @@ class Rails::SecretsTest < ActiveSupport::TestCase api_key: 00112233445566778899aabbccddeeff… 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| assert_match(/production:\n\s*api_key: 00112233445566778899aabbccddeeff…\n/, File.read(tmp_path)) @@ -153,7 +153,7 @@ class Rails::SecretsTest < ActiveSupport::TestCase Rails::Secrets.write(secrets) 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 assert_equal "00112233445566778899aabbccddeeff…\n", `bin/rails runner -e production "puts Rails.application.secrets.api_key"` |