Commit 6e74ac9f authored by Imre Farkas's avatar Imre Farkas

Merge branch '201855-rename-slackmattermost-notifier' into 'master'

Move SlackMattermost::Notifier to Integrations namespace

See merge request gitlab-org/gitlab!62937
parents a90fef24 72222e9f
......@@ -722,7 +722,6 @@ RSpec/EmptyLineAfterFinalLetItBe:
- spec/services/wiki_pages/event_create_service_spec.rb
- spec/support/shared_examples/graphql/design_fields_shared_examples.rb
- spec/support/shared_examples/graphql/mutations/set_assignees_shared_examples.rb
- spec/support/shared_examples/models/slack_mattermost_notifications_shared_examples.rb
- spec/support/shared_examples/quick_actions/issuable/issuable_quick_actions_shared_examples.rb
- spec/support/shared_examples/services/container_registry_auth_service_shared_examples.rb
- spec/support/shared_examples/services/packages_shared_examples.rb
......@@ -2917,5 +2916,4 @@ Style/RegexpLiteralMixedPreserve:
- 'spec/support/helpers/grafana_api_helpers.rb'
- 'spec/support/helpers/query_recorder.rb'
- 'spec/support/helpers/require_migration.rb'
- 'spec/support/shared_examples/models/slack_mattermost_notifications_shared_examples.rb'
- 'spec/views/layouts/_head.html.haml_spec.rb'
# frozen_string_literal: true
module SlackMattermost
module Notifier
module Integrations
module SlackMattermostNotifier
private
def notify(message, opts)
......
......@@ -2,7 +2,7 @@
module Integrations
class Mattermost < BaseChatNotification
include SlackMattermost::Notifier
include SlackMattermostNotifier
include ActionView::Helpers::UrlHelper
def title
......
......@@ -2,7 +2,7 @@
module Integrations
class Slack < BaseChatNotification
include SlackMattermost::Notifier
include SlackMattermostNotifier
extend ::Gitlab::Utils::Override
SUPPORTED_EVENTS_FOR_USAGE_LOG = %w[
......
......@@ -3,5 +3,5 @@
require 'spec_helper'
RSpec.describe Integrations::Mattermost do
it_behaves_like "slack or mattermost notifications", "Mattermost"
it_behaves_like Integrations::SlackMattermostNotifier, "Mattermost"
end
......@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe Integrations::Slack do
it_behaves_like "slack or mattermost notifications", 'Slack'
it_behaves_like Integrations::SlackMattermostNotifier, "Slack"
describe '#execute' do
before do
......
# frozen_string_literal: true
RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
RSpec.shared_examples Integrations::SlackMattermostNotifier do |service_name|
include StubRequests
let(:chat_service) { described_class.new }
let(:webhook_url) { 'https://example.gitlab.com' }
def execute_with_options(options)
receive(:new).with(webhook_url, options.merge(http_client: SlackMattermost::Notifier::HTTPClient))
receive(:new).with(webhook_url, options.merge(http_client: Integrations::SlackMattermostNotifier::HTTPClient))
.and_return(double(:slack_service).as_null_object)
end
......@@ -128,6 +128,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
context 'issue events' do
let_it_be(:issue) { create(:issue) }
let(:data) { issue.to_hook_data(user) }
it_behaves_like 'calls the service API with the event message', /Issue (.*?) opened by/
......@@ -167,6 +168,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
context 'merge request events' do
let_it_be(:merge_request) { create(:merge_request) }
let(:data) { merge_request.to_hook_data(user) }
it_behaves_like 'calls the service API with the event message', /opened merge request/
......@@ -184,9 +186,10 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
context 'wiki page events' do
let_it_be(:wiki_page) { create(:wiki_page, wiki: project.wiki, message: 'user created page: Awesome wiki_page') }
let(:data) { Gitlab::DataBuilder::WikiPage.build(wiki_page, user, 'create') }
it_behaves_like 'calls the service API with the event message', / created (.*?)wikis\/(.*?)|wiki page> in/
it_behaves_like 'calls the service API with the event message', %r{ created (.*?)wikis/(.*?)|wiki page> in}
context 'with event channel' do
let(:chat_service_params) { { wiki_page_channel: 'random' } }
......@@ -201,6 +204,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
context 'deployment events' do
let_it_be(:deployment) { create(:deployment) }
let(:data) { Gitlab::DataBuilder::Deployment.build(deployment, Time.current) }
it_behaves_like 'calls the service API with the event message', /Deploy to (.*?) created/
......@@ -208,6 +212,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
context 'note event' do
let_it_be(:issue_note) { create(:note_on_issue, project: project, note: "issue note") }
let(:data) { Gitlab::DataBuilder::Note.build(issue_note, user) }
it_behaves_like 'calls the service API with the event message', /commented on issue/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment