diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-06 18:09:02 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-06 18:09:02 +0000 |
commit | 2d181003830956f5e690cce74be50bb4d96048f8 (patch) | |
tree | cd72c53f6cb3753fc1bd28521e89af66c420f08a /spec/services | |
parent | c79da5142f46e6e9187f75c329e2c81a8568c581 (diff) | |
download | gitlab-ce-2d181003830956f5e690cce74be50bb4d96048f8.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/members/mailgun/process_webhook_service_spec.rb | 72 | ||||
-rw-r--r-- | spec/services/pages/delete_service_spec.rb | 6 |
2 files changed, 6 insertions, 72 deletions
diff --git a/spec/services/members/mailgun/process_webhook_service_spec.rb b/spec/services/members/mailgun/process_webhook_service_spec.rb deleted file mode 100644 index 3b657c05bd8..00000000000 --- a/spec/services/members/mailgun/process_webhook_service_spec.rb +++ /dev/null @@ -1,72 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Members::Mailgun::ProcessWebhookService do - describe '#execute', :aggregate_failures do - let_it_be(:member) { create(:project_member, :invited) } - - let(:raw_invite_token) { member.raw_invite_token } - let(:payload) { { 'user-variables' => { ::Members::Mailgun::INVITE_EMAIL_TOKEN_KEY => raw_invite_token } } } - - subject(:service) { described_class.new(payload).execute } - - it 'marks the member invite email success as false' do - expect(Gitlab::AppLogger).to receive(:info).with(/^UPDATED MEMBER INVITE_EMAIL_SUCCESS/).and_call_original - - expect { service }.to change { member.reload.invite_email_success }.from(true).to(false) - end - - context 'when member can not be found' do - let(:raw_invite_token) { '_foobar_' } - - it 'does not change member status' do - expect(Gitlab::AppLogger).not_to receive(:info).with(/^UPDATED MEMBER INVITE_EMAIL_SUCCESS/) - - expect { service }.not_to change { member.reload.invite_email_success } - end - end - - context 'when invite token is not found in payload' do - let(:payload) { {} } - - it 'does not change member status and logs an error' do - expect(Gitlab::AppLogger).not_to receive(:info).with(/^UPDATED MEMBER INVITE_EMAIL_SUCCESS/) - expect(Gitlab::ErrorTracking).to receive(:track_exception).with( - an_instance_of(described_class::ProcessWebhookServiceError)) - - expect { service }.not_to change { member.reload.invite_email_success } - end - end - end - - describe '#should_process?' do - it 'processes permanent failures for member invite emails' do - payload = { 'event' => 'failed', 'severity' => 'permanent', 'tags' => [Members::Mailgun::INVITE_EMAIL_TAG] } - service = described_class.new(payload) - - expect(service.should_process?).to eq(true) - end - - it 'does not process temporary failures' do - payload = { 'event' => 'failed', 'severity' => 'temporary', 'tags' => [Members::Mailgun::INVITE_EMAIL_TAG] } - service = described_class.new(payload) - - expect(service.should_process?).to eq(false) - end - - it 'does not process non member invite emails' do - payload = { 'event' => 'failed', 'severity' => 'permanent', 'tags' => [] } - service = described_class.new(payload) - - expect(service.should_process?).to eq(false) - end - - it 'does not process other types of events' do - payload = { 'event' => 'delivered', 'tags' => [Members::Mailgun::INVITE_EMAIL_TAG] } - service = described_class.new(payload) - - expect(service.should_process?).to eq(false) - end - end -end diff --git a/spec/services/pages/delete_service_spec.rb b/spec/services/pages/delete_service_spec.rb index e02e8e72e0b..0c0b2c0431b 100644 --- a/spec/services/pages/delete_service_spec.rb +++ b/spec/services/pages/delete_service_spec.rb @@ -43,4 +43,10 @@ RSpec.describe Pages::DeleteService do service.execute end.to change { PagesDeployment.count }.by(-1) end + + it 'publishes a ProjectDeleted event with project id and namespace id' do + expected_data = { project_id: project.id, namespace_id: project.namespace_id } + + expect { service.execute }.to publish_event(Pages::PageDeletedEvent).with(expected_data) + end end |