diff options
author | José Valim <jose.valim@gmail.com> | 2009-08-09 00:20:03 +0200 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-08-08 23:42:18 +0100 |
commit | 3ea091e1cc4deab1410676d080dc1fcdc572d65f (patch) | |
tree | b46b8c16e9d5b3ee8df3629fd14b17472b618ecb | |
parent | c0f828ca4f3aa45a4c8ea8761183ad3854f0a13f (diff) | |
download | rails-3ea091e1cc4deab1410676d080dc1fcdc572d65f.tar.gz rails-3ea091e1cc4deab1410676d080dc1fcdc572d65f.tar.bz2 rails-3ea091e1cc4deab1410676d080dc1fcdc572d65f.zip |
Improved coverage for session_migration generator. [#3008 status:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
-rw-r--r-- | railties/lib/generators/active_record/session_migration/session_migration_generator.rb | 2 | ||||
-rw-r--r-- | railties/test/generators/session_migration_generator_test.rb | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/railties/lib/generators/active_record/session_migration/session_migration_generator.rb b/railties/lib/generators/active_record/session_migration/session_migration_generator.rb index d78b9d42b0..59c4792066 100644 --- a/railties/lib/generators/active_record/session_migration/session_migration_generator.rb +++ b/railties/lib/generators/active_record/session_migration/session_migration_generator.rb @@ -13,7 +13,7 @@ module ActiveRecord def session_table_name current_table_name = ActiveRecord::SessionStore::Session.table_name - if current_table_name == "sessions" || current_table_name == "session" + if ["sessions", "session"].include?(current_table_name) current_table_name = (ActiveRecord::Base.pluralize_table_names ? 'session'.pluralize : 'session') end current_table_name diff --git a/railties/test/generators/session_migration_generator_test.rb b/railties/test/generators/session_migration_generator_test.rb index a87eeb1e1a..57bd755a9a 100644 --- a/railties/test/generators/session_migration_generator_test.rb +++ b/railties/test/generators/session_migration_generator_test.rb @@ -24,9 +24,13 @@ class SessionMigrationGeneratorTest < GeneratorsTestCase assert_migration "db/migrate/create_session_table.rb", /class CreateSessionTable < ActiveRecord::Migration/ end - def test_session_migtions_with_custom_table_name + def test_session_migration_with_custom_table_name + ActiveRecord::SessionStore::Session.table_name = "custom_table_name" run_generator - assert_migration "db/migrate/add_session_table.rb", /class CreateSessionTable < ActiveRecord::Migration/ + assert_migration "db/migrate/add_sessions_table.rb" do |migration| + assert_match /class AddSessionsTable < ActiveRecord::Migration/, migration + assert_match /create_table :custom_table_name/, migration + end end protected |