blob: ea1476b94a9cb9f0b1bd56b935fc17f03abbfff2 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe InsertDailyInvitesTrialPlanLimits, feature_category: :subgroups do
let(:plans) { table(:plans) }
let(:plan_limits) { table(:plan_limits) }
let!(:premium_trial_plan) { plans.create!(name: 'premium_trial') }
let!(:ultimate_trial_plan) { plans.create!(name: 'ultimate_trial') }
context 'when on gitlab.com' do
before do
allow(Gitlab).to receive(:com?).and_return(true)
end
it 'correctly migrates up and down' do
reversible_migration do |migration|
migration.before -> {
trial_plan_ids = [premium_trial_plan.id, ultimate_trial_plan.id]
expect(plan_limits.where(plan_id: trial_plan_ids).where.not(daily_invites: 0)).to be_empty
}
migration.after -> {
expect(plan_limits.pluck(:plan_id, :daily_invites))
.to contain_exactly([premium_trial_plan.id, 50], [ultimate_trial_plan.id, 50])
}
end
end
end
context 'when on self-managed' do
before do
allow(Gitlab).to receive(:com?).and_return(false)
end
it 'correctly migrates up and down' do
reversible_migration do |migration|
trial_plan_ids = [premium_trial_plan.id, ultimate_trial_plan.id]
migration.before -> {
expect(plan_limits.where(plan_id: trial_plan_ids).where.not(daily_invites: 0)).to be_empty
}
migration.after -> {
expect(plan_limits.where(plan_id: trial_plan_ids).where.not(daily_invites: 0)).to be_empty
}
end
end
end
end
|