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.
上级 2c89d1dd
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
......
......@@ -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 @@ def protect_against_forgery? # :doc:
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
......
# frozen_string_literal: true
require "delegate"
require "active_support/core_ext/string/strip"
module ActionDispatch
module Routing
......@@ -150,10 +149,10 @@ def header(routes)
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 @@ def header(routes)
end
def no_routes(*)
@buffer << <<-MESSAGE.strip_heredoc
@buffer << <<~MESSAGE
<p>You don't have any routes defined!</p>
<ul>
<li>Please add some routes in <tt>config/routes.rb</tt>.</li>
......
......@@ -611,7 +611,7 @@ def mount(app, options = nil)
end
raise ArgumentError, "A rack application must be specified" unless app.respond_to?(:call)
raise ArgumentError, <<-MSG.strip_heredoc unless path
raise ArgumentError, <<~MSG unless path
Must be called with mount point
mount SomeRackApp, at: "some_route"
......
......@@ -2,7 +2,6 @@
require "abstract_unit"
require "action_controller/metal/strong_parameters"
require "active_support/core_ext/string/strip"
class ParametersSerializationTest < ActiveSupport::TestCase
setup do
......@@ -31,7 +30,7 @@ class ParametersSerializationTest < ActiveSupport::TestCase
end
test "yaml backwardscompatible with psych 2.0.8 format" do
params = YAML.load <<-end_of_yaml.strip_heredoc
params = YAML.load <<~end_of_yaml
--- !ruby/hash:ActionController::Parameters
key: :value
end_of_yaml
......@@ -41,7 +40,7 @@ class ParametersSerializationTest < ActiveSupport::TestCase
end
test "yaml backwardscompatible with psych 2.0.9+ format" do
params = YAML.load(<<-end_of_yaml.strip_heredoc)
params = YAML.load(<<~end_of_yaml)
--- !ruby/hash-with-ivars:ActionController::Parameters
elements:
key: :value
......
# frozen_string_literal: true
require "cases/helper"
require "active_support/core_ext/string/strip"
require "yaml"
class ErrorsTest < ActiveModel::TestCase
......@@ -406,7 +405,7 @@ def test_no_key
end
test "errors are backward compatible with the Rails 4.2 format" do
yaml = <<-CODE.strip_heredoc
yaml = <<~CODE
--- !ruby/object:ActiveModel::Errors
base: &1 !ruby/object:ErrorsTest::Person
errors: !ruby/object:ActiveModel::Errors
......
......@@ -131,7 +131,7 @@ def primary_key=(value)
def suppress_composite_primary_key(pk)
return pk unless pk.is_a?(Array)
warn <<-WARNING.strip_heredoc
warn <<~WARNING
WARNING: Active Record does not support composite primary key.
#{table_name} has composite primary key. Composite primary key is ignored.
......
......@@ -7,7 +7,7 @@ module Serialization
class ColumnNotSerializableError < StandardError
def initialize(name, type)
super <<-EOS.strip_heredoc
super <<~EOS
Column `#{name}` of type #{type.class} does not support `serialize` feature.
Usually it means that you are trying to use `serialize`
on a column that already implements serialization natively.
......
# frozen_string_literal: true
require "active_support/core_ext/string/strip"
module ActiveRecord
module ConnectionAdapters
class AbstractAdapter
......@@ -66,7 +64,7 @@ def visit_PrimaryKeyDefinition(o)
end
def visit_ForeignKeyDefinition(o)
sql = <<-SQL.strip_heredoc
sql = <<~SQL
CONSTRAINT #{quote_column_name(o.name)}
FOREIGN KEY (#{quote_column_name(o.column)})
REFERENCES #{quote_table_name(o.to_table)} (#{quote_column_name(o.primary_key)})
......@@ -133,7 +131,7 @@ def action_sql(action, dependency)
when :cascade then "ON #{action} CASCADE"
when :restrict then "ON #{action} RESTRICT"
else
raise ArgumentError, <<-MSG.strip_heredoc
raise ArgumentError, <<~MSG
'#{dependency}' is not supported for :on_update or :on_delete.
Supported values are: :nullify, :cascade, :restrict
MSG
......
......@@ -11,8 +11,6 @@
require "active_record/connection_adapters/mysql/schema_statements"
require "active_record/connection_adapters/mysql/type_metadata"
require "active_support/core_ext/string/strip"
module ActiveRecord
module ConnectionAdapters
class AbstractMysqlAdapter < AbstractAdapter
......@@ -284,7 +282,7 @@ def truncate(table_name, name = nil)
def table_comment(table_name) # :nodoc:
scope = quoted_scope(table_name)
query_value(<<-SQL.strip_heredoc, "SCHEMA").presence
query_value(<<~SQL, "SCHEMA").presence
SELECT table_comment
FROM information_schema.tables
WHERE table_schema = #{scope[:schema]}
......@@ -392,7 +390,7 @@ def foreign_keys(table_name)
scope = quoted_scope(table_name)
fk_info = exec_query(<<-SQL.strip_heredoc, "SCHEMA")
fk_info = exec_query(<<~SQL, "SCHEMA")
SELECT fk.referenced_table_name AS 'to_table',
fk.referenced_column_name AS 'primary_key',
fk.column_name AS 'column',
......@@ -480,7 +478,7 @@ def primary_keys(table_name) # :nodoc:
scope = quoted_scope(table_name)
query_values(<<-SQL.strip_heredoc, "SCHEMA")
query_values(<<~SQL, "SCHEMA")
SELECT column_name
FROM information_schema.key_column_usage
WHERE constraint_name = 'PRIMARY'
......
......@@ -115,7 +115,7 @@ def indexes(table_name) # :nodoc:
if indkey.include?(0)
columns = expressions
else
columns = Hash[query(<<-SQL.strip_heredoc, "SCHEMA")].values_at(*indkey).compact
columns = Hash[query(<<~SQL, "SCHEMA")].values_at(*indkey).compact
SELECT a.attnum, a.attname
FROM pg_attribute a
WHERE a.attrelid = #{oid}
......@@ -158,7 +158,7 @@ def table_options(table_name) # :nodoc:
def table_comment(table_name) # :nodoc:
scope = quoted_scope(table_name, type: "BASE TABLE")
if scope[:name]
query_value(<<-SQL.strip_heredoc, "SCHEMA")
query_value(<<~SQL, "SCHEMA")
SELECT pg_catalog.obj_description(c.oid, 'pg_class')
FROM pg_catalog.pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
......@@ -353,7 +353,7 @@ def pk_and_sequence_for(table) #:nodoc:
end
def primary_keys(table_name) # :nodoc:
query_values(<<-SQL.strip_heredoc, "SCHEMA")
query_values(<<~SQL, "SCHEMA")
SELECT a.attname
FROM (
SELECT indrelid, indkey, generate_subscripts(indkey, 1) idx
......@@ -502,7 +502,7 @@ def rename_index(table_name, old_name, new_name)
def foreign_keys(table_name)
scope = quoted_scope(table_name)
fk_info = exec_query(<<-SQL.strip_heredoc, "SCHEMA")
fk_info = exec_query(<<~SQL, "SCHEMA")
SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete, c.convalidated AS valid
FROM pg_constraint c
JOIN pg_class t1 ON c.conrelid = t1.oid
......
......@@ -120,13 +120,13 @@ class MismatchedForeignKey < StatementInvalid
def initialize(adapter = nil, message: nil, table: nil, foreign_key: nil, target_table: nil, primary_key: nil)
@adapter = adapter
if table
msg = <<-EOM.strip_heredoc
msg = <<~EOM
Column `#{foreign_key}` on table `#{table}` has a type of `#{column_type(table, foreign_key)}`.
This does not match column `#{primary_key}` on `#{target_table}`, which has type `#{column_type(target_table, primary_key)}`.
To resolve this issue, change the type of the `#{foreign_key}` column on `#{table}` to be :integer. (For example `t.integer #{foreign_key}`).
EOM
else
msg = <<-EOM
msg = <<~EOM
There is a mismatch between the foreign key and primary key column types.
Verify that the foreign key column type and the primary key of the associated table match types.
EOM
......
......@@ -85,7 +85,7 @@ def record(*command, &block)
# invert the +command+.
def inverse_of(command, args, &block)
method = :"invert_#{command}"
raise IrreversibleMigration, <<-MSG.strip_heredoc unless respond_to?(method, true)
raise IrreversibleMigration, <<~MSG unless respond_to?(method, true)
This migration uses #{command}, which is not automatically reversible.
To make the migration reversible you can either:
1. Define #up and #down methods in place of the #change method.
......
......@@ -4,7 +4,6 @@
require "models/person"
require "models/topic"
require "pp"
require "active_support/core_ext/string/strip"
class NonExistentTable < ActiveRecord::Base; end
......@@ -39,26 +38,26 @@ def test_pretty_print_new
topic = Topic.new
actual = "".dup
PP.pp(topic, StringIO.new(actual))
expected = <<-PRETTY.strip_heredoc
#<Topic:0xXXXXXX
id: nil,
title: nil,
author_name: nil,
author_email_address: "test@test.com",
written_on: nil,
bonus_time: nil,
last_read: nil,
content: nil,
important: nil,
approved: true,
replies_count: 0,
unique_replies_count: 0,
parent_id: nil,
parent_title: nil,
type: nil,
group: nil,
created_at: nil,
updated_at: nil>
expected = <<~PRETTY
#<Topic:0xXXXXXX
id: nil,
title: nil,
author_name: nil,
author_email_address: "test@test.com",
written_on: nil,
bonus_time: nil,
last_read: nil,
content: nil,
important: nil,
approved: true,
replies_count: 0,
unique_replies_count: 0,
parent_id: nil,
parent_title: nil,
type: nil,
group: nil,
created_at: nil,
updated_at: nil>
PRETTY
assert actual.start_with?(expected.split("XXXXXX").first)
assert actual.end_with?(expected.split("XXXXXX").last)
......@@ -68,26 +67,26 @@ def test_pretty_print_persisted
topic = topics(:first)
actual = "".dup
PP.pp(topic, StringIO.new(actual))
expected = <<-PRETTY.strip_heredoc
#<Topic:0x\\w+
id: 1,
title: "The First Topic",
author_name: "David",
author_email_address: "david@loudthinking.com",
written_on: 2003-07-16 14:28:11 UTC,
bonus_time: 2000-01-01 14:28:00 UTC,
last_read: Thu, 15 Apr 2004,
content: "Have a nice day",
important: nil,
approved: false,
replies_count: 1,
unique_replies_count: 0,
parent_id: nil,
parent_title: nil,
type: nil,
group: nil,
created_at: [^,]+,
updated_at: [^,>]+>
expected = <<~PRETTY
#<Topic:0x\\w+
id: 1,
title: "The First Topic",
author_name: "David",
author_email_address: "david@loudthinking.com",
written_on: 2003-07-16 14:28:11 UTC,
bonus_time: 2000-01-01 14:28:00 UTC,
last_read: Thu, 15 Apr 2004,
content: "Have a nice day",
important: nil,
approved: false,
replies_count: 1,
unique_replies_count: 0,
parent_id: nil,
parent_title: nil,
type: nil,
group: nil,
created_at: [^,]+,
updated_at: [^,>]+>
PRETTY
assert_match(/\A#{expected}\z/, actual)
end
......
......@@ -2,7 +2,6 @@
require "cases/helper"
require "models/car"
require "active_support/core_ext/string/strip"
if ActiveRecord::Base.connection.supports_explain?
class ExplainTest < ActiveRecord::TestCase
......@@ -53,7 +52,7 @@ def test_exec_explain_with_binds
queries = sqls.zip(binds)
stub_explain_for_query_plans(["query plan foo\n", "query plan bar\n"]) do
expected = <<-SQL.strip_heredoc
expected = <<~SQL
EXPLAIN for: #{sqls[0]} [["wadus", 1]]
query plan foo
......
......@@ -86,7 +86,7 @@ def test_bulk_insert_multiple_table_with_a_multi_statement_query
create_fixtures("bulbs", "authors", "computers")
expected_sql = <<-EOS.strip_heredoc.chop
expected_sql = <<~EOS
INSERT INTO #{ActiveRecord::Base.connection.quote_table_name("bulbs")} .*
INSERT INTO #{ActiveRecord::Base.connection.quote_table_name("authors")} .*
INSERT INTO #{ActiveRecord::Base.connection.quote_table_name("computers")} .*
......
......@@ -88,7 +88,7 @@ def test_renaming_table_renames_primary_key
assert connection.table_exists? :felines
assert_not connection.table_exists? :cats
primary_key_name = connection.select_values(<<-SQL.strip_heredoc, "SCHEMA")[0]
primary_key_name = connection.select_values(<<~SQL, "SCHEMA")[0]
SELECT c.relname
FROM pg_class c
JOIN pg_index i
......
# frozen_string_literal: true
require "active_support/core_ext/module/redefine_method"
require "active_support/core_ext/string/strip" # for strip_heredoc
require "active_support/core_ext/time/calculations"
require "concurrent/map"
......@@ -112,7 +111,7 @@ def travel(duration, &block)
# Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
def travel_to(date_or_time)
if block_given? && simple_stubs.stubbing(Time, :now)
travel_to_nested_block_call = <<-MSG.strip_heredoc
travel_to_nested_block_call = <<~MSG
Calling `travel_to` with a block, when we have previously already made a call to `travel_to`, can lead to confusing time stubbing.
......
......@@ -9,9 +9,9 @@
require "active_support/inflector"
require "active_support/core_ext/string"
require "active_support/time"
require "active_support/core_ext/string/strip"
require "active_support/core_ext/string/output_safety"
require "active_support/core_ext/string/indent"
require "active_support/core_ext/string/strip"
require "time_zone_test_helpers"
require "yaml"
......
......@@ -3,7 +3,6 @@
require "abstract_unit"
require "active_support/time"
require "time_zone_test_helpers"
require "active_support/core_ext/string/strip"
require "yaml"
class TimeWithZoneTest < ActiveSupport::TestCase
......@@ -163,7 +162,7 @@ def test_rfc3339_with_fractional_seconds
end
def test_to_yaml
yaml = <<-EOF.strip_heredoc
yaml = <<~EOF
--- !ruby/object:ActiveSupport::TimeWithZone
utc: 2000-01-01 00:00:00.000000000 Z
zone: !ruby/object:ActiveSupport::TimeZone
......@@ -175,7 +174,7 @@ def test_to_yaml
end
def test_ruby_to_yaml
yaml = <<-EOF.strip_heredoc
yaml = <<~EOF
---
twz: !ruby/object:ActiveSupport::TimeWithZone
utc: 2000-01-01 00:00:00.000000000 Z
......@@ -188,7 +187,7 @@ def test_ruby_to_yaml
end
def test_yaml_load
yaml = <<-EOF.strip_heredoc
yaml = <<~EOF
--- !ruby/object:ActiveSupport::TimeWithZone
utc: 2000-01-01 00:00:00.000000000 Z
zone: !ruby/object:ActiveSupport::TimeZone
......@@ -200,7 +199,7 @@ def test_yaml_load
end
def test_ruby_yaml_load
yaml = <<-EOF.strip_heredoc
yaml = <<~EOF
---
twz: !ruby/object:ActiveSupport::TimeWithZone
utc: 2000-01-01 00:00:00.000000000 Z
......
# frozen_string_literal: true
require "active_support/core_ext/string/strip"
module Rails
module Generators
module Actions
......
......@@ -2,7 +2,6 @@
require "fileutils"
require "digest/md5"
require "active_support/core_ext/string/strip"
require "rails/version" unless defined?(Rails::VERSION)
require "open-uri"
require "uri"
......
......@@ -2,7 +2,6 @@
require "rails/generators/base"
require "rails/generators/rails/master_key/master_key_generator"
require "active_support/core_ext/string/strip"
require "active_support/encrypted_configuration"
module Rails
......@@ -43,13 +42,13 @@ def credentials
end
def credentials_template
<<-YAML.strip_heredoc
# aws:
# access_key_id: 123
# secret_access_key: 345
<<~YAML
# aws:
# access_key_id: 123
# secret_access_key: 345
# Used as the base secret for all MessageVerifiers in Rails, including the one protecting cookies.
secret_key_base: #{SecureRandom.hex(64)}
# Used as the base secret for all MessageVerifiers in Rails, including the one protecting cookies.
secret_key_base: #{SecureRandom.hex(64)}
YAML
end
end
......
......@@ -16,10 +16,10 @@ def add_encrypted_file_silently(file_path, key_path, template = encrypted_file_t
private
def encrypted_file_template
<<-YAML.strip_heredoc
# aws:
# access_key_id: 123
# secret_access_key: 345
<<~YAML
# aws:
# access_key_id: 123
# secret_access_key: 345
YAML
end
......
<%= wrap_in_modules <<-rb.strip_heredoc
<%= wrap_in_modules <<~rb
class ApplicationController < ActionController::#{api? ? "API" : "Base"}
#{ api? ? '# ' : '' }protect_from_forgery with: :exception
end
......
<%= wrap_in_modules <<-rb.strip_heredoc
<%= wrap_in_modules <<~rb
module ApplicationHelper
end
rb
......
<%= wrap_in_modules <<-rb.strip_heredoc
<%= wrap_in_modules <<~rb
class ApplicationJob < ActiveJob::Base
end
rb
......
<%= wrap_in_modules <<-rb.strip_heredoc
<%= wrap_in_modules <<~rb
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
......
<%= wrap_in_modules <<-rb.strip_heredoc
<%= wrap_in_modules <<~rb
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
......
<%= wrap_in_modules <<-rb.strip_heredoc
<%= wrap_in_modules <<~rb
class Engine < ::Rails::Engine
#{mountable? ? ' isolate_namespace ' + camelized_modules : ' '}
#{api? ? " config.generators.api_only = true" : ' '}
......
<%= wrap_in_modules <<-rb.strip_heredoc
<%= wrap_in_modules <<~rb
class Railtie < ::Rails::Railtie
end
rb
......
......@@ -2,7 +2,6 @@
require "yaml"
require "active_support/message_encryptor"
require "active_support/core_ext/string/strip"
module Rails
# Greatly inspired by Ara T. Howard's magnificent sekrets gem. 😘
......
......@@ -2,7 +2,6 @@
require "isolation/abstract_unit"
require "env_helpers"
require "active_support/core_ext/string/strip"
module ApplicationTests
class RakeTest < ActiveSupport::TestCase
......@@ -131,7 +130,7 @@ def test_rails_routes_calls_the_route_inspector
RUBY
output = rails("routes")
assert_equal <<-MESSAGE.strip_heredoc, output
assert_equal <<~MESSAGE, output
Prefix Verb URI Pattern Controller#Action
cart GET /cart(.:format) cart#show
rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
......@@ -173,7 +172,7 @@ def test_rails_routes_with_global_search_key
RUBY
output = rails("routes", "-g", "show")
assert_equal <<-MESSAGE.strip_heredoc, output
assert_equal <<~MESSAGE, output
Prefix Verb URI Pattern Controller#Action
cart GET /cart(.:format) cart#show
rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
......@@ -183,7 +182,7 @@ def test_rails_routes_with_global_search_key
MESSAGE
output = rails("routes", "-g", "POST")
assert_equal <<-MESSAGE.strip_heredoc, output
assert_equal <<~MESSAGE, output
Prefix Verb URI Pattern Controller#Action
POST /cart(.:format) cart#create
rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create
......@@ -242,7 +241,7 @@ def test_rails_routes_displays_message_when_no_routes_are_defined
end
RUBY
assert_equal <<-MESSAGE.strip_heredoc, rails("routes")
assert_equal <<~MESSAGE, rails("routes")
Prefix Verb URI Pattern Controller#Action
rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
rails_blob_variation GET /rails/active_storage/variants/:signed_blob_id/:variation_key/*filename(.:format) active_storage/variants#show
......@@ -262,7 +261,7 @@ def test_rake_routes_with_rake_options
output = Dir.chdir(app_path) { `bin/rake --rakefile Rakefile routes` }
assert_equal <<-MESSAGE.strip_heredoc, output
assert_equal <<~MESSAGE, output
Prefix Verb URI Pattern Controller#Action
cart GET /cart(.:format) cart#show
rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
......
# frozen_string_literal: true
require "isolation/abstract_unit"
require "active_support/core_ext/string/strip"
require "env_helpers"
module ApplicationTests
......@@ -741,7 +740,7 @@ def run_test_command(arguments = "test/unit/test_test.rb", **opts)
def create_model_with_fixture
rails "generate", "model", "user", "name:string"
app_file "test/fixtures/users.yml", <<-YAML.strip_heredoc
app_file "test/fixtures/users.yml", <<~YAML
vampire:
id: 1
name: Koyomi Araragi
......
......@@ -2,7 +2,6 @@
require "generators/generators_test_helper"
require "rails/generators/rails/model/model_generator"
require "active_support/core_ext/string/strip"
class ModelGeneratorTest < Rails::Generators::TestCase
include GeneratorsTestHelper
......@@ -379,10 +378,10 @@ def test_add_uuid_to_create_table_migration
def test_required_belongs_to_adds_required_association
run_generator ["account", "supplier:references{required}"]
expected_file = <<-FILE.strip_heredoc
class Account < ApplicationRecord
belongs_to :supplier, required: true
end
expected_file = <<~FILE
class Account < ApplicationRecord
belongs_to :supplier, required: true
end
FILE
assert_file "app/models/account.rb", expected_file
end
......@@ -390,10 +389,10 @@ class Account < ApplicationRecord
def test_required_polymorphic_belongs_to_generages_correct_model
run_generator ["account", "supplier:references{required,polymorphic}"]
expected_file = <<-FILE.strip_heredoc
class Account < ApplicationRecord
belongs_to :supplier, polymorphic: true, required: true
end
expected_file = <<~FILE
class Account < ApplicationRecord
belongs_to :supplier, polymorphic: true, required: true
end
FILE
assert_file "app/models/account.rb", expected_file
end
......@@ -401,10 +400,10 @@ class Account < ApplicationRecord
def test_required_and_polymorphic_are_order_independent
run_generator ["account", "supplier:references{polymorphic.required}"]
expected_file = <<-FILE.strip_heredoc
class Account < ApplicationRecord
belongs_to :supplier, polymorphic: true, required: true
end
expected_file = <<~FILE
class Account < ApplicationRecord
belongs_to :supplier, polymorphic: true, required: true
end
FILE
assert_file "app/models/account.rb", expected_file
end
......@@ -452,11 +451,11 @@ def test_foreign_key_is_skipped_for_polymorphic_references
def test_token_option_adds_has_secure_token
run_generator ["user", "token:token", "auth_token:token"]
expected_file = <<-FILE.strip_heredoc
class User < ApplicationRecord
has_secure_token
has_secure_token :auth_token
end
expected_file = <<~FILE
class User < ApplicationRecord
has_secure_token
has_secure_token :auth_token
end
FILE
assert_file "app/models/user.rb", expected_file
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册