From 89bcca59e91fa9da941de890012872e8288e77b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 16 Feb 2018 19:28:30 -0500 Subject: Remove usage of strip_heredoc in the framework in favor of <<~ Some places we can't remove because Ruby still don't have a method equivalent to strip_heredoc to be called in an already existent string. --- .rubocop.yml | 2 +- .../metal/request_forgery_protection.rb | 3 +- .../lib/action_dispatch/routing/inspector.rb | 9 ++- actionpack/lib/action_dispatch/routing/mapper.rb | 2 +- .../controller/parameters/serialization_test.rb | 5 +- activemodel/test/cases/errors_test.rb | 3 +- .../active_record/attribute_methods/primary_key.rb | 2 +- .../attribute_methods/serialization.rb | 2 +- .../abstract/schema_creation.rb | 6 +- .../connection_adapters/abstract_mysql_adapter.rb | 8 +-- .../postgresql/schema_statements.rb | 8 +-- activerecord/lib/active_record/errors.rb | 4 +- .../active_record/migration/command_recorder.rb | 2 +- activerecord/test/cases/core_test.rb | 81 +++++++++++----------- activerecord/test/cases/explain_test.rb | 3 +- activerecord/test/cases/fixtures_test.rb | 2 +- .../test/cases/migration/rename_table_test.rb | 2 +- .../lib/active_support/testing/time_helpers.rb | 3 +- activesupport/test/core_ext/string_ext_test.rb | 2 +- activesupport/test/core_ext/time_with_zone_test.rb | 9 ++- railties/lib/rails/generators/actions.rb | 2 + railties/lib/rails/generators/app_base.rb | 1 - .../rails/credentials/credentials_generator.rb | 13 ++-- .../encrypted_file/encrypted_file_generator.rb | 8 +-- .../%namespaced_name%/application_controller.rb.tt | 2 +- .../%namespaced_name%/application_helper.rb.tt | 2 +- .../jobs/%namespaced_name%/application_job.rb.tt | 2 +- .../%namespaced_name%/application_mailer.rb.tt | 2 +- .../%namespaced_name%/application_record.rb.tt | 2 +- .../templates/lib/%namespaced_name%/engine.rb.tt | 2 +- .../templates/lib/%namespaced_name%/railtie.rb.tt | 2 +- railties/lib/rails/secrets.rb | 1 - railties/test/application/rake_test.rb | 11 ++- railties/test/application/test_runner_test.rb | 3 +- railties/test/generators/model_generator_test.rb | 35 +++++----- 35 files changed, 115 insertions(+), 131 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3b4dd79e81..23df748cfd 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 2.2 + TargetRubyVersion: 2.3 # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop # to ignore them, so only the ones explicitly set in this file are enabled. DisabledByDefault: true diff --git a/actionpack/lib/action_controller/metal/request_forgery_protection.rb b/actionpack/lib/action_controller/metal/request_forgery_protection.rb index 0ab313e398..94092de96c 100644 --- a/actionpack/lib/action_controller/metal/request_forgery_protection.rb +++ b/actionpack/lib/action_controller/metal/request_forgery_protection.rb @@ -3,7 +3,6 @@ require "rack/session/abstract/id" require "action_controller/metal/exceptions" require "active_support/security_utils" -require "active_support/core_ext/string/strip" module ActionController #:nodoc: class InvalidAuthenticityToken < ActionControllerError #:nodoc: @@ -416,7 +415,7 @@ module ActionController #:nodoc: allow_forgery_protection end - NULL_ORIGIN_MESSAGE = <<-MSG.strip_heredoc + NULL_ORIGIN_MESSAGE = <<~MSG The browser returned a 'null' origin for a request with origin-based forgery protection turned on. This usually means you have the 'no-referrer' Referrer-Policy header enabled, or that you the request came from a site that refused to give its origin. This makes it impossible for Rails to verify the source of the requests. Likely the diff --git a/actionpack/lib/action_dispatch/routing/inspector.rb b/actionpack/lib/action_dispatch/routing/inspector.rb index a2205569b4..22336c59b6 100644 --- a/actionpack/lib/action_dispatch/routing/inspector.rb +++ b/actionpack/lib/action_dispatch/routing/inspector.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require "delegate" -require "active_support/core_ext/string/strip" module ActionDispatch module Routing @@ -150,10 +149,10 @@ module ActionDispatch def no_routes(routes) @buffer << if routes.none? - <<-MESSAGE.strip_heredoc - You don't have any routes defined! + <<~MESSAGE + You don't have any routes defined! - Please add some routes in config/routes.rb. + Please add some routes in config/routes.rb. MESSAGE else "No routes were found for this controller" @@ -203,7 +202,7 @@ module ActionDispatch end def no_routes(*) - @buffer << <<-MESSAGE.strip_heredoc + @buffer << <<~MESSAGE

You don't have any routes defined!