From d1bf557aacb5dd789ccc88786b47ec174ed1de2b Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Tue, 20 Dec 2016 19:29:39 -0200 Subject: Rename MattermostNotificationService back to MattermostService --- app/models/project.rb | 2 +- .../mattermost_notification_service.rb | 41 ---------------------- app/models/project_services/mattermost_service.rb | 41 ++++++++++++++++++++++ app/models/service.rb | 2 +- lib/api/services.rb | 2 +- spec/lib/gitlab/import_export/all_models.yml | 2 +- .../mattermost_notification_service_spec.rb | 5 --- .../project_services/mattermost_service_spec.rb | 5 +++ spec/models/project_spec.rb | 2 +- 9 files changed, 51 insertions(+), 51 deletions(-) delete mode 100644 app/models/project_services/mattermost_notification_service.rb create mode 100644 app/models/project_services/mattermost_service.rb delete mode 100644 spec/models/project_services/mattermost_notification_service_spec.rb create mode 100644 spec/models/project_services/mattermost_service_spec.rb diff --git a/app/models/project.rb b/app/models/project.rb index 5807ea5acdc..26fa20f856d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -94,7 +94,7 @@ class Project < ActiveRecord::Base has_one :asana_service, dependent: :destroy has_one :gemnasium_service, dependent: :destroy has_one :mattermost_slash_commands_service, dependent: :destroy - has_one :mattermost_notification_service, dependent: :destroy + has_one :mattermost_service, dependent: :destroy has_one :slack_slash_commands_service, dependent: :destroy has_one :slack_service, dependent: :destroy has_one :buildkite_service, dependent: :destroy diff --git a/app/models/project_services/mattermost_notification_service.rb b/app/models/project_services/mattermost_notification_service.rb deleted file mode 100644 index de18c4b1f00..00000000000 --- a/app/models/project_services/mattermost_notification_service.rb +++ /dev/null @@ -1,41 +0,0 @@ -class MattermostNotificationService < ChatNotificationService - def title - 'Mattermost notifications' - end - - def description - 'Receive event notifications in Mattermost' - end - - def to_param - 'mattermost_notification' - end - - def help - 'This service sends notifications about projects events to Mattermost channels.
- To set up this service: -
    -
  1. Enable incoming webhooks in your Mattermost installation.
  2. -
  3. Add an incoming webhook in your Mattermost team. The default channel can be overridden for each event.
  4. -
  5. Paste the webhook URL into the field bellow.
  6. -
  7. Select events below to enable notifications. The channel and username are optional.
  8. -
' - end - - def fields - default_fields + build_event_channels - end - - def default_fields - [ - { type: 'text', name: 'webhook', placeholder: 'http://mattermost_host/hooks/...' }, - { type: 'text', name: 'username', placeholder: 'username' }, - { type: 'checkbox', name: 'notify_only_broken_builds' }, - { type: 'checkbox', name: 'notify_only_broken_pipelines' }, - ] - end - - def default_channel - "#town-square" - end -end diff --git a/app/models/project_services/mattermost_service.rb b/app/models/project_services/mattermost_service.rb new file mode 100644 index 00000000000..0650f930402 --- /dev/null +++ b/app/models/project_services/mattermost_service.rb @@ -0,0 +1,41 @@ +class MattermostService < ChatNotificationService + def title + 'Mattermost notifications' + end + + def description + 'Receive event notifications in Mattermost' + end + + def to_param + 'mattermost' + end + + def help + 'This service sends notifications about projects events to Mattermost channels.
+ To set up this service: +
    +
  1. Enable incoming webhooks in your Mattermost installation.
  2. +
  3. Add an incoming webhook in your Mattermost team. The default channel can be overridden for each event.
  4. +
  5. Paste the webhook URL into the field bellow.
  6. +
  7. Select events below to enable notifications. The channel and username are optional.
  8. +
' + end + + def fields + default_fields + build_event_channels + end + + def default_fields + [ + { type: 'text', name: 'webhook', placeholder: 'http://mattermost_host/hooks/...' }, + { type: 'text', name: 'username', placeholder: 'username' }, + { type: 'checkbox', name: 'notify_only_broken_builds' }, + { type: 'checkbox', name: 'notify_only_broken_pipelines' }, + ] + end + + def default_channel + "#town-square" + end +end diff --git a/app/models/service.rb b/app/models/service.rb index 918ed8206e0..19ef3ba9c23 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -216,7 +216,7 @@ class Service < ActiveRecord::Base jira kubernetes mattermost_slash_commands - mattermost_notification + mattermost pipelines_email pivotaltracker pushover diff --git a/lib/api/services.rb b/lib/api/services.rb index 44e668e3cf5..d11cdce4e18 100644 --- a/lib/api/services.rb +++ b/lib/api/services.rb @@ -500,7 +500,7 @@ module API desc: 'The channel name' } ], - 'mattermost-notification' => [ + 'mattermost' => [ { required: true, name: :webhook, diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index 155cf8565b5..f420d71dee2 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -138,7 +138,7 @@ project: - asana_service - gemnasium_service - slack_service -- mattermost_notification_service +- mattermost_service - buildkite_service - bamboo_service - teamcity_service diff --git a/spec/models/project_services/mattermost_notification_service_spec.rb b/spec/models/project_services/mattermost_notification_service_spec.rb deleted file mode 100644 index 7832d6f50cf..00000000000 --- a/spec/models/project_services/mattermost_notification_service_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe MattermostNotificationService, models: true do - it_behaves_like "slack or mattermost notifications" -end diff --git a/spec/models/project_services/mattermost_service_spec.rb b/spec/models/project_services/mattermost_service_spec.rb new file mode 100644 index 00000000000..490d6aedffc --- /dev/null +++ b/spec/models/project_services/mattermost_service_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe MattermostService, models: true do + it_behaves_like "slack or mattermost notifications" +end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 569071c0418..88d5d14f855 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -22,7 +22,7 @@ describe Project, models: true do it { is_expected.to have_many(:protected_branches).dependent(:destroy) } it { is_expected.to have_one(:forked_project_link).dependent(:destroy) } it { is_expected.to have_one(:slack_service).dependent(:destroy) } - it { is_expected.to have_one(:mattermost_notification_service).dependent(:destroy) } + it { is_expected.to have_one(:mattermost_service).dependent(:destroy) } it { is_expected.to have_one(:pushover_service).dependent(:destroy) } it { is_expected.to have_one(:asana_service).dependent(:destroy) } it { is_expected.to have_many(:boards).dependent(:destroy) } -- cgit v1.2.1