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
hangouts_chat
irker
packagist pipelines_email pivotaltracker pushover
mattermost
mattermost mattermost_slash_commands microsoft_teams
].to_set.freeze
def self.renamed?(name)
......
......@@ -176,7 +176,7 @@ class Project < ApplicationRecord
has_one :jira_service, class_name: 'Integrations::Jira'
has_one :mattermost_integration, class_name: 'Integrations::Mattermost'
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 :packagist_integration, class_name: 'Integrations::Packagist'
has_one :pipelines_email_integration, class_name: 'Integrations::PipelinesEmail'
......
......@@ -44,10 +44,10 @@ RSpec.describe Projects::ServicesController do
let(:project) { create(:project) }
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
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
......
......@@ -378,7 +378,7 @@ project:
- assembla_integration
- asana_integration
- slack_service
- microsoft_teams_service
- microsoft_teams_integration
- mattermost_integration
- hangouts_chat_integration
- unify_circuit_service
......
......@@ -64,7 +64,8 @@ RSpec.describe Integrations::MicrosoftTeams do
end
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)
end
......
......@@ -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(:exported_protected_branches) }
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(:hangouts_chat_integration) }
it { is_expected.to have_one(:unify_circuit_service) }
......
......@@ -275,8 +275,8 @@ RSpec.describe API::Services do
end
end
describe 'Microsoft Teams service' do
let(:service_name) { 'microsoft-teams' }
describe 'Microsoft Teams integration' do
let(:integration_name) { 'microsoft-teams' }
let(:params) do
{
webhook: 'https://hook.example.com',
......@@ -286,21 +286,23 @@ RSpec.describe API::Services do
end
before do
project.create_microsoft_teams_service(
project.create_microsoft_teams_integration(
active: true,
properties: params
)
end
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(json_response['properties']['branches_to_be_notified']).to eq('all')
end
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(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