summaryrefslogtreecommitdiff
path: root/spec/migrations
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-27 21:08:47 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-27 21:08:47 +0000
commite4ea43b2b85ad5f3115f00220601eb719705139a (patch)
tree1888a43f802e45ebb8dfed59595a790807777c6f /spec/migrations
parent390582e118752426acf5cb25ec99103d312d891c (diff)
downloadgitlab-ce-e4ea43b2b85ad5f3115f00220601eb719705139a.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/20200127090233_remove_invalid_issue_tracker_data_spec.rb59
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/migrations/20200127090233_remove_invalid_issue_tracker_data_spec.rb b/spec/migrations/20200127090233_remove_invalid_issue_tracker_data_spec.rb
new file mode 100644
index 00000000000..d1b1dfb1904
--- /dev/null
+++ b/spec/migrations/20200127090233_remove_invalid_issue_tracker_data_spec.rb
@@ -0,0 +1,59 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20200127090233_remove_invalid_issue_tracker_data.rb')
+
+describe RemoveInvalidIssueTrackerData, :migration do
+ let(:issue_tracker_data) { table(:issue_tracker_data) }
+ let(:services) { table(:services) }
+
+ let(:service) { services.create(id: 1) }
+ let(:data) do
+ {
+ service_id: service.id,
+ encrypted_issues_url: 'http:url.com',
+ encrypted_issues_url_iv: 'somevalue',
+ encrypted_new_issue_url: 'http:url.com',
+ encrypted_new_issue_url_iv: 'somevalue',
+ encrypted_project_url: 'username',
+ encrypted_project_url_iv: 'somevalue'
+ }
+ end
+
+ let!(:valid_data) { issue_tracker_data.create(data) }
+ let!(:empty_data) { issue_tracker_data.create(service_id: service.id) }
+ let!(:invalid_issues_url) do
+ data[:encrypted_issues_url_iv] = nil
+ issue_tracker_data.create(data)
+ end
+ let!(:missing_issues_url) do
+ data[:encrypted_issues_url] = ''
+ data[:encrypted_issues_url_iv] = nil
+ issue_tracker_data.create(data)
+ end
+ let!(:invalid_new_isue_url) do
+ data[:encrypted_new_issue_url_iv] = nil
+ issue_tracker_data.create(data)
+ end
+ let!(:missing_new_issue_url) do
+ data[:encrypted_new_issue_url] = ''
+ issue_tracker_data.create(data)
+ end
+ let!(:invalid_project_url) do
+ data[:encrypted_project_url_iv] = nil
+ issue_tracker_data.create(data)
+ end
+ let!(:missing_project_url) do
+ data[:encrypted_project_url] = nil
+ data[:encrypted_project_url_iv] = nil
+ issue_tracker_data.create(data)
+ end
+
+ it 'removes the invalid data' do
+ valid_data_records = [valid_data, empty_data, missing_issues_url, missing_new_issue_url, missing_project_url]
+
+ expect { migrate! }.to change { issue_tracker_data.count }.from(8).to(5)
+
+ expect(issue_tracker_data.all).to match_array(valid_data_records)
+ end
+end