Commit 74560c9e authored by Alex Kalderimis's avatar Alex Kalderimis

Remove references to service in microsoft teams spec

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