Class: ApplicationSettings::UpdateService

Inherits:
BaseService show all
Includes:
ValidatesClassificationLabel
Defined in:
app/services/application_settings/update_service.rb

Constant Summary collapse

MARKDOWN_CACHE_INVALIDATING_PARAMS =
%w(asset_proxy_enabled asset_proxy_url asset_proxy_secret_key asset_proxy_whitelist).freeze

Instance Attribute Summary collapse

Attributes inherited from BaseService

#current_user, #project

Instance Method Summary collapse

Methods included from ValidatesClassificationLabel

#classification_label_change?, #rejection_reason_for_label, #validate_classification_label

Methods inherited from BaseService

#initialize

Methods inherited from BaseService

#initialize

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

This class inherits a constructor from ApplicationSettings::BaseService

Instance Attribute Details

#application_settingObject (readonly)

Returns the value of attribute application_setting


7
8
9
# File 'app/services/application_settings/update_service.rb', line 7

def application_setting
  @application_setting
end

#paramsObject (readonly)

Returns the value of attribute params


7
8
9
# File 'app/services/application_settings/update_service.rb', line 7

def params
  @params
end

Instance Method Details

#executeObject


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/services/application_settings/update_service.rb', line 11

def execute
  validate_classification_label(application_setting, :external_authorization_service_default_label) unless bypass_external_auth?

  if application_setting.errors.any?
    return false
  end

  update_terms(@params.delete(:terms))

  add_to_outbound_local_requests_whitelist(@params.delete(:add_to_outbound_local_requests_whitelist))

  if params.key?(:performance_bar_allowed_group_path)
    group_id = process_performance_bar_allowed_group_id

    return false if application_setting.errors.any?

    params[:performance_bar_allowed_group_id] = group_id
  end

  if usage_stats_updated? && !params.delete(:skip_usage_stats_user)
    params[:usage_stats_set_by_user_id] = current_user.id
  end

  @application_setting.assign_attributes(params)

  if invalidate_markdown_cache?
    @application_setting[:local_markdown_version] = @application_setting.local_markdown_version + 1
  end

  @application_setting.save
end