diff options
author | Matthew Draper <matthew@trebex.net> | 2016-03-25 00:11:53 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2016-03-25 00:11:53 +1030 |
commit | 00a0388adcb2a09cb811ee9659636a154c36bca5 (patch) | |
tree | 2ff43614ead7e934d4bb9e96b9c1da69cbf8012d /activerecord | |
parent | 878c2bbaaf21f88543e75d4a986652d128ea8448 (diff) | |
parent | cf570d7d0153283d2175b7330270d94291884864 (diff) | |
download | rails-00a0388adcb2a09cb811ee9659636a154c36bca5.tar.gz rails-00a0388adcb2a09cb811ee9659636a154c36bca5.tar.bz2 rails-00a0388adcb2a09cb811ee9659636a154c36bca5.zip |
Merge pull request #24295 from yui-knk/add_test_for_unknown_migration_version
Change for `ActiveRecord::Migration.[]` to raise `ArgumentError` inst…
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/migration_test.rb | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 4419a7b1e7..245c05f3e0 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -528,7 +528,7 @@ module ActiveRecord name = "V#{version.tr('.', '_')}" unless Compatibility.const_defined?(name) versions = Compatibility.constants.grep(/\AV[0-9_]+\z/).map { |s| s.to_s.delete('V').tr('_', '.').inspect } - raise "Unknown migration version #{version.inspect}; expected one of #{versions.sort.join(', ')}" + raise ArgumentError, "Unknown migration version #{version.inspect}; expected one of #{versions.sort.join(', ')}" end Compatibility.const_get(name) end diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 6a6250eec3..5a6d2ce80c 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -1107,4 +1107,7 @@ class CopyMigrationsTest < ActiveRecord::TestCase ActiveRecord::Base.logger = old end + def test_unknown_migration_version_should_raise_an_argument_error + assert_raise(ArgumentError) { ActiveRecord::Migration[1.0] } + end end |