summaryrefslogtreecommitdiff
path: root/spec/migrations/migrate_protected_attribute_to_pending_builds_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 18:25:58 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 18:25:58 +0000
commita5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch)
treefb69158581673816a8cd895f9d352dcb3c678b1e /spec/migrations/migrate_protected_attribute_to_pending_builds_spec.rb
parentd16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff)
downloadgitlab-ce-a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4.tar.gz
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/migrations/migrate_protected_attribute_to_pending_builds_spec.rb')
-rw-r--r--spec/migrations/migrate_protected_attribute_to_pending_builds_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/migrations/migrate_protected_attribute_to_pending_builds_spec.rb b/spec/migrations/migrate_protected_attribute_to_pending_builds_spec.rb
new file mode 100644
index 00000000000..e838476a650
--- /dev/null
+++ b/spec/migrations/migrate_protected_attribute_to_pending_builds_spec.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20210610102413_migrate_protected_attribute_to_pending_builds.rb')
+
+RSpec.describe MigrateProtectedAttributeToPendingBuilds do
+ let(:namespaces) { table(:namespaces) }
+ let(:projects) { table(:projects) }
+ let(:queue) { table(:ci_pending_builds) }
+ let(:builds) { table(:ci_builds) }
+
+ before do
+ namespaces.create!(id: 123, name: 'sample', path: 'sample')
+ projects.create!(id: 123, name: 'sample', path: 'sample', namespace_id: 123)
+
+ builds.create!(id: 1, project_id: 123, status: 'pending', protected: false, type: 'Ci::Build')
+ builds.create!(id: 2, project_id: 123, status: 'pending', protected: true, type: 'Ci::Build')
+ builds.create!(id: 3, project_id: 123, status: 'pending', protected: false, type: 'Ci::Build')
+ builds.create!(id: 4, project_id: 123, status: 'pending', protected: true, type: 'Ci::Bridge')
+ builds.create!(id: 5, project_id: 123, status: 'success', protected: true, type: 'Ci::Build')
+
+ queue.create!(id: 1, project_id: 123, build_id: 1)
+ queue.create!(id: 2, project_id: 123, build_id: 2)
+ queue.create!(id: 3, project_id: 123, build_id: 3)
+ end
+
+ it 'updates entries that should be protected' do
+ migrate!
+
+ expect(queue.where(protected: true).count).to eq 1
+ expect(queue.find_by(protected: true).id).to eq 2
+ end
+end