aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators/migration_generator_test.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@plataformatec.com.br>2012-07-18 00:16:39 -0700
committerJosé Valim <jose.valim@plataformatec.com.br>2012-07-18 00:16:39 -0700
commit58ccc9f6c5d261f7c1305d822b16447ac3d286b3 (patch)
treef47e5097d83b04464904fa56d0f65bc91b521fc8 /railties/test/generators/migration_generator_test.rb
parent17b6fa877752c217a9171b7f420bc86d55fddcbc (diff)
parent211d88b71b3df2ae161b23579a79f8e937132388 (diff)
downloadrails-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 'railties/test/generators/migration_generator_test.rb')
-rw-r--r--railties/test/generators/migration_generator_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/railties/test/generators/migration_generator_test.rb b/railties/test/generators/migration_generator_test.rb
index 86e3793289..9f9cd9c9fc 100644
--- a/railties/test/generators/migration_generator_test.rb
+++ b/railties/test/generators/migration_generator_test.rb
@@ -167,6 +167,19 @@ class MigrationGeneratorTest < Rails::Generators::TestCase
end
end
+ def test_create_join_table_migration
+ migration = "add_media_join_table"
+ run_generator [migration, "artists", "musics:uniq"]
+
+ assert_migration "db/migrate/#{migration}.rb" do |content|
+ assert_method :change, content do |up|
+ assert_match(/create_join_table :artists, :musics/, up)
+ assert_match(/# t.index \[:artist_id, :music_id\]/, up)
+ assert_match(/ t.index \[:music_id, :artist_id\], unique: true/, up)
+ end
+ end
+ end
+
def test_should_create_empty_migrations_if_name_not_start_with_add_or_remove
migration = "create_books"
run_generator [migration, "title:string", "content:text"]