Improved coverage for session_migration generator. [#3008 status:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
parent
c0f828ca4f
commit
3ea091e1cc
@ -13,7 +13,7 @@ def create_migration_file
|
||||
|
||||
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
|
||||
|
@ -24,9 +24,13 @@ def test_session_migration_with_given_name
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user