summaryrefslogtreecommitdiff
path: root/spec/migrations/change_default_value_for_dsa_key_restriction_spec.rb
blob: 699708ad1d468f83a4b5ee3ebb2e7a32467943d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

require 'spec_helper'
require Rails.root.join('db', 'migrate', '20180531220618_change_default_value_for_dsa_key_restriction.rb')

describe ChangeDefaultValueForDsaKeyRestriction, :migration do
  let(:application_settings) { table(:application_settings) }

  before do
    application_settings.create!
  end

  it 'changes the default value for dsa_key_restriction' do
    expect(application_settings.first.dsa_key_restriction).to eq(0)

    migrate!

    application_settings.reset_column_information
    new_setting = application_settings.create!

    expect(application_settings.count).to eq(2)
    expect(new_setting.dsa_key_restriction).to eq(-1)
  end

  it 'changes the existing setting' do
    setting = application_settings.last

    expect(setting.dsa_key_restriction).to eq(0)

    migrate!

    expect(application_settings.count).to eq(1)
    expect(setting.reload.dsa_key_restriction).to eq(-1)
  end
end