aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Kenny <elkenny@gmail.com>2017-07-23 11:09:15 +0100
committerEugene Kenny <elkenny@gmail.com>2017-07-23 20:40:00 +0100
commit2b331e9098c489791031ee17f683ca8be92f7bba (patch)
tree97c9218e82b41fe8bf9ba92a3363158957fa6bb1
parent36a301a90aaea213caa54cf3825d3fc9b345c04e (diff)
downloadrails-2b331e9098c489791031ee17f683ca8be92f7bba.tar.gz
rails-2b331e9098c489791031ee17f683ca8be92f7bba.tar.bz2
rails-2b331e9098c489791031ee17f683ca8be92f7bba.zip
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.
-rw-r--r--activerecord/lib/active_record/tasks/database_tasks.rb2
-rw-r--r--railties/test/application/rake/dbs_test.rb7
2 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb
index 5c6a796857..0f3f84ca08 100644
--- a/activerecord/lib/active_record/tasks/database_tasks.rb
+++ b/activerecord/lib/active_record/tasks/database_tasks.rb
@@ -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
diff --git a/railties/test/application/rake/dbs_test.rb b/railties/test/application/rake/dbs_test.rb
index c63f23fa0a..9e612f1526 100644
--- a/railties/test/application/rake/dbs_test.rb
+++ b/railties/test/application/rake/dbs_test.rb
@@ -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;