diff options
author | Philippe Guay <Philippe.Guay@videri.com> | 2017-03-19 22:39:14 -0400 |
---|---|---|
committer | Philippe Guay <Philippe.Guay@videri.com> | 2017-03-26 21:06:02 -0400 |
commit | 14739b5e27987e1eee080579fa0c80eea07347b8 (patch) | |
tree | ab04a005f092325afaf6a15cf9ea72598cb161d5 /activerecord/test | |
parent | 40ba03adaa743e2c67c82220794c9f11fae97d12 (diff) | |
download | rails-14739b5e27987e1eee080579fa0c80eea07347b8.tar.gz rails-14739b5e27987e1eee080579fa0c80eea07347b8.tar.bz2 rails-14739b5e27987e1eee080579fa0c80eea07347b8.zip |
Fixes #28359
Add stronger assertions to rake migration tasks to make sure the user is providing a numeric VERSION
An empty string was getting converted to version = 0. This would in turn pass the presence check.
Address linting warning
Add test for rake task and refactor code to meet expectations
In particular passing VERSION=0 should not raise an error.
Addressed Comments for PR #28485. Trimmed empty lines + change of wording for error message
Adjust test for change of wording in error message
Change condition to follow rails idioms
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/tasks/database_tasks_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/tasks/database_tasks_test.rb b/activerecord/test/cases/tasks/database_tasks_test.rb index 5653fd83fd..baa41a3a47 100644 --- a/activerecord/test/cases/tasks/database_tasks_test.rb +++ b/activerecord/test/cases/tasks/database_tasks_test.rb @@ -350,6 +350,14 @@ module ActiveRecord ENV["VERBOSE"], ENV["VERSION"] = verbose, version end + def test_migrate_raise_error_on_empty_version + version = ENV["VERSION"] + ENV["VERSION"] = "" + assert_raise(RuntimeError, "Empty VERSION provided") { ActiveRecord::Tasks::DatabaseTasks.migrate } + ensure + ENV["VERSION"] = version + end + def test_migrate_clears_schema_cache_afterward ActiveRecord::Base.expects(:clear_cache!) ActiveRecord::Tasks::DatabaseTasks.migrate |