diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-12 21:06:57 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-12 21:06:57 +0300 |
commit | 6d31b8f052d30b7e55128d17b66bceed8c6065a9 (patch) | |
tree | ca428cf6145af7cfaada94378e66bd5e7cc5a429 /spec/migrations/move_limits_from_plans_spec.rb | |
parent | 69944ffb68788d190e81ff7e33db5dcb6c903184 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations/move_limits_from_plans_spec.rb')
-rw-r--r-- | spec/migrations/move_limits_from_plans_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/migrations/move_limits_from_plans_spec.rb b/spec/migrations/move_limits_from_plans_spec.rb new file mode 100644 index 00000000000..693d6ecb2c1 --- /dev/null +++ b/spec/migrations/move_limits_from_plans_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'migrate', '20191030152934_move_limits_from_plans.rb') + +describe MoveLimitsFromPlans, :migration do + let(:plans) { table(:plans) } + let(:plan_limits) { table(:plan_limits) } + + let!(:early_adopter_plan) { plans.create(name: 'early_adopter', title: 'Early adopter', active_pipelines_limit: 10, pipeline_size_limit: 11, active_jobs_limit: 12) } + let!(:gold_plan) { plans.create(name: 'gold', title: 'Gold', active_pipelines_limit: 20, pipeline_size_limit: 21, active_jobs_limit: 22) } + let!(:silver_plan) { plans.create(name: 'silver', title: 'Silver', active_pipelines_limit: 30, pipeline_size_limit: 31, active_jobs_limit: 32) } + let!(:bronze_plan) { plans.create(name: 'bronze', title: 'Bronze', active_pipelines_limit: 40, pipeline_size_limit: 41, active_jobs_limit: 42) } + let!(:free_plan) { plans.create(name: 'free', title: 'Free', active_pipelines_limit: 50, pipeline_size_limit: 51, active_jobs_limit: 52) } + let!(:other_plan) { plans.create(name: 'other', title: 'Other', active_pipelines_limit: nil, pipeline_size_limit: nil, active_jobs_limit: 0) } + + describe 'migrate' do + it 'populates plan_limits from all the records in plans' do + expect { migrate! }.to change { plan_limits.count }.by 6 + end + + it 'copies plan limits and plan.id into to plan_limits table' do + migrate! + + new_data = plan_limits.pluck(:plan_id, :ci_active_pipelines, :ci_pipeline_size, :ci_active_jobs) + expected_data = [ + [early_adopter_plan.id, 10, 11, 12], + [gold_plan.id, 20, 21, 22], + [silver_plan.id, 30, 31, 32], + [bronze_plan.id, 40, 41, 42], + [free_plan.id, 50, 51, 52], + [other_plan.id, 0, 0, 0] + ] + expect(new_data).to contain_exactly(*expected_data) + end + end +end |