Class: Integrations::Test::BaseService

Inherits:
Object
  • Object
show all
Includes:
BaseServiceUtility
Defined in:
app/services/integrations/test/base_service.rb

Direct Known Subclasses

ProjectService

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(integration, current_user, event = nil) ⇒ BaseService

Returns a new instance of BaseService.

Parameters:

  • integration (Service)

    The external service that will be called

  • current_user (User)

    The user calling the service

  • event (String/nil) (defaults to: nil)

    The event that triggered this


13
14
15
16
17
# File 'app/services/integrations/test/base_service.rb', line 13

def initialize(integration, current_user, event = nil)
  @integration = integration
  @current_user = current_user
  @event = event
end

Instance Attribute Details

#current_userObject

Returns the value of attribute current_user


8
9
10
# File 'app/services/integrations/test/base_service.rb', line 8

def current_user
  @current_user
end

#eventObject

Returns the value of attribute event


8
9
10
# File 'app/services/integrations/test/base_service.rb', line 8

def event
  @event
end

#integrationObject

Returns the value of attribute integration


8
9
10
# File 'app/services/integrations/test/base_service.rb', line 8

def integration
  @integration
end

Instance Method Details

#executeObject


19
20
21
22
23
24
25
26
27
# File 'app/services/integrations/test/base_service.rb', line 19

def execute
  if event && (integration.supported_events.exclude?(event) || data.blank?)
    return error('Testing not available for this event')
  end

  return error(data[:error]) if data[:error].present?

  integration.test(data)
end