diff options
author | Michał Łomnicki <michal.lomnicki@gmail.com> | 2011-02-01 23:27:26 +0100 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-02-01 22:50:51 -0200 |
commit | 4e390720178889c773adb12ea1f073bc035fbe67 (patch) | |
tree | 9604ba568b7d69b0f4397ff7c51a91cd567e83b7 /railties/test/generators | |
parent | 5b42e9660201fc721075d2bfbe13edb0014dbde2 (diff) | |
download | rails-4e390720178889c773adb12ea1f073bc035fbe67.tar.gz rails-4e390720178889c773adb12ea1f073bc035fbe67.tar.bz2 rails-4e390720178889c773adb12ea1f073bc035fbe67.zip |
Configurable generation of add_index for references columns
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'railties/test/generators')
-rw-r--r-- | railties/test/generators/model_generator_test.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/railties/test/generators/model_generator_test.rb b/railties/test/generators/model_generator_test.rb index b86859666e..6b2fd8b9ee 100644 --- a/railties/test/generators/model_generator_test.rb +++ b/railties/test/generators/model_generator_test.rb @@ -203,4 +203,45 @@ class ModelGeneratorTest < Rails::Generators::TestCase content = capture(:stderr){ run_generator ["object"] } assert_match /The name 'Object' is either already used in your application or reserved/, content end + + def test_index_is_added_for_belongs_to_association + run_generator ["account", "supplier:belongs_to"] + + assert_migration "db/migrate/create_accounts.rb" do |m| + assert_method :change, m do |up| + assert_match /add_index/, up + end + end + end + + def test_index_is_added_for_references_association + run_generator ["account", "supplier:references"] + + assert_migration "db/migrate/create_accounts.rb" do |m| + assert_method :change, m do |up| + assert_match /add_index/, up + end + end + end + + def test_index_is_skipped_for_belongs_to_association + run_generator ["account", "supplier:belongs_to", "--no-indexes"] + + assert_migration "db/migrate/create_accounts.rb" do |m| + assert_method :change, m do |up| + assert_no_match /add_index/, up + end + end + end + + def test_index_is_skipped_for_references_association + run_generator ["account", "supplier:references", "--no-indexes"] + + assert_migration "db/migrate/create_accounts.rb" do |m| + assert_method :change, m do |up| + assert_no_match /add_index/, up + end + end + end + end |