diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-08-13 11:44:58 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-08-13 11:44:58 +0200 |
commit | ecfce561e415d99df48eebefc1b444dd53580d1a (patch) | |
tree | f4bf69fb7ab73b31b6a3005b88dd91249ae13dd8 /activerecord/test/cases/migration | |
parent | 82e28492e7c581cdeea904464a18eb11118f4ac0 (diff) | |
download | rails-ecfce561e415d99df48eebefc1b444dd53580d1a.tar.gz rails-ecfce561e415d99df48eebefc1b444dd53580d1a.tar.bz2 rails-ecfce561e415d99df48eebefc1b444dd53580d1a.zip |
`index_exists?` with `:name` checks specified columns.
[Yves Senn & Matthew Draper]
The column check was embodied in the defaul index name.
If the :name option was used, the specified columns were not verified at all.
Given:
```
assert connection.index_exists?(table_name, :foo_id, :name => :index_testings_on_yo_momma)
```
That index could have been defined on any field, not necessarily on `:foo_id`.
Diffstat (limited to 'activerecord/test/cases/migration')
-rw-r--r-- | activerecord/test/cases/migration/index_test.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration/index_test.rb b/activerecord/test/cases/migration/index_test.rb index 93c3bfae7a..ac932378fd 100644 --- a/activerecord/test/cases/migration/index_test.rb +++ b/activerecord/test/cases/migration/index_test.rb @@ -95,6 +95,12 @@ module ActiveRecord assert connection.index_exists?(:testings, [:foo, :bar]) end + def test_index_exists_with_custom_name_checks_columns + connection.add_index :testings, [:foo, :bar], name: "my_index" + assert connection.index_exists?(:testings, [:foo, :bar], name: "my_index") + assert_not connection.index_exists?(:testings, [:foo], name: "my_index") + end + def test_valid_index_options assert_raise ArgumentError do connection.add_index :testings, :foo, unqiue: true |