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

Avoid modifying frozen string in check_schema_file

This was missed when the frozen string literal pragma was added to this
file because the string is only modified when running in the context of
a full Rails app, which wasn't covered by the test suite.
This commit is contained in:
Eugene Kenny 2017-07-23 11:09:15 +01:00
parent 36a301a90a
commit 2b331e9098
2 changed files with 8 additions and 1 deletions

View file

@ -261,7 +261,7 @@ module ActiveRecord
def check_schema_file(filename)
unless File.exist?(filename)
message = %{#{filename} doesn't exist yet. Run `rails db:migrate` to create it, then try again.}
message = %{#{filename} doesn't exist yet. Run `rails db:migrate` to create it, then try again.}.dup
message << %{ If you do not intend to use a database, you should instead alter #{Rails.root}/config/application.rb to limit the frameworks that will be loaded.} if defined?(::Rails.root)
Kernel.abort message
end

View file

@ -259,6 +259,13 @@ module ApplicationTests
end
end
test "db:schema:load fails if schema.rb doesn't exist yet" do
Dir.chdir(app_path) do
stderr_output = capture(:stderr) { `bin/rails db:schema:load` }
assert_match /Run `rails db:migrate` to create it/, stderr_output
end
end
def db_test_load_structure
Dir.chdir(app_path) do
`bin/rails generate model book title:string;