diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2012-07-18 00:16:39 -0700 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2012-07-18 00:16:39 -0700 |
commit | 58ccc9f6c5d261f7c1305d822b16447ac3d286b3 (patch) | |
tree | f47e5097d83b04464904fa56d0f65bc91b521fc8 /activerecord/test/cases | |
parent | 17b6fa877752c217a9171b7f420bc86d55fddcbc (diff) | |
parent | 211d88b71b3df2ae161b23579a79f8e937132388 (diff) | |
download | rails-58ccc9f6c5d261f7c1305d822b16447ac3d286b3.tar.gz rails-58ccc9f6c5d261f7c1305d822b16447ac3d286b3.tar.bz2 rails-58ccc9f6c5d261f7c1305d822b16447ac3d286b3.zip |
Merge pull request #7028 from lexmag/join_table_indexes
Add indexes to create_join_table method
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/migration/create_join_table_test.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/activerecord/test/cases/migration/create_join_table_test.rb b/activerecord/test/cases/migration/create_join_table_test.rb index 8b91b3bc92..cd1b0e8b47 100644 --- a/activerecord/test/cases/migration/create_join_table_test.rb +++ b/activerecord/test/cases/migration/create_join_table_test.rb @@ -42,22 +42,36 @@ module ActiveRecord end def test_create_join_table_with_the_table_name - connection.create_join_table :artists, :musics, :table_name => :catalog + connection.create_join_table :artists, :musics, table_name: :catalog assert_equal %w(artist_id music_id), connection.columns(:catalog).map(&:name).sort end def test_create_join_table_with_the_table_name_as_string - connection.create_join_table :artists, :musics, :table_name => 'catalog' + connection.create_join_table :artists, :musics, table_name: 'catalog' assert_equal %w(artist_id music_id), connection.columns(:catalog).map(&:name).sort end def test_create_join_table_with_column_options - connection.create_join_table :artists, :musics, :column_options => {:null => true} + connection.create_join_table :artists, :musics, column_options: {null: true} assert_equal [true, true], connection.columns(:artists_musics).map(&:null) end + + def test_create_join_table_without_indexes + connection.create_join_table :artists, :musics + + assert connection.indexes(:artists_musics).blank? + end + + def test_create_join_table_with_index + connection.create_join_table :artists, :musics do |t| + t.index [:artist_id, :music_id] + end + + assert_equal [%w(artist_id music_id)], connection.indexes(:artists_musics).map(&:columns) + end end end end |