Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-07 00:07:43 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-07 00:07:43 +0300
commit015663b70f1bcdae4483e38c2beac884f92da5b8 (patch)
tree6dd5a59c7f9a27c3cca22801ca30bf3dd8f9b401 /spec/migrations
parent5eb11b697d7ee280b0b5c2ff9a1850a3b5e9b7e3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/backfill_operations_feature_flags_active_spec.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/migrations/backfill_operations_feature_flags_active_spec.rb b/spec/migrations/backfill_operations_feature_flags_active_spec.rb
new file mode 100644
index 00000000000..ad69b776052
--- /dev/null
+++ b/spec/migrations/backfill_operations_feature_flags_active_spec.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'migrate', '20191213184609_backfill_operations_feature_flags_active.rb')
+
+describe BackfillOperationsFeatureFlagsActive, :migration do
+ let(:namespaces) { table(:namespaces) }
+ let(:projects) { table(:projects) }
+ let(:flags) { table(:operations_feature_flags) }
+
+ def setup
+ namespace = namespaces.create!(name: 'foo', path: 'foo')
+ project = projects.create!(namespace_id: namespace.id)
+
+ project
+ end
+
+ it 'executes successfully when there are no flags in the table' do
+ setup
+
+ disable_migrations_output { migrate! }
+
+ expect(flags.count).to eq(0)
+ end
+
+ it 'updates active to true' do
+ project = setup
+ flag = flags.create!(project_id: project.id, name: 'test_flag', active: false)
+
+ disable_migrations_output { migrate! }
+
+ expect(flag.reload.active).to eq(true)
+ end
+
+ it 'updates active to true for multiple flags' do
+ project = setup
+ flag_a = flags.create!(project_id: project.id, name: 'test_flag', active: false)
+ flag_b = flags.create!(project_id: project.id, name: 'other_flag', active: false)
+
+ disable_migrations_output { migrate! }
+
+ expect(flag_a.reload.active).to eq(true)
+ expect(flag_b.reload.active).to eq(true)
+ end
+
+ it 'leaves active true if it is already true' do
+ project = setup
+ flag = flags.create!(project_id: project.id, name: 'test_flag', active: true)
+
+ disable_migrations_output { migrate! }
+
+ expect(flag.reload.active).to eq(true)
+ end
+end