Sha256: a67e0ccd771891dc7044c20c4dc6814918660fabac4ef925ff4cd2f07b904277

Contents?: true

Size: 925 Bytes

Versions: 7

Compression:

Stored size: 925 Bytes

Contents

# frozen_string_literal: true

require_relative '../../../../lib/declare_schema/schema_change/foreign_key_add'

RSpec.describe DeclareSchema::SchemaChange::ForeignKeyAdd do
  include_context 'prepare test app'

  let(:table_name) { 'users' }
  let(:parent_table_name) { 'organization' }
  let(:column_name) { :organization_id }
  let(:name) { 'on_organization_id' }
  subject { described_class.new(table_name, parent_table_name, column_name: column_name, name: name) }

  describe '#up/down' do
    describe '#up' do
      it 'responds with command' do
        expect(subject.up).to eq("add_foreign_key :#{table_name}, :#{parent_table_name}, column: #{column_name.to_sym.inspect}, name: #{name.to_sym.inspect}\n")
      end
    end

    describe '#down' do
      it 'responds with command' do
        expect(subject.down).to eq("remove_foreign_key :#{table_name}, name: #{name.to_sym.inspect}\n")
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
declare_schema-2.3.0 spec/lib/declare_schema/schema_change/foreign_key_add_spec.rb
declare_schema-2.3.0.pre.is.0 spec/lib/declare_schema/schema_change/foreign_key_add_spec.rb
declare_schema-2.2.1 spec/lib/declare_schema/schema_change/foreign_key_add_spec.rb
declare_schema-2.2.0.colin.1 spec/lib/declare_schema/schema_change/foreign_key_add_spec.rb
declare_schema-2.2.0 spec/lib/declare_schema/schema_change/foreign_key_add_spec.rb
declare_schema-2.1.0 spec/lib/declare_schema/schema_change/foreign_key_add_spec.rb
declare_schema-2.1.0.pre.1 spec/lib/declare_schema/schema_change/foreign_key_add_spec.rb