diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-11-20 17:37:54 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-11-20 17:37:54 -0800 |
commit | 3e92806357543cdbabad813884a591fca69193c2 (patch) | |
tree | 64f1f65b18399df4232740342455383eedc6fc85 /activerecord/test/cases | |
parent | ee80e22f03b36f5e2c35288226c66a44e2e722e2 (diff) | |
download | rails-3e92806357543cdbabad813884a591fca69193c2.tar.gz rails-3e92806357543cdbabad813884a591fca69193c2.tar.bz2 rails-3e92806357543cdbabad813884a591fca69193c2.zip |
raise a better exception for renaming long indexes
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/migration/index_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration/index_test.rb b/activerecord/test/cases/migration/index_test.rb index ac932378fd..b23b9a679f 100644 --- a/activerecord/test/cases/migration/index_test.rb +++ b/activerecord/test/cases/migration/index_test.rb @@ -36,6 +36,20 @@ module ActiveRecord assert connection.index_name_exists?(table_name, 'new_idx', true) end + def test_rename_index_too_long + too_long_index_name = good_index_name + 'x' + # keep the names short to make Oracle and similar behave + connection.add_index(table_name, [:foo], :name => 'old_idx') + e = assert_raises(ArgumentError) { + connection.rename_index(table_name, 'old_idx', too_long_index_name) + } + assert_match(/too long; the limit is #{connection.allowed_index_name_length} characters/, e.message) + + # if the adapter doesn't support the indexes call, pick defaults that let the test pass + assert connection.index_name_exists?(table_name, 'old_idx', false) + end + + def test_double_add_index connection.add_index(table_name, [:foo], :name => 'some_idx') assert_raises(ArgumentError) { |