2009-06-28 07:16:14 -04:00
|
|
|
require 'generators/generators_test_helper'
|
2010-03-23 08:40:19 -04:00
|
|
|
require 'rails/generators/rails/session_migration/session_migration_generator'
|
2009-06-28 07:16:14 -04:00
|
|
|
|
2010-01-18 18:07:11 -05:00
|
|
|
class SessionMigrationGeneratorTest < Rails::Generators::TestCase
|
|
|
|
include GeneratorsTestHelper
|
|
|
|
|
2009-06-28 07:16:14 -04:00
|
|
|
def test_session_migration_with_default_name
|
|
|
|
run_generator
|
|
|
|
assert_migration "db/migrate/add_sessions_table.rb", /class AddSessionsTable < ActiveRecord::Migration/
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_session_migration_with_given_name
|
|
|
|
run_generator ["create_session_table"]
|
|
|
|
assert_migration "db/migrate/create_session_table.rb", /class CreateSessionTable < ActiveRecord::Migration/
|
|
|
|
end
|
|
|
|
|
2009-08-08 18:20:03 -04:00
|
|
|
def test_session_migration_with_custom_table_name
|
|
|
|
ActiveRecord::SessionStore::Session.table_name = "custom_table_name"
|
2009-08-08 17:06:45 -04:00
|
|
|
run_generator
|
2009-08-08 18:20:03 -04:00
|
|
|
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
|
2009-08-10 12:29:20 -04:00
|
|
|
ensure
|
|
|
|
ActiveRecord::SessionStore::Session.table_name = "sessions"
|
2009-08-08 17:06:45 -04:00
|
|
|
end
|
2009-06-28 07:16:14 -04:00
|
|
|
end
|