Sha256: bf42f264b9f7d31fa4ba3303f465553143ee556ef80b529f66608898025eae1d

Contents?: true

Size: 1.92 KB

Versions: 32

Compression:

Stored size: 1.92 KB

Contents

describe 'Ridgepole::Client#diff -> migrate' do
  context 'when database and definition are same (default unsigned / nothing -> unsigned:false)' do
    let(:actual_dsl) {
      <<-RUBY
        create_table "employee_clubs", force: true do |t|
          t.integer "emp_no",  unsigned: true, null: false
          t.integer "club_id",                 null: false
        end
      RUBY
    }

    let(:expected_dsl) {
      <<-RUBY
        create_table "employee_clubs", force: true do |t|
          t.integer "emp_no",  unsigned: true, null: false
          t.integer "club_id", unsigned: false,null: false
        end
      RUBY
    }

    before { subject.diff(actual_dsl).migrate }
    subject { client }

    it {
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_falsey
      expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
      delta.migrate
      expect(subject.dump).to eq expected_dsl.strip_heredoc.strip.gsub('unsigned: false,', '                ')
    }
  end

  context 'when database and definition are same (default null / unsigned:false -> nothing)' do
    let(:actual_dsl) {
      <<-RUBY
        create_table "employee_clubs", force: true do |t|
          t.integer "emp_no",  unsigned: true, null: false
          t.integer "club_id", unsigned: false,null: false
        end
      RUBY
    }

    let(:expected_dsl) {
      <<-RUBY
        create_table "employee_clubs", force: true do |t|
          t.integer "emp_no",  unsigned: true, null: false
          t.integer "club_id",                 null: false
        end
      RUBY
    }

    before { subject.diff(actual_dsl).migrate }
    subject { client }

    it {
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_falsey
      expect(subject.dump).to eq actual_dsl.strip_heredoc.strip.gsub('unsigned: false,', '                ')
      delta.migrate
      expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
    }
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
ridgepole-0.4.12 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.4.11.beta spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.4.10 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.4.10.beta spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.4.9 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.4.8 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.4.8.rc2 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.4.8.rc1 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.4.7 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.4.6 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.4.5 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.4.4 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.4.3 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.4.2 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.4.1 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.4.0 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.3.9 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.3.8 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.3.7 spec/migrate/migrate_same_default_unsigned_spec.rb
ridgepole-0.3.6 spec/migrate/migrate_same_default_unsigned_spec.rb