summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-17 09:06:11 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-17 09:06:11 +0000
commite567b4c2df7dc4085d213db029eff6b6fcde0152 (patch)
tree801718b86d32bdd82a3cd90760e06a4d7a51b71d /spec
parent42b933efc3384386c1991daca1a6d58160f70176 (diff)
downloadgitlab-ce-e567b4c2df7dc4085d213db029eff6b6fcde0152.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/migrations/migrate_code_owner_approval_status_to_protected_branches_in_batches_spec.rb63
1 files changed, 63 insertions, 0 deletions
diff --git a/spec/migrations/migrate_code_owner_approval_status_to_protected_branches_in_batches_spec.rb b/spec/migrations/migrate_code_owner_approval_status_to_protected_branches_in_batches_spec.rb
new file mode 100644
index 00000000000..67ac40d4d39
--- /dev/null
+++ b/spec/migrations/migrate_code_owner_approval_status_to_protected_branches_in_batches_spec.rb
@@ -0,0 +1,63 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20190827102026_migrate_code_owner_approval_status_to_protected_branches_in_batches.rb')
+
+describe MigrateCodeOwnerApprovalStatusToProtectedBranchesInBatches, :migration do
+ let(:namespaces) { table(:namespaces) }
+ let(:projects) { table(:projects) }
+ let(:protected_branches) { table(:protected_branches) }
+
+ let(:namespace) do
+ namespaces.create!(
+ path: 'gitlab-instance-administrators',
+ name: 'GitLab Instance Administrators'
+ )
+ end
+
+ let(:project) do
+ projects.create!(
+ namespace_id: namespace.id,
+ name: 'GitLab Instance Administration'
+ )
+ end
+
+ let!(:protected_branch_1) do
+ protected_branches.create!(
+ name: "branch name",
+ project_id: project.id
+ )
+ end
+
+ describe '#up' do
+ context "when there's no projects needing approval" do
+ it "doesn't change any protected branch records" do
+ expect { migrate! }
+ .not_to change { ProtectedBranch.where(code_owner_approval_required: true).count }
+ end
+ end
+
+ context "when there's a project needing approval" do
+ let!(:project_needing_approval) do
+ projects.create!(
+ namespace_id: namespace.id,
+ name: 'GitLab Instance Administration',
+ merge_requests_require_code_owner_approval: true
+ )
+ end
+
+ let!(:protected_branch_2) do
+ protected_branches.create!(
+ name: "branch name",
+ project_id: project_needing_approval.id
+ )
+ end
+
+ it "changes N protected branch records" do
+ expect { migrate! }
+ .to change { ProtectedBranch.where(code_owner_approval_required: true).count }
+ .by(1)
+ end
+ end
+ end
+end