From 2f60b1cea923269e3c31ebc569a878c442081d25 Mon Sep 17 00:00:00 2001
From: bmarjanovic <bmarjanovic@gitlab.com>
Date: Mon, 24 Jul 2023 19:17:28 +0200
Subject: [PATCH] Convert Pumble integration to use DSL

---
 app/models/integrations/pumble.rb       | 31 ++++++++++++++++---------
 spec/models/integrations/pumble_spec.rb |  2 +-
 2 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/app/models/integrations/pumble.rb b/app/models/integrations/pumble.rb
index e08dc6d0f513..85fb3b9c3e63 100644
--- a/app/models/integrations/pumble.rb
+++ b/app/models/integrations/pumble.rb
@@ -2,6 +2,24 @@
 
 module Integrations
   class Pumble < BaseChatNotification
+    undef :notify_only_broken_pipelines
+
+    field :webhook,
+      section: SECTION_TYPE_CONNECTION,
+      help: 'https://api.pumble.com/workspaces/x/...',
+      required: true
+
+    field :notify_only_broken_pipelines,
+      type: 'checkbox',
+      section: SECTION_TYPE_CONFIGURATION,
+      help: 'If selected, successful pipelines do not trigger a notification event.'
+
+    field :branches_to_be_notified,
+      type: 'select',
+      section: SECTION_TYPE_CONFIGURATION,
+      title: -> { s_('Integrations|Branches for which notifications are to be sent') },
+      choices: -> { branch_choices }
+
     def title
       'Pumble'
     end
@@ -34,17 +52,8 @@ def self.supported_events
          pipeline wiki_page]
     end
 
-    def default_fields
-      [
-        { type: 'text', name: 'webhook', help: 'https://api.pumble.com/workspaces/x/...', required: true },
-        { type: 'checkbox', name: 'notify_only_broken_pipelines' },
-        {
-          type: 'select',
-          name: 'branches_to_be_notified',
-          title: s_('Integrations|Branches for which notifications are to be sent'),
-          choices: self.class.branch_choices
-        }
-      ]
+    def fields
+      self.class.fields + build_event_channels
     end
 
     private
diff --git a/spec/models/integrations/pumble_spec.rb b/spec/models/integrations/pumble_spec.rb
index 8b9b5d214c6d..8d966ff5da55 100644
--- a/spec/models/integrations/pumble_spec.rb
+++ b/spec/models/integrations/pumble_spec.rb
@@ -2,7 +2,7 @@
 
 require "spec_helper"
 
-RSpec.describe Integrations::Pumble do
+RSpec.describe Integrations::Pumble, feature_category: :integrations do
   it_behaves_like "chat integration", "Pumble" do
     let(:client_arguments) { webhook_url }
     let(:payload) do
-- 
GitLab