aboutsummaryrefslogblamecommitdiffstats
path: root/railties/test/generators/session_migration_generator_test.rb
blob: de28b4c75b7f90cd8abdf861885cb062df74cdf2 (plain) (tree)
1
2
3
4
5
6
                                           
                                                                        
 


                                                                 









                                                                                                               

                                                                        
                 



                                                                                

                                                               
     
   
require 'generators/generators_test_helper'
require 'generators/rails/session_migration/session_migration_generator'

class SessionMigrationGeneratorTest < Rails::Generators::TestCase
  include GeneratorsTestHelper

  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

  def test_session_migration_with_custom_table_name
    ActiveRecord::SessionStore::Session.table_name = "custom_table_name"
    run_generator
    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
  ensure
    ActiveRecord::SessionStore::Session.table_name = "sessions"
  end
end