Commit dbedacb3 authored by Alex Kalderimis's avatar Alex Kalderimis

Rename microsoft_teams_service to integration

Rename the projection association from microsoft_teams_service to
microsoft_teams_integration
parent 2ae8a1e7
...@@ -49,7 +49,7 @@ class Integration < ApplicationRecord ...@@ -49,7 +49,7 @@ class Integration < ApplicationRecord
hangouts_chat hangouts_chat
irker irker
packagist pipelines_email pivotaltracker pushover packagist pipelines_email pivotaltracker pushover
mattermost mattermost mattermost_slash_commands microsoft_teams
].to_set.freeze ].to_set.freeze
def self.renamed?(name) def self.renamed?(name)
......
...@@ -176,7 +176,7 @@ class Project < ApplicationRecord ...@@ -176,7 +176,7 @@ class Project < ApplicationRecord
has_one :jira_service, class_name: 'Integrations::Jira' has_one :jira_service, class_name: 'Integrations::Jira'
has_one :mattermost_integration, class_name: 'Integrations::Mattermost' has_one :mattermost_integration, class_name: 'Integrations::Mattermost'
has_one :mattermost_slash_commands_integration, class_name: 'Integrations::MattermostSlashCommands' has_one :mattermost_slash_commands_integration, class_name: 'Integrations::MattermostSlashCommands'
has_one :microsoft_teams_service, class_name: 'Integrations::MicrosoftTeams' has_one :microsoft_teams_integration, class_name: 'Integrations::MicrosoftTeams'
has_one :mock_ci_service, class_name: 'Integrations::MockCi' has_one :mock_ci_service, class_name: 'Integrations::MockCi'
has_one :packagist_integration, class_name: 'Integrations::Packagist' has_one :packagist_integration, class_name: 'Integrations::Packagist'
has_one :pipelines_email_integration, class_name: 'Integrations::PipelinesEmail' has_one :pipelines_email_integration, class_name: 'Integrations::PipelinesEmail'
......
...@@ -44,10 +44,10 @@ RSpec.describe Projects::ServicesController do ...@@ -44,10 +44,10 @@ RSpec.describe Projects::ServicesController do
let(:project) { create(:project) } let(:project) { create(:project) }
context 'with chat notification service' do context 'with chat notification service' do
let(:service) { project.create_microsoft_teams_service(webhook: 'http://webhook.com') } let(:service) { project.create_microsoft_teams_integration(webhook: 'http://webhook.com') }
it 'returns success' do it 'returns success' do
allow_any_instance_of(::MicrosoftTeams::Notifier).to receive(:ping).and_return(true) allow_next(::MicrosoftTeams::Notifier).to receive(:ping).and_return(true)
put :test, params: project_params put :test, params: project_params
......
...@@ -378,7 +378,7 @@ project: ...@@ -378,7 +378,7 @@ project:
- assembla_integration - assembla_integration
- asana_integration - asana_integration
- slack_service - slack_service
- microsoft_teams_service - microsoft_teams_integration
- mattermost_integration - mattermost_integration
- hangouts_chat_integration - hangouts_chat_integration
- unify_circuit_service - unify_circuit_service
......
...@@ -64,7 +64,8 @@ RSpec.describe Integrations::MicrosoftTeams do ...@@ -64,7 +64,8 @@ RSpec.describe Integrations::MicrosoftTeams do
end end
it 'specifies the webhook when it is configured' do it 'specifies the webhook when it is configured' do
expect(::MicrosoftTeams::Notifier).to receive(:new).with(webhook_url).and_return(double(:microsoft_teams_service).as_null_object) 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_service.execute(push_sample_data)
end end
......
...@@ -36,7 +36,7 @@ RSpec.describe Project, factory_default: :keep do ...@@ -36,7 +36,7 @@ RSpec.describe Project, factory_default: :keep do
it { is_expected.to have_many(:protected_branches) } it { is_expected.to have_many(:protected_branches) }
it { is_expected.to have_many(:exported_protected_branches) } it { is_expected.to have_many(:exported_protected_branches) }
it { is_expected.to have_one(:slack_service) } it { is_expected.to have_one(:slack_service) }
it { is_expected.to have_one(:microsoft_teams_service) } it { is_expected.to have_one(:microsoft_teams_integration) }
it { is_expected.to have_one(:mattermost_integration) } it { is_expected.to have_one(:mattermost_integration) }
it { is_expected.to have_one(:hangouts_chat_integration) } it { is_expected.to have_one(:hangouts_chat_integration) }
it { is_expected.to have_one(:unify_circuit_service) } it { is_expected.to have_one(:unify_circuit_service) }
......
...@@ -275,8 +275,8 @@ RSpec.describe API::Services do ...@@ -275,8 +275,8 @@ RSpec.describe API::Services do
end end
end end
describe 'Microsoft Teams service' do describe 'Microsoft Teams integration' do
let(:service_name) { 'microsoft-teams' } let(:integration_name) { 'microsoft-teams' }
let(:params) do let(:params) do
{ {
webhook: 'https://hook.example.com', webhook: 'https://hook.example.com',
...@@ -286,21 +286,23 @@ RSpec.describe API::Services do ...@@ -286,21 +286,23 @@ RSpec.describe API::Services do
end end
before do before do
project.create_microsoft_teams_service( project.create_microsoft_teams_integration(
active: true, active: true,
properties: params properties: params
) )
end end
it 'accepts branches_to_be_notified for update' do it 'accepts branches_to_be_notified for update' do
put api("/projects/#{project.id}/services/#{service_name}", user), params: params.merge(branches_to_be_notified: 'all') put api("/projects/#{project.id}/services/#{integration_name}", user),
params: params.merge(branches_to_be_notified: 'all')
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['properties']['branches_to_be_notified']).to eq('all') expect(json_response['properties']['branches_to_be_notified']).to eq('all')
end end
it 'accepts notify_only_broken_pipelines for update' do it 'accepts notify_only_broken_pipelines for update' do
put api("/projects/#{project.id}/services/#{service_name}", user), params: params.merge(notify_only_broken_pipelines: true) put api("/projects/#{project.id}/services/#{integration_name}", user),
params: params.merge(notify_only_broken_pipelines: true)
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['properties']['notify_only_broken_pipelines']).to eq(true) expect(json_response['properties']['notify_only_broken_pipelines']).to eq(true)
......
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