Sha256: d848caf786aacb151e314d90c2b0eb0c999eaad5dd88d2e50447f1cd801d9185

Contents?: true

Size: 1.41 KB

Versions: 28

Compression:

Stored size: 1.41 KB

Contents

require 'migration_spec_helper'
require_generator :active_record => :roles_migration

describe 'roles_migration_generator' do
  use_orm :active_record  
  use_helper :migration
  
  before :each do              
    setup_generator 'roles_migration_generator' do
      tests ActiveRecord::Generators::RolesMigrationGenerator
    end    
  end

  after :each do
  end


  it "should generate migration 'add_role_string_strategy' for role strategy 'role_string'" do    
    
    # class AddRoleStringStrategy < ActiveRecord::Migration
    #   def self.up           
    #     change_table :users do |t|
    #       t.string :role, :default => 'guest'
    #     end
    #   end
    # 
    #   def self.down
    #     change_table :users do |t|
    #       t.remove :role
    #     end
    #   end
    # end
    
    
    with_generator do |g|
      remove_migration :add_role_string_strategy
      g.run_generator [:user, %w{--strategy role_string}].args

      g.should generate_migration :add_role_string_strategy do |content|
        content.should have_up do |up|
          up.should have_change_table :users do |tbl_content|
            tbl_content.should have_add_column :role, :string
          end
        end

        content.should have_down do |down|
          down.should have_change_table :users do |tbl_content|
            tbl_content.should have_remove_column :role
          end
        end
      end
    end # with
  end
end 

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
roles_active_record-0.5.1 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.5.0 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.4.9 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.4.8 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.4.7 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.4.6.4 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.4.6.3 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.4.6.2 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.4.6.1 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.4.6 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.4.5 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.4.4 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.4.3 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.4.2 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.4.1 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.4.0 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.3.6 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.3.5 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.3.4 spec/roles_active_record/generators/roles_migration/role_string_spec.rb
roles_active_record-0.3.3 spec/roles_active_record/generators/roles_migration/role_string_spec.rb