Commit 0bea9d41 authored by Imre Farkas's avatar Imre Farkas

Merge branch '330300-ajk-model-specs-11' into 'master'

Remove references to service in microsoft teams integration model spec

See merge request gitlab-org/gitlab!65019
parents 0b0eddca 74560c9e
......@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe Integrations::MicrosoftTeams do
let(:chat_service) { described_class.new }
let(:chat_integration) { described_class.new }
let(:webhook_url) { 'https://example.gitlab.com/' }
describe "Associations" do
......@@ -12,16 +12,16 @@ RSpec.describe Integrations::MicrosoftTeams do
end
describe 'Validations' do
context 'when service is active' do
context 'when integration is active' do
before do
subject.active = true
end
it { is_expected.to validate_presence_of(:webhook) }
it_behaves_like 'issue tracker service URL attribute', :webhook
it_behaves_like 'issue tracker integration URL attribute', :webhook
end
context 'when service is inactive' do
context 'when integration is inactive' do
before do
subject.active = false
end
......@@ -42,7 +42,7 @@ RSpec.describe Integrations::MicrosoftTeams do
let_it_be(:project) { create(:project, :repository, :wiki_repo) }
before do
allow(chat_service).to receive_messages(
allow(chat_integration).to receive_messages(
project: project,
project_id: project.id,
service_hook: true,
......@@ -58,7 +58,7 @@ RSpec.describe Integrations::MicrosoftTeams do
end
it "calls Microsoft Teams API for push events" do
chat_service.execute(push_sample_data)
chat_integration.execute(push_sample_data)
expect(WebMock).to have_requested(:post, webhook_url).once
end
......@@ -67,7 +67,7 @@ RSpec.describe Integrations::MicrosoftTeams do
integration = double(:microsoft_teams_integration).as_null_object
expect(::MicrosoftTeams::Notifier).to receive(:new).with(webhook_url).and_return(integration)
chat_service.execute(push_sample_data)
chat_integration.execute(push_sample_data)
end
end
......@@ -80,7 +80,7 @@ RSpec.describe Integrations::MicrosoftTeams do
end
it "calls Microsoft Teams API" do
chat_service.execute(issues_sample_data)
chat_integration.execute(issues_sample_data)
expect(WebMock).to have_requested(:post, webhook_url).once
end
......@@ -107,7 +107,7 @@ RSpec.describe Integrations::MicrosoftTeams do
end
it "calls Microsoft Teams API" do
chat_service.execute(merge_sample_data)
chat_integration.execute(merge_sample_data)
expect(WebMock).to have_requested(:post, webhook_url).once
end
......@@ -127,7 +127,7 @@ RSpec.describe Integrations::MicrosoftTeams do
let(:wiki_page_sample_data) { Gitlab::DataBuilder::WikiPage.build(wiki_page, user, 'create') }
it "calls Microsoft Teams API" do
chat_service.execute(wiki_page_sample_data)
chat_integration.execute(wiki_page_sample_data)
expect(WebMock).to have_requested(:post, webhook_url).once
end
......@@ -139,7 +139,7 @@ RSpec.describe Integrations::MicrosoftTeams do
let(:project) { create(:project, :repository, creator: user) }
before do
allow(chat_service).to receive_messages(
allow(chat_integration).to receive_messages(
project: project,
project_id: project.id,
service_hook: true,
......@@ -160,7 +160,7 @@ RSpec.describe Integrations::MicrosoftTeams do
it "calls Microsoft Teams API for commit comment events" do
data = Gitlab::DataBuilder::Note.build(commit_note, user)
chat_service.execute(data)
chat_integration.execute(data)
expect(WebMock).to have_requested(:post, webhook_url).once
end
......@@ -175,7 +175,7 @@ RSpec.describe Integrations::MicrosoftTeams do
it "calls Microsoft Teams API for merge request comment events" do
data = Gitlab::DataBuilder::Note.build(merge_request_note, user)
chat_service.execute(data)
chat_integration.execute(data)
expect(WebMock).to have_requested(:post, webhook_url).once
end
......@@ -189,7 +189,7 @@ RSpec.describe Integrations::MicrosoftTeams do
it "calls Microsoft Teams API for issue comment events" do
data = Gitlab::DataBuilder::Note.build(issue_note, user)
chat_service.execute(data)
chat_integration.execute(data)
expect(WebMock).to have_requested(:post, webhook_url).once
end
......@@ -204,7 +204,7 @@ RSpec.describe Integrations::MicrosoftTeams do
it "calls Microsoft Teams API for snippet comment events" do
data = Gitlab::DataBuilder::Note.build(snippet_note, user)
chat_service.execute(data)
chat_integration.execute(data)
expect(WebMock).to have_requested(:post, webhook_url).once
end
......@@ -222,7 +222,7 @@ RSpec.describe Integrations::MicrosoftTeams do
end
before do
allow(chat_service).to receive_messages(
allow(chat_integration).to receive_messages(
project: project,
service_hook: true,
webhook: webhook_url
......@@ -232,14 +232,14 @@ RSpec.describe Integrations::MicrosoftTeams do
shared_examples 'call Microsoft Teams API' do |branches_to_be_notified: nil|
before do
WebMock.stub_request(:post, webhook_url)
chat_service.branches_to_be_notified = branches_to_be_notified if branches_to_be_notified
chat_integration.branches_to_be_notified = branches_to_be_notified if branches_to_be_notified
end
it 'calls Microsoft Teams API for pipeline events' do
data = Gitlab::DataBuilder::Pipeline.build(pipeline)
data[:markdown] = true
chat_service.execute(data)
chat_integration.execute(data)
message = Integrations::ChatMessage::PipelineMessage.new(data)
......@@ -251,11 +251,11 @@ RSpec.describe Integrations::MicrosoftTeams do
shared_examples 'does not call Microsoft Teams API' do |branches_to_be_notified: nil|
before do
chat_service.branches_to_be_notified = branches_to_be_notified if branches_to_be_notified
chat_integration.branches_to_be_notified = branches_to_be_notified if branches_to_be_notified
end
it 'does not call Microsoft Teams API for pipeline events' do
data = Gitlab::DataBuilder::Pipeline.build(pipeline)
result = chat_service.execute(data)
result = chat_integration.execute(data)
expect(result).to be_falsy
end
......@@ -273,7 +273,7 @@ RSpec.describe Integrations::MicrosoftTeams do
context 'with default to notify_only_broken_pipelines' do
it 'does not call Microsoft Teams API for pipeline events' do
data = Gitlab::DataBuilder::Pipeline.build(pipeline)
result = chat_service.execute(data)
result = chat_integration.execute(data)
expect(result).to be_falsy
end
......@@ -281,7 +281,7 @@ RSpec.describe Integrations::MicrosoftTeams do
context 'with setting notify_only_broken_pipelines to false' do
before do
chat_service.notify_only_broken_pipelines = false
chat_integration.notify_only_broken_pipelines = false
end
it_behaves_like 'call Microsoft Teams API'
......
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