Sha256: 8c707a93634b592780b949d8660fd3ba4d3cc9c39ce33793e25d6e12d56cff7e

Contents?: true

Size: 722 Bytes

Versions: 17

Compression:

Stored size: 722 Bytes

Contents

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

describe "Foreign Key definition" do

  before(:all) do
    load_core_schema
  end

  let(:definition) { SchemaPlus::ActiveRecord::ConnectionAdapters::ForeignKeyDefinition.new("posts_user_fkey", :posts, :user, :users, :id) }

  it "it is dumped to sql with quoted values" do
    definition.to_sql.should == %Q{CONSTRAINT posts_user_fkey FOREIGN KEY (#{quote_column_name('user')}) REFERENCES #{quote_table_name('users')} (#{quote_column_name('id')})}
  end

  def quote_table_name(table)
    ActiveRecord::Base.connection.quote_table_name(table)
  end

  def quote_column_name(column)
    ActiveRecord::Base.connection.quote_column_name(column)
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
schema_plus-0.4.1 spec/foreign_key_definition_spec.rb
schema_plus-0.4.0 spec/foreign_key_definition_spec.rb
schema_plus-0.3.4 spec/foreign_key_definition_spec.rb
schema_plus-0.3.3 spec/foreign_key_definition_spec.rb
schema_plus-0.3.2 spec/foreign_key_definition_spec.rb
schema_plus-0.3.1 spec/foreign_key_definition_spec.rb
schema_plus-0.3.0 spec/foreign_key_definition_spec.rb
schema_plus-0.2.1 spec/foreign_key_definition_spec.rb
schema_plus-0.2.0 spec/foreign_key_definition_spec.rb
schema_plus-0.1.3 spec/foreign_key_definition_spec.rb
schema_plus-0.1.2 spec/foreign_key_definition_spec.rb
schema_plus-0.1.1 spec/foreign_key_definition_spec.rb
schema_plus-0.1.0 spec/foreign_key_definition_spec.rb
schema_plus-0.1.0.pre4 spec/foreign_key_definition_spec.rb
schema_plus-0.1.0.pre3 spec/foreign_key_definition_spec.rb
schema_plus-0.1.0.pre2 spec/foreign_key_definition_spec.rb
schema_plus-0.1.0.pre1 spec/foreign_key_definition_spec.rb