diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-17 15:08:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-17 15:08:11 +0300 |
commit | badb9c1deacbea601b02f88811b7e123589d9251 (patch) | |
tree | f4b4f85db49a8c9fc9bd6233ed9f7862c9de8ded /spec/migrations | |
parent | 5bd24a54ef4ce3a38a860eb53b66d062c2382971 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/insert_project_hooks_plan_limits_spec.rb | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/spec/migrations/insert_project_hooks_plan_limits_spec.rb b/spec/migrations/insert_project_hooks_plan_limits_spec.rb new file mode 100644 index 00000000000..abc2ccd0507 --- /dev/null +++ b/spec/migrations/insert_project_hooks_plan_limits_spec.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'migrate', '20191216183532_insert_project_hooks_plan_limits.rb') + +describe InsertProjectHooksPlanLimits, :migration do + let(:migration) { described_class.new } + let(:plans) { table(:plans) } + let(:plan_limits) { table(:plan_limits) } + + before do + plans.create(id: 34, name: 'free') + plans.create(id: 2, name: 'bronze') + plans.create(id: 3, name: 'silver') + plans.create(id: 4, name: 'gold') + plan_limits.create(plan_id: 34, ci_active_jobs: 5) + end + + context 'when on Gitlab.com' do + before do + expect(Gitlab).to receive(:com?).at_most(:twice).and_return(true) + end + + describe '#up' do + it 'updates the project_hooks plan limits' do + migration.up + + expect(plan_limits.pluck(:plan_id, :project_hooks, :ci_active_jobs)) + .to match_array([[34, 10, 5], [2, 20, 0], [3, 30, 0], [4, 100, 0]]) + end + end + + describe '#down' do + it 'updates the project_hooks plan limits to 0' do + migration.up + migration.down + + expect(plan_limits.pluck(:plan_id, :project_hooks, :ci_active_jobs)) + .to match_array([[34, 0, 5], [2, 0, 0], [3, 0, 0], [4, 0, 0]]) + end + end + end + + context 'when on self-hosted' do + before do + expect(Gitlab).to receive(:com?).and_return(false) + end + + describe '#up' do + it 'does not update the plan limits' do + migration.up + + expect(plan_limits.pluck(:plan_id, :project_hooks, :ci_active_jobs)) + .to match_array([[34, 0, 5]]) + end + end + + describe '#down' do + it 'does not update the plan limits' do + migration.down + + expect(plan_limits.pluck(:plan_id, :project_hooks, :ci_active_jobs)) + .to match_array([[34, 0, 5]]) + end + end + end +end |