summaryrefslogtreecommitdiff
path: root/spec/migrations/fix_max_pages_size_spec.rb
blob: 97cf026df5c540a40f8f6827235947a28a97c96d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

require 'spec_helper'
require_migration!

RSpec.describe FixMaxPagesSize do
  let(:application_settings) { table(:application_settings) }
  let!(:default_setting) { application_settings.create! }
  let!(:max_possible_setting) { application_settings.create!(max_pages_size: described_class::MAX_SIZE) }
  let!(:higher_than_maximum_setting) { application_settings.create!(max_pages_size: described_class::MAX_SIZE + 1) }

  it 'correctly updates settings only if needed' do
    migrate!

    expect(default_setting.reload.max_pages_size).to eq(100)
    expect(max_possible_setting.reload.max_pages_size).to eq(described_class::MAX_SIZE)
    expect(higher_than_maximum_setting.reload.max_pages_size).to eq(described_class::MAX_SIZE)
  end
end