Sha256: 906b6a0bd974421e0a5f40a7f3782489a05fb22f0531596c1e612d26fc5a25c3

Contents?: true

Size: 1.53 KB

Versions: 15

Compression:

Stored size: 1.53 KB

Contents

# frozen_string_literal: true

RSpec.shared_examples 'Gumboot Foreign Keys' do
  RSpec.shared_examples 'gumboot fk' do
    let(:conn) do
      ActiveRecord::Base.connection
    end

    let(:foreign_key) do
      conn.foreign_keys(from_table).find do |key|
        key.options[:column] == column
      end
    end

    it 'has valid foreign key' do
      if conn.supports_foreign_keys?
        expect(foreign_key).to(be_truthy)
        expect(foreign_key.to_table).to eql to_table
      end
    end
  end

  context 'Permission' do
    context 'Roles' do
      include_examples 'gumboot fk' do
        let(:from_table) { 'permissions' }
        let(:to_table) { 'roles' }
        let(:column) { 'role_id' }
      end
    end
  end

  context 'API Subject' do
    context 'Roles' do
      include_examples 'gumboot fk' do
        let(:from_table) { 'api_subject_roles' }
        let(:to_table) { 'api_subjects' }
        let(:column) { 'api_subject_id' }
      end
    end
  end

  context 'Subject' do
    context 'Roles' do
      include_examples 'gumboot fk' do
        let(:from_table) { 'subject_roles' }
        let(:to_table) { 'subjects' }
        let(:column) { 'subject_id' }
      end
    end
  end

  context 'Roles' do
    let(:to_table) { 'roles' }
    let(:column) { 'role_id' }
    context 'Subjects' do
      include_examples 'gumboot fk' do
        let(:from_table) { 'subject_roles' }
      end
    end
    context 'API Subjects' do
      include_examples 'gumboot fk' do
        let(:from_table) { 'api_subject_roles' }
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
aaf-gumboot-2.6.3 lib/gumboot/shared_examples/foreign_keys.rb
aaf-gumboot-2.6.2 lib/gumboot/shared_examples/foreign_keys.rb
aaf-gumboot-2.6.1 lib/gumboot/shared_examples/foreign_keys.rb
aaf-gumboot-2.6.0 lib/gumboot/shared_examples/foreign_keys.rb
aaf-gumboot-2.5.1 lib/gumboot/shared_examples/foreign_keys.rb
aaf-gumboot-2.5.0 lib/gumboot/shared_examples/foreign_keys.rb
aaf-gumboot-2.4.0 lib/gumboot/shared_examples/foreign_keys.rb
aaf-gumboot-2.2.0 lib/gumboot/shared_examples/foreign_keys.rb
aaf-gumboot-2.1.4 lib/gumboot/shared_examples/foreign_keys.rb
aaf-gumboot-2.1.3 lib/gumboot/shared_examples/foreign_keys.rb
aaf-gumboot-2.1.1 lib/gumboot/shared_examples/foreign_keys.rb
aaf-gumboot-2.1.0 lib/gumboot/shared_examples/foreign_keys.rb
aaf-gumboot-2.0.1 lib/gumboot/shared_examples/foreign_keys.rb
aaf-gumboot-1.2.0 lib/gumboot/shared_examples/foreign_keys.rb
aaf-gumboot-1.1.0 lib/gumboot/shared_examples/foreign_keys.rb