summaryrefslogtreecommitdiff
path: root/spec/migrations
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-14 06:09:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-14 06:09:14 +0000
commit8c558095790d0b9ae67344a05975f1f84f8df837 (patch)
tree786c71e2d3d57c18ef4917e83423d0fcf609a70a /spec/migrations
parent8957ace3159e5369a700a77614493ed6a8a98f93 (diff)
downloadgitlab-ce-8c558095790d0b9ae67344a05975f1f84f8df837.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/delete_template_project_services_spec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/migrations/delete_template_project_services_spec.rb b/spec/migrations/delete_template_project_services_spec.rb
new file mode 100644
index 00000000000..3c6709ec310
--- /dev/null
+++ b/spec/migrations/delete_template_project_services_spec.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'migrate', '20200305151736_delete_template_project_services.rb')
+
+describe DeleteTemplateProjectServices, :migration do
+ let(:services) { table(:services) }
+ let(:project) { table(:projects).create!(namespace_id: 1) }
+
+ before do
+ services.create!(template: true, project_id: project.id)
+ services.create!(template: true)
+ services.create!(template: false, project_id: project.id)
+ end
+
+ it 'deletes services when template and attached to a project' do
+ expect { migrate! }.to change { services.where(template: true, project_id: project.id).count }.from(1).to(0)
+ .and not_change { services.where(template: true, project_id: nil).count }
+ .and not_change { services.where(template: false).where.not(project_id: nil).count }
+ end
+end