Sha256: 859908d49dd4456da70ca0e727033c1655a7e8f83b569fae31ebc8fd5f141c62

Contents?: true

Size: 864 Bytes

Versions: 6

Compression:

Stored size: 864 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
require 'stringio'

require 'models/post'

describe "Schema dump" do

  let(:dump) do
    stream = StringIO.new
    ActiveRecord::SchemaDumper.ignore_tables = []
    ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
    stream.string
  end

  it "shouldn't include :index option for index" do
    add_column(:author_id, :integer, :references => :users, :index => true) do
      dump.should_not match(/index => true/)
    end
  end
    
  protected
  def add_column(column_name, *args)
    table = Post.table_name
    ActiveRecord::Migration.suppress_messages do
      ActiveRecord::Migration.add_column(table, column_name, *args)
      Post.reset_column_information
      yield if block_given?
      ActiveRecord::Migration.remove_column(table, column_name)
    end
  end

end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
aspgems-foreign_key_migrations-2.0.0.beta2 spec/schema_dumper_spec.rb
automatic_foreign_key-1.3.0 spec/schema_dumper_spec.rb
aspgems-foreign_key_migrations-2.0.0.beta1 spec/schema_dumper_spec.rb
automatic_foreign_key-1.2.0 spec/schema_dumper_spec.rb
automatic_foreign_key-1.1.8 spec/schema_dumper_spec.rb
automatic_foreign_key-1.1.7 spec/schema_dumper_spec.rb