diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-27 21:08:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-27 21:08:14 +0300 |
commit | ab801bd018f129b2c2f7ebe0de677728582c66f0 (patch) | |
tree | 017d87f33afadcbc15f6570abaa08c53ed4bdefd /spec/migrations | |
parent | 4d5ee2b81486df708e04a0e32ec2ea58b0e5ed5e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/backfill_status_page_published_incidents_spec.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/migrations/backfill_status_page_published_incidents_spec.rb b/spec/migrations/backfill_status_page_published_incidents_spec.rb new file mode 100644 index 00000000000..ccdc8be4168 --- /dev/null +++ b/spec/migrations/backfill_status_page_published_incidents_spec.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20200421195234_backfill_status_page_published_incidents.rb') + +describe BackfillStatusPagePublishedIncidents, :migration do + subject(:migration) { described_class.new } + + describe '#up' do + let(:projects) { table(:projects) } + let(:status_page_settings) { table(:status_page_settings) } + let(:issues) { table(:issues) } + let(:incidents) { table(:status_page_published_incidents) } + + let(:namespace) { table(:namespaces).create!(name: 'gitlab', path: 'gitlab') } + let(:project_without_status_page) { projects.create!(namespace_id: namespace.id) } + let(:enabled_project) { projects.create!(namespace_id: namespace.id) } + let(:disabled_project) { projects.create!(namespace_id: namespace.id) } + + let!(:enabled_setting) { status_page_settings.create!(enabled: true, project_id: enabled_project.id, **status_page_setting_attrs) } + let!(:disabled_setting) { status_page_settings.create!(enabled: false, project_id: disabled_project.id, **status_page_setting_attrs) } + + let!(:published_issue) { issues.create!(confidential: false, project_id: enabled_project.id) } + let!(:nonpublished_issue_1) { issues.create!(confidential: true, project_id: enabled_project.id) } + let!(:nonpublished_issue_2) { issues.create!(confidential: false, project_id: disabled_project.id) } + let!(:nonpublished_issue_3) { issues.create!(confidential: false, project_id: project_without_status_page.id) } + + let(:current_time) { Time.current.change(usec: 0) } + let(:status_page_setting_attrs) do + { + aws_s3_bucket_name: 'bucket', + aws_region: 'region', + aws_access_key: 'key', + encrypted_aws_secret_key: 'abc123', + encrypted_aws_secret_key_iv: 'abc123' + } + end + + it 'creates a StatusPage::PublishedIncident record for each published issue' do + Timecop.freeze(current_time) do + expect(incidents.all).to be_empty + + migrate! + + incident = incidents.first + + expect(incidents.count).to eq(1) + expect(incident.issue_id).to eq(published_issue.id) + expect(incident.created_at).to eq(current_time) + expect(incident.updated_at).to eq(current_time) + end + end + end +end |