Sha256: 2de9db44d95b4b8f07249dbdd85f24541c91a79bae6325b9e196a4bb78a91992

Contents?: true

Size: 1.97 KB

Versions: 11

Compression:

Stored size: 1.97 KB

Contents

describe 'Ridgepole::Client#diff -> migrate' do
  context 'when change float column' do
    let(:actual_dsl) do
      erbh(<<-ERB)
        create_table "salaries", id: false, force: :cascade do |t|
          t.integer "emp_no", null: false
          t.float   "salary", limit: 24, null: false
          t.date    "from_date", null: false
          t.date    "to_date", null: false
        end
      ERB
    end

    let(:expected_dsl) do
      <<-RUBY
        create_table "salaries", id: false, force: :cascade do |t|
          t.integer "emp_no", null: false
          t.float   "salary", null: false
          t.date    "from_date", null: false
          t.date    "to_date", null: false
        end
      RUBY
    end

    before { subject.diff(actual_dsl).migrate }
    subject { client(default_float_limit: 0) }

    it {
      delta = subject.diff(expected_dsl)

      if condition('< 5.2.0.beta2')
        expect(delta.differ?).to be_truthy
        expect(subject.dump).to match_ruby actual_dsl
        delta.migrate
        expect(subject.dump).to match_ruby actual_dsl
      else
        expect(delta.differ?).to be_falsy
      end
    }
  end

  context 'when change float column (no change)' do
    let(:actual_dsl) do
      <<-RUBY
        create_table "salaries", id: false, force: :cascade do |t|
          t.integer "emp_no", null: false
          t.float   "salary", limit: 24, null: false
          t.date    "from_date", null: false
          t.date    "to_date", null: false
        end
      RUBY
    end

    let(:expected_dsl) do
      <<-RUBY
        create_table "salaries", id: false, force: :cascade do |t|
          t.integer "emp_no", null: false
          t.float   "salary", null: false
          t.date    "from_date", null: false
          t.date    "to_date", null: false
        end
      RUBY
    end

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

    it {
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_falsey
    }
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ridgepole-0.8.0.rc1 spec/mysql/migrate/migrate_change_column_float_spec.rb
ridgepole-0.7.7 spec/mysql/migrate/migrate_change_column_float_spec.rb
ridgepole-0.7.6 spec/mysql/migrate/migrate_change_column_float_spec.rb
ridgepole-0.7.5 spec/mysql/migrate/migrate_change_column_float_spec.rb
ridgepole-0.7.5.beta3 spec/mysql/migrate/migrate_change_column_float_spec.rb
ridgepole-0.7.5.beta2 spec/mysql/migrate/migrate_change_column_float_spec.rb
ridgepole-0.7.5.beta spec/mysql/migrate/migrate_change_column_float_spec.rb
ridgepole-0.7.4 spec/mysql/migrate/migrate_change_column_float_spec.rb
ridgepole-0.7.3 spec/mysql/migrate/migrate_change_column_float_spec.rb
ridgepole-0.7.3.beta3 spec/mysql/migrate/migrate_change_column_float_spec.rb
ridgepole-0.7.3.beta2 spec/mysql/migrate/migrate_change_column_float_spec.rb