summaryrefslogtreecommitdiff
path: root/spec/migrations/add_new_post_eoa_plans_spec.rb
blob: 02360d5a12d4b66a8b39df1404d4b601548b9d51 (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
# frozen_string_literal: true

require 'spec_helper'

require_migration!

RSpec.describe AddNewPostEoaPlans do
  let(:plans) { table(:plans) }

  subject(:migration) { described_class.new }

  describe '#up' do
    it 'creates the two new records' do
      expect { migration.up }.to change { plans.count }.by(2)

      new_plans = plans.last(2)
      expect(new_plans.map(&:name)).to contain_exactly('premium', 'ultimate')
    end
  end

  describe '#down' do
    it 'removes these two new records' do
      plans.create!(name: 'premium', title: 'Premium (Formerly Silver)')
      plans.create!(name: 'ultimate', title: 'Ultimate (Formerly Gold)')

      expect { migration.down }.to change { plans.count }.by(-2)

      expect(plans.find_by(name: 'premium')).to be_nil
      expect(plans.find_by(name: 'ultimate')).to be_nil
    end
  end
end