Sha256: b1220fcd5fa45247c41550267c9b2bad461d5f983d2ac0979c1b43450b62cdf4

Contents?: true

Size: 1.61 KB

Versions: 17

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

describe 'Ridgepole::Client#diff -> migrate' do
  context 'when change fk' do
    let(:actual_dsl) do
      erbh(<<-ERB)
        create_table "parent", force: :cascade do |t|
        end

        create_table "child", force: :cascade do |t|
          t.integer "parent_id"
          t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
        end

        add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc", on_delete: :cascade
      ERB
    end

    let(:sorted_actual_dsl) do
      erbh(<<-ERB)
        create_table "child", force: :cascade do |t|
          t.integer "parent_id"
          t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
        end

        create_table "parent", force: :cascade do |t|
        end

        add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc", on_delete: :cascade
      ERB
    end

    let(:expected_dsl) do
      erbh(<<-ERB)
        create_table "child", force: :cascade do |t|
          t.integer "parent_id"
          t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
        end

        create_table "parent", force: :cascade do |t|
        end

        add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
      ERB
    end

    before { subject.diff(actual_dsl).migrate }

    subject { client(dump_with_default_fk_name: true) }

    it {
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_truthy
      expect(subject.dump).to match_fuzzy sorted_actual_dsl
      delta.migrate
      expect(subject.dump).to match_ruby expected_dsl
    }
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ridgepole-0.8.13 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.9.0.beta spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.8.12 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.8.11 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.8.10 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.8.9 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.8.8 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.8.7 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.8.6 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.8.5 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.8.4 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.8.3 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.8.2 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.8.1 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.8.0 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.8.0.rc2 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.8 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb