Commit 4df1d532 authored by Thong Kuah's avatar Thong Kuah

Merge branch '330300-ajk-spec-and-private-methods' into 'master'

Rename private and spec methods to integration [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!64794
parents 9a82843e 062e0ccf
...@@ -7,7 +7,7 @@ module AutoDevopsHelper ...@@ -7,7 +7,7 @@ module AutoDevopsHelper
can?(current_user, :admin_pipeline, project) && can?(current_user, :admin_pipeline, project) &&
project.has_auto_devops_implicitly_disabled? && project.has_auto_devops_implicitly_disabled? &&
!project.repository.gitlab_ci_yml && !project.repository.gitlab_ci_yml &&
!project.ci_service !project.ci_integration
end end
def badge_for_auto_devops_scope(auto_devops_receiver) def badge_for_auto_devops_scope(auto_devops_receiver)
......
...@@ -248,10 +248,10 @@ module AlertManagement ...@@ -248,10 +248,10 @@ module AlertManagement
"#{project.to_reference_base(from, full: full)}#{reference}" "#{project.to_reference_base(from, full: full)}#{reference}"
end end
def execute_services def execute_integrations
return unless project.has_active_services?(:alert_hooks) return unless project.has_active_integrations?(:alert_hooks)
project.execute_services(hook_data, :alert_hooks) project.execute_integrations(hook_data, :alert_hooks)
end end
# Representation of the alert's payload. Avoid accessing # Representation of the alert's payload. Avoid accessing
......
...@@ -772,7 +772,7 @@ module Ci ...@@ -772,7 +772,7 @@ module Ci
return unless project return unless project
project.execute_hooks(build_data.dup, :job_hooks) if project.has_active_hooks?(:job_hooks) project.execute_hooks(build_data.dup, :job_hooks) if project.has_active_hooks?(:job_hooks)
project.execute_services(build_data.dup, :job_hooks) if project.has_active_services?(:job_hooks) project.execute_integrations(build_data.dup, :job_hooks) if project.has_active_integrations?(:job_hooks)
end end
def browsable_artifacts? def browsable_artifacts?
......
...@@ -854,7 +854,7 @@ module Ci ...@@ -854,7 +854,7 @@ module Ci
def execute_hooks def execute_hooks
project.execute_hooks(pipeline_data, :pipeline_hooks) if project.has_active_hooks?(:pipeline_hooks) project.execute_hooks(pipeline_data, :pipeline_hooks) if project.has_active_hooks?(:pipeline_hooks)
project.execute_services(pipeline_data, :pipeline_hooks) if project.has_active_services?(:pipeline_hooks) project.execute_integrations(pipeline_data, :pipeline_hooks) if project.has_active_integrations?(:pipeline_hooks)
end end
# All the merge requests for which the current pipeline runs/ran against # All the merge requests for which the current pipeline runs/ran against
......
...@@ -189,7 +189,7 @@ class Deployment < ApplicationRecord ...@@ -189,7 +189,7 @@ class Deployment < ApplicationRecord
def execute_hooks(status_changed_at) def execute_hooks(status_changed_at)
deployment_data = Gitlab::DataBuilder::Deployment.build(self, status_changed_at) deployment_data = Gitlab::DataBuilder::Deployment.build(self, status_changed_at)
project.execute_hooks(deployment_data, :deployment_hooks) project.execute_hooks(deployment_data, :deployment_hooks)
project.execute_services(deployment_data, :deployment_hooks) project.execute_integrations(deployment_data, :deployment_hooks)
end end
def last? def last?
......
...@@ -666,7 +666,7 @@ class Group < Namespace ...@@ -666,7 +666,7 @@ class Group < Namespace
# TODO: group hooks https://gitlab.com/gitlab-org/gitlab/-/issues/216904 # TODO: group hooks https://gitlab.com/gitlab-org/gitlab/-/issues/216904
end end
def execute_services(data, hooks_scope) def execute_integrations(data, hooks_scope)
# NOOP # NOOP
# TODO: group hooks https://gitlab.com/gitlab-org/gitlab/-/issues/216904 # TODO: group hooks https://gitlab.com/gitlab-org/gitlab/-/issues/216904
end end
......
...@@ -38,31 +38,6 @@ class Integration < ApplicationRecord ...@@ -38,31 +38,6 @@ class Integration < ApplicationRecord
Integrations::BaseSlashCommands Integrations::BaseSlashCommands
].freeze ].freeze
# used as part of the renaming effort (https://gitlab.com/groups/gitlab-org/-/epics/2504)
RENAMED_TO_INTEGRATION = %w[
asana assembla
bamboo bugzilla buildkite
campfire confluence custom_issue_tracker
datadog discord drone_ci
emails_on_push ewm emails_on_push external_wiki
flowdock
hangouts_chat
irker
jenkins jira
packagist pipelines_email pivotaltracker prometheus pushover
mattermost mattermost_slash_commands microsoft_teams mock_ci mock_monitoring
redmine
slack slack_slash_commands
teamcity
unify_circuit
webex_teams
youtrack
].to_set.freeze
def self.renamed?(name)
RENAMED_TO_INTEGRATION.include?(name)
end
serialize :properties, JSON # rubocop:disable Cop/ActiveRecordSerialize serialize :properties, JSON # rubocop:disable Cop/ActiveRecordSerialize
attribute :type, Gitlab::Integrations::StiType.new attribute :type, Gitlab::Integrations::StiType.new
...@@ -207,14 +182,14 @@ class Integration < ApplicationRecord ...@@ -207,14 +182,14 @@ class Integration < ApplicationRecord
end end
def self.create_nonexistent_templates def self.create_nonexistent_templates
nonexistent_services = build_nonexistent_services_for(for_template) nonexistent_integrations = build_nonexistent_integrations_for(for_template)
return if nonexistent_services.empty? return if nonexistent_integrations.empty?
# Create within a transaction to perform the lowest possible SQL queries. # Create within a transaction to perform the lowest possible SQL queries.
transaction do transaction do
nonexistent_services.each do |service| nonexistent_integrations.each do |integration|
service.template = true integration.template = true
service.save integration.save
end end
end end
end end
...@@ -227,24 +202,24 @@ class Integration < ApplicationRecord ...@@ -227,24 +202,24 @@ class Integration < ApplicationRecord
end end
def self.find_or_initialize_all_non_project_specific(scope) def self.find_or_initialize_all_non_project_specific(scope)
scope + build_nonexistent_services_for(scope) scope + build_nonexistent_integrations_for(scope)
end end
def self.build_nonexistent_services_for(scope) def self.build_nonexistent_integrations_for(scope)
nonexistent_services_types_for(scope).map do |service_type| nonexistent_integration_types_for(scope).map do |type|
integration_type_to_model(service_type).new integration_type_to_model(type).new
end end
end end
private_class_method :build_nonexistent_services_for private_class_method :build_nonexistent_integrations_for
# Returns a list of service types that do not exist in the given scope. # Returns a list of integration types that do not exist in the given scope.
# Example: ["AsanaService", ...] # Example: ["AsanaService", ...]
def self.nonexistent_services_types_for(scope) def self.nonexistent_integration_types_for(scope)
# Using #map instead of #pluck to save one query count. This is because # Using #map instead of #pluck to save one query count. This is because
# ActiveRecord loaded the object here, so we don't need to query again later. # ActiveRecord loaded the object here, so we don't need to query again later.
available_integration_types(include_project_specific: false) - scope.map(&:type) available_integration_types(include_project_specific: false) - scope.map(&:type)
end end
private_class_method :nonexistent_services_types_for private_class_method :nonexistent_integration_types_for
# Returns a list of available integration names. # Returns a list of available integration names.
# Example: ["asana", ...] # Example: ["asana", ...]
...@@ -261,10 +236,6 @@ class Integration < ApplicationRecord ...@@ -261,10 +236,6 @@ class Integration < ApplicationRecord
INTEGRATION_NAMES INTEGRATION_NAMES
end end
def self.services_names
integration_names
end
def self.dev_integration_names def self.dev_integration_names
return [] unless Rails.env.development? return [] unless Rails.env.development?
...@@ -283,14 +254,14 @@ class Integration < ApplicationRecord ...@@ -283,14 +254,14 @@ class Integration < ApplicationRecord
end end
end end
# Returns the model for the given service name. # Returns the model for the given integration name.
# Example: "asana" => Integrations::Asana # Example: "asana" => Integrations::Asana
def self.integration_name_to_model(name) def self.integration_name_to_model(name)
type = integration_name_to_type(name) type = integration_name_to_type(name)
integration_type_to_model(type) integration_type_to_model(type)
end end
# Returns the STI type for the given service name. # Returns the STI type for the given integration name.
# Example: "asana" => "AsanaService" # Example: "asana" => "AsanaService"
def self.integration_name_to_type(name) def self.integration_name_to_type(name)
"#{name}_service".camelize "#{name}_service".camelize
...@@ -419,7 +390,7 @@ class Integration < ApplicationRecord ...@@ -419,7 +390,7 @@ class Integration < ApplicationRecord
%w[active] %w[active]
end end
def to_service_hash def to_integration_hash
as_json(methods: :type, except: %w[id template instance project_id group_id]) as_json(methods: :type, except: %w[id template instance project_id group_id])
end end
......
...@@ -1340,7 +1340,7 @@ class MergeRequest < ApplicationRecord ...@@ -1340,7 +1340,7 @@ class MergeRequest < ApplicationRecord
def has_ci? def has_ci?
return false if has_no_commits? return false if has_no_commits?
!!(head_pipeline_id || all_pipelines.any? || source_project&.ci_service) !!(head_pipeline_id || all_pipelines.any? || source_project&.ci_integration)
end end
def branch_missing? def branch_missing?
......
...@@ -147,11 +147,7 @@ class Project < ApplicationRecord ...@@ -147,11 +147,7 @@ class Project < ApplicationRecord
has_many :boards has_many :boards
def self.integration_association_name(name) def self.integration_association_name(name)
if ::Integration.renamed?(name) "#{name}_integration"
"#{name}_integration"
else
"#{name}_service"
end
end end
# Project integrations # Project integrations
...@@ -1425,20 +1421,12 @@ class Project < ApplicationRecord ...@@ -1425,20 +1421,12 @@ class Project < ApplicationRecord
end end
# rubocop: enable CodeReuse/ServiceClass # rubocop: enable CodeReuse/ServiceClass
def ci_services def ci_integrations
integrations.where(category: :ci) integrations.where(category: :ci)
end end
def ci_service def ci_integration
@ci_service ||= ci_services.reorder(nil).find_by(active: true) @ci_integration ||= ci_integrations.reorder(nil).find_by(active: true)
end
def monitoring_services
integrations.where(category: :monitoring)
end
def monitoring_service
@monitoring_service ||= monitoring_services.reorder(nil).find_by(active: true)
end end
def avatar_in_git def avatar_in_git
...@@ -1509,7 +1497,7 @@ class Project < ApplicationRecord ...@@ -1509,7 +1497,7 @@ class Project < ApplicationRecord
end end
# rubocop: enable CodeReuse/ServiceClass # rubocop: enable CodeReuse/ServiceClass
def execute_services(data, hooks_scope = :push_hooks) def execute_integrations(data, hooks_scope = :push_hooks)
# Call only service hooks that are active for this scope # Call only service hooks that are active for this scope
run_after_commit_or_now do run_after_commit_or_now do
integrations.public_send(hooks_scope).each do |integration| # rubocop:disable GitlabSecurity/PublicSend integrations.public_send(hooks_scope).each do |integration| # rubocop:disable GitlabSecurity/PublicSend
...@@ -1522,7 +1510,7 @@ class Project < ApplicationRecord ...@@ -1522,7 +1510,7 @@ class Project < ApplicationRecord
hooks.hooks_for(hooks_scope).any? || SystemHook.hooks_for(hooks_scope).any? || Gitlab::FileHook.any? hooks.hooks_for(hooks_scope).any? || SystemHook.hooks_for(hooks_scope).any? || Gitlab::FileHook.any?
end end
def has_active_services?(hooks_scope = :push_hooks) def has_active_integrations?(hooks_scope = :push_hooks)
integrations.public_send(hooks_scope).any? # rubocop:disable GitlabSecurity/PublicSend integrations.public_send(hooks_scope).any? # rubocop:disable GitlabSecurity/PublicSend
end end
...@@ -2699,10 +2687,10 @@ class Project < ApplicationRecord ...@@ -2699,10 +2687,10 @@ class Project < ApplicationRecord
end end
def build_from_instance_or_template(name) def build_from_instance_or_template(name)
instance = find_integration(services_instances, name) instance = find_integration(integration_instances, name)
return Integration.build_from_integration(instance, project_id: id) if instance return Integration.build_from_integration(instance, project_id: id) if instance
template = find_integration(services_templates, name) template = find_integration(integration_templates, name)
return Integration.build_from_integration(template, project_id: id) if template return Integration.build_from_integration(template, project_id: id) if template
end end
...@@ -2710,12 +2698,12 @@ class Project < ApplicationRecord ...@@ -2710,12 +2698,12 @@ class Project < ApplicationRecord
Integration.integration_name_to_model(name).new(project_id: id) Integration.integration_name_to_model(name).new(project_id: id)
end end
def services_templates def integration_templates
@services_templates ||= Integration.for_template @integration_templates ||= Integration.for_template
end end
def services_instances def integration_instances
@services_instances ||= Integration.for_instance @integration_instances ||= Integration.for_instance
end end
def closest_namespace_setting(name) def closest_namespace_setting(name)
......
...@@ -19,8 +19,8 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated ...@@ -19,8 +19,8 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
status || "preparing" status || "preparing"
else else
ci_service = source_project.try(:ci_service) ci_integration = source_project.try(:ci_integration)
ci_service&.commit_status(diff_head_sha, source_branch) ci_integration&.commit_status(diff_head_sha, source_branch)
end end
end end
......
...@@ -8,7 +8,7 @@ class BulkCreateIntegrationService ...@@ -8,7 +8,7 @@ class BulkCreateIntegrationService
end end
def execute def execute
service_list = ServiceList.new(batch, service_hash, association).to_array service_list = ServiceList.new(batch, integration_hash, association).to_array
Integration.transaction do Integration.transaction do
results = bulk_insert(*service_list) results = bulk_insert(*service_list)
...@@ -31,11 +31,11 @@ class BulkCreateIntegrationService ...@@ -31,11 +31,11 @@ class BulkCreateIntegrationService
klass.insert_all(items_to_insert, returning: [:id]) klass.insert_all(items_to_insert, returning: [:id])
end end
def service_hash def integration_hash
if integration.template? if integration.template?
integration.to_service_hash integration.to_integration_hash
else else
integration.to_service_hash.tap { |json| json['inherit_from_id'] = integration.inherit_from_id || integration.id } integration.to_integration_hash.tap { |json| json['inherit_from_id'] = integration.inherit_from_id || integration.id }
end end
end end
......
...@@ -9,7 +9,7 @@ class BulkUpdateIntegrationService ...@@ -9,7 +9,7 @@ class BulkUpdateIntegrationService
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def execute def execute
Integration.transaction do Integration.transaction do
Integration.where(id: batch.select(:id)).update_all(service_hash) Integration.where(id: batch.select(:id)).update_all(integration_hash)
if integration.data_fields_present? if integration.data_fields_present?
integration.data_fields.class.where(service_id: batch.select(:id)).update_all(data_fields_hash) integration.data_fields.class.where(service_id: batch.select(:id)).update_all(data_fields_hash)
...@@ -22,8 +22,8 @@ class BulkUpdateIntegrationService ...@@ -22,8 +22,8 @@ class BulkUpdateIntegrationService
attr_reader :integration, :batch attr_reader :integration, :batch
def service_hash def integration_hash
integration.to_service_hash.tap { |json| json['inherit_from_id'] = integration.inherit_from_id || integration.id } integration.to_integration_hash.tap { |json| json['inherit_from_id'] = integration.inherit_from_id || integration.id }
end end
def data_fields_hash def data_fields_hash
......
...@@ -64,7 +64,7 @@ module AlertManagement ...@@ -64,7 +64,7 @@ module AlertManagement
def process_new_alert def process_new_alert
if alert.save if alert.save
alert.execute_services alert.execute_integrations
SystemNoteService.create_new_alert(alert, alert_source) SystemNoteService.create_new_alert(alert, alert_source)
process_resolved_alert if resolving_alert? process_resolved_alert if resolving_alert?
......
...@@ -69,7 +69,7 @@ module Git ...@@ -69,7 +69,7 @@ module Git
# Creating push_data invokes one CommitDelta RPC per commit. Only # Creating push_data invokes one CommitDelta RPC per commit. Only
# build this data if we actually need it. # build this data if we actually need it.
project.execute_hooks(push_data, hook_name) if project.has_active_hooks?(hook_name) project.execute_hooks(push_data, hook_name) if project.has_active_hooks?(hook_name)
project.execute_services(push_data, hook_name) if project.has_active_services?(hook_name) project.execute_integrations(push_data, hook_name) if project.has_active_integrations?(hook_name)
end end
def enqueue_invalidate_cache def enqueue_invalidate_cache
......
...@@ -60,7 +60,7 @@ module Issues ...@@ -60,7 +60,7 @@ module Issues
issue_data = Gitlab::Lazy.new { hook_data(issue, action, old_associations: old_associations) } issue_data = Gitlab::Lazy.new { hook_data(issue, action, old_associations: old_associations) }
hooks_scope = issue.confidential? ? :confidential_issue_hooks : :issue_hooks hooks_scope = issue.confidential? ? :confidential_issue_hooks : :issue_hooks
issue.project.execute_hooks(issue_data, hooks_scope) issue.project.execute_hooks(issue_data, hooks_scope)
issue.project.execute_services(issue_data, hooks_scope) issue.project.execute_integrations(issue_data, hooks_scope)
end end
def update_project_counter_caches?(issue) def update_project_counter_caches?(issue)
......
...@@ -22,7 +22,7 @@ module MergeRequests ...@@ -22,7 +22,7 @@ module MergeRequests
def execute_hooks(merge_request, action = 'open', old_rev: nil, old_associations: {}) def execute_hooks(merge_request, action = 'open', old_rev: nil, old_associations: {})
merge_data = hook_data(merge_request, action, old_rev: old_rev, old_associations: old_associations) merge_data = hook_data(merge_request, action, old_rev: old_rev, old_associations: old_associations)
merge_request.project.execute_hooks(merge_data, :merge_request_hooks) merge_request.project.execute_hooks(merge_data, :merge_request_hooks)
merge_request.project.execute_services(merge_data, :merge_request_hooks) merge_request.project.execute_integrations(merge_data, :merge_request_hooks)
execute_external_hooks(merge_request, merge_data) execute_external_hooks(merge_request, merge_data)
......
...@@ -39,7 +39,7 @@ module Notes ...@@ -39,7 +39,7 @@ module Notes
hooks_scope = note.confidential?(include_noteable: true) ? :confidential_note_hooks : :note_hooks hooks_scope = note.confidential?(include_noteable: true) ? :confidential_note_hooks : :note_hooks
note.project.execute_hooks(note_data, hooks_scope) note.project.execute_hooks(note_data, hooks_scope)
note.project.execute_services(note_data, hooks_scope) note.project.execute_integrations(note_data, hooks_scope)
end end
end end
end end
......
...@@ -12,7 +12,7 @@ module WikiPages ...@@ -12,7 +12,7 @@ module WikiPages
def execute_hooks(page) def execute_hooks(page)
page_data = payload(page) page_data = payload(page)
container.execute_hooks(page_data, :wiki_page_hooks) container.execute_hooks(page_data, :wiki_page_hooks)
container.execute_services(page_data, :wiki_page_hooks) container.execute_integrations(page_data, :wiki_page_hooks)
increment_usage increment_usage
create_wiki_event(page) create_wiki_event(page)
end end
......
...@@ -831,12 +831,12 @@ build.dependencies.each do |d| { puts "status: #{d.status}, finished at: #{d.fin ...@@ -831,12 +831,12 @@ build.dependencies.each do |d| { puts "status: #{d.status}, finished at: #{d.fin
completed: #{d.complete?}, artifacts_expired: #{d.artifacts_expired?}, erased: #{d.erased?}" } completed: #{d.complete?}, artifacts_expired: #{d.artifacts_expired?}, erased: #{d.erased?}" }
``` ```
### Try CI service ### Try CI integration
```ruby ```ruby
p = Project.find_by_full_path('<project_path>') p = Project.find_by_full_path('<project_path>')
m = project.merge_requests.find_by(iid: ) m = project.merge_requests.find_by(iid: )
m.project.try(:ci_service) m.project.try(:ci_integration)
``` ```
### Validate the `.gitlab-ci.yml` ### Validate the `.gitlab-ci.yml`
......
...@@ -12,10 +12,6 @@ module EE ...@@ -12,10 +12,6 @@ module EE
github github
].freeze ].freeze
EE_RENAMED_TO_INTEGRATION = %w[
github
].to_set.freeze
class_methods do class_methods do
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
...@@ -25,11 +21,6 @@ module EE ...@@ -25,11 +21,6 @@ module EE
integrations += EE_COM_PROJECT_SPECIFIC_INTEGRATION_NAMES if ::Gitlab.com? integrations += EE_COM_PROJECT_SPECIFIC_INTEGRATION_NAMES if ::Gitlab.com?
integrations integrations
end end
override :renamed?
def renamed?(name)
EE_RENAMED_TO_INTEGRATION.include?(name) || super
end
end end
end end
end end
...@@ -144,7 +144,7 @@ module EE ...@@ -144,7 +144,7 @@ module EE
scope :for_plan_name, -> (name) { joins(namespace: { gitlab_subscription: :hosted_plan }).where(plans: { name: name }) } scope :for_plan_name, -> (name) { joins(namespace: { gitlab_subscription: :hosted_plan }).where(plans: { name: name }) }
scope :requiring_code_owner_approval, scope :requiring_code_owner_approval,
-> { joins(:protected_branches).where(protected_branches: { code_owner_approval_required: true }) } -> { joins(:protected_branches).where(protected_branches: { code_owner_approval_required: true }) }
scope :with_active_services, -> { joins(:integrations).merge(::Integration.active) } scope :with_active_integrations, -> { joins(:integrations).merge(::Integration.active) }
scope :github_imported, -> { where(import_type: 'github') } scope :github_imported, -> { where(import_type: 'github') }
scope :with_protected_branches, -> { joins(:protected_branches) } scope :with_protected_branches, -> { joins(:protected_branches) }
scope :with_repositories_enabled, -> { joins(:project_feature).where(project_features: { repository_access_level: ::ProjectFeature::ENABLED }) } scope :with_repositories_enabled, -> { joins(:project_feature).where(project_features: { repository_access_level: ::ProjectFeature::ENABLED }) }
......
...@@ -281,13 +281,13 @@ RSpec.describe Project do ...@@ -281,13 +281,13 @@ RSpec.describe Project do
end end
end end
describe '.with_active_services' do describe '.with_active_integrations' do
it 'returns the correct project' do it 'returns the correct project' do
active_service = create(:service, active: true) active = create(:service, active: true)
inactive_service = create(:service, active: false) inactive = create(:service, active: false)
expect(described_class.with_active_services).to include(active_service.project) expect(described_class.with_active_integrations).to include(active.project)
expect(described_class.with_active_services).not_to include(inactive_service.project) expect(described_class.with_active_integrations).not_to include(inactive.project)
end end
end end
...@@ -939,14 +939,14 @@ RSpec.describe Project do ...@@ -939,14 +939,14 @@ RSpec.describe Project do
before do before do
stub_licensed_features(group_webhooks: true) stub_licensed_features(group_webhooks: true)
end end
let(:fake_service) { double } let(:fake_integration) { double }
shared_examples 'triggering group webhook' do shared_examples 'triggering group webhook' do
it 'executes the hook' do it 'executes the hook' do
expect(fake_service).to receive(:async_execute).once expect(fake_integration).to receive(:async_execute).once
expect(WebHookService).to receive(:new) expect(WebHookService)
.with(group_hook, { some: 'info' }, 'push_hooks') { fake_service } .to receive(:new).with(group_hook, { some: 'info' }, 'push_hooks') { fake_integration }
project.execute_hooks(some: 'info') project.execute_hooks(some: 'info')
end end
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
# batch_count(::Clusters::Cluster.aws_installed.enabled, :cluster_id) # batch_count(::Clusters::Cluster.aws_installed.enabled, :cluster_id)
# batch_count(Namespace.group(:type)) # batch_count(Namespace.group(:type))
# batch_distinct_count(::Project, :creator_id) # batch_distinct_count(::Project, :creator_id)
# batch_distinct_count(::Project.with_active_services.service_desk_enabled.where(time_period), start: ::User.minimum(:id), finish: ::User.maximum(:id)) # batch_distinct_count(::Project.with_active_integrations.service_desk_enabled.where(time_period), start: ::User.minimum(:id), finish: ::User.maximum(:id))
# batch_distinct_count(Project.group(:visibility_level), :creator_id) # batch_distinct_count(Project.group(:visibility_level), :creator_id)
# batch_sum(User, :sign_in_count) # batch_sum(User, :sign_in_count)
# batch_sum(Issue.group(:state_id), :weight)) # batch_sum(Issue.group(:state_id), :weight))
......
...@@ -11,17 +11,17 @@ module Gitlab ...@@ -11,17 +11,17 @@ module Gitlab
# In order to not use a possible complex time consuming query when calculating min and max values, # In order to not use a possible complex time consuming query when calculating min and max values,
# the start and finish can be sent specifically, start and finish should contain max and min values for PRIMARY KEY of # the start and finish can be sent specifically, start and finish should contain max and min values for PRIMARY KEY of
# relation (most cases `id` column) rather than counted attribute eg: # relation (most cases `id` column) rather than counted attribute eg:
# estimate_distinct_count(start: ::Project.with_active_services.minimum(:id), finish: ::Project.with_active_services.maximum(:id)) # estimate_distinct_count(start: ::Project.with_active_integrations.minimum(:id), finish: ::Project.with_active_integrations.maximum(:id))
# #
# Grouped relations are NOT supported yet. # Grouped relations are NOT supported yet.
# #
# @example Usage # @example Usage
# ::Gitlab::Database::PostgresHllBatchDistinctCount.new(::Project, :creator_id).execute # ::Gitlab::Database::PostgresHllBatchDistinctCount.new(::Project, :creator_id).execute
# ::Gitlab::Database::PostgresHllBatchDistinctCount.new(::Project.with_active_services.service_desk_enabled.where(time_period)) # ::Gitlab::Database::PostgresHllBatchDistinctCount.new(::Project.with_active_integrations.service_desk_enabled.where(time_period))
# .execute( # .execute(
# batch_size: 1_000, # batch_size: 1_000,
# start: ::Project.with_active_services.service_desk_enabled.where(time_period).minimum(:id), # start: ::Project.with_active_integrations.service_desk_enabled.where(time_period).minimum(:id),
# finish: ::Project.with_active_services.service_desk_enabled.where(time_period).maximum(:id) # finish: ::Project.with_active_integrations.service_desk_enabled.where(time_period).maximum(:id)
# ) # )
# #
# @note HyperLogLog is an PROBABILISTIC algorithm that ESTIMATES distinct count of given attribute value for supplied relation # @note HyperLogLog is an PROBABILISTIC algorithm that ESTIMATES distinct count of given attribute value for supplied relation
......
...@@ -915,7 +915,7 @@ RSpec.describe Integration do ...@@ -915,7 +915,7 @@ RSpec.describe Integration do
described_class.available_integration_names(include_project_specific: false) described_class.available_integration_names(include_project_specific: false)
end end
it 'does not call dev_services_names with include_dev false' do it 'does not call dev_integration_names with include_dev false' do
expect(described_class).to receive(:integration_names).and_call_original expect(described_class).to receive(:integration_names).and_call_original
expect(described_class).not_to receive(:dev_integration_names) expect(described_class).not_to receive(:dev_integration_names)
expect(described_class).to receive(:project_specific_integration_names).and_call_original expect(described_class).to receive(:project_specific_integration_names).and_call_original
......
...@@ -18,7 +18,7 @@ RSpec.describe Integrations::DroneCi, :use_clean_rails_memory_store_caching do ...@@ -18,7 +18,7 @@ RSpec.describe Integrations::DroneCi, :use_clean_rails_memory_store_caching do
it { is_expected.to validate_presence_of(:token) } it { is_expected.to validate_presence_of(:token) }
it { is_expected.to validate_presence_of(:drone_url) } it { is_expected.to validate_presence_of(:drone_url) }
it_behaves_like 'issue tracker service URL attribute', :drone_url it_behaves_like 'issue tracker integration URL attribute', :drone_url
end end
context 'inactive' do context 'inactive' do
...@@ -66,7 +66,7 @@ RSpec.describe Integrations::DroneCi, :use_clean_rails_memory_store_caching do ...@@ -66,7 +66,7 @@ RSpec.describe Integrations::DroneCi, :use_clean_rails_memory_store_caching do
end end
end end
describe "service page/path methods" do describe "integration page/path methods" do
include_context :drone_ci_integration include_context :drone_ci_integration
it { expect(drone.build_page(sha, branch)).to eq(build_page) } it { expect(drone.build_page(sha, branch)).to eq(build_page) }
......
...@@ -1898,7 +1898,7 @@ RSpec.describe MergeRequest, factory_default: :keep do ...@@ -1898,7 +1898,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
context 'has ci' do context 'has ci' do
it 'returns true if MR has head_pipeline_id and commits' do it 'returns true if MR has head_pipeline_id and commits' do
allow(merge_request).to receive_message_chain(:source_project, :ci_service) { nil } allow(merge_request).to receive_message_chain(:source_project, :ci_integration) { nil }
allow(merge_request).to receive(:head_pipeline_id) { double } allow(merge_request).to receive(:head_pipeline_id) { double }
allow(merge_request).to receive(:has_no_commits?) { false } allow(merge_request).to receive(:has_no_commits?) { false }
...@@ -1906,7 +1906,7 @@ RSpec.describe MergeRequest, factory_default: :keep do ...@@ -1906,7 +1906,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
end end
it 'returns true if MR has any pipeline and commits' do it 'returns true if MR has any pipeline and commits' do
allow(merge_request).to receive_message_chain(:source_project, :ci_service) { nil } allow(merge_request).to receive_message_chain(:source_project, :ci_integration) { nil }
allow(merge_request).to receive(:head_pipeline_id) { nil } allow(merge_request).to receive(:head_pipeline_id) { nil }
allow(merge_request).to receive(:has_no_commits?) { false } allow(merge_request).to receive(:has_no_commits?) { false }
allow(merge_request).to receive(:all_pipelines) { [double] } allow(merge_request).to receive(:all_pipelines) { [double] }
...@@ -1914,8 +1914,8 @@ RSpec.describe MergeRequest, factory_default: :keep do ...@@ -1914,8 +1914,8 @@ RSpec.describe MergeRequest, factory_default: :keep do
expect(merge_request.has_ci?).to be(true) expect(merge_request.has_ci?).to be(true)
end end
it 'returns true if MR has CI service and commits' do it 'returns true if MR has CI integration and commits' do
allow(merge_request).to receive_message_chain(:source_project, :ci_service) { double } allow(merge_request).to receive_message_chain(:source_project, :ci_integration) { double }
allow(merge_request).to receive(:head_pipeline_id) { nil } allow(merge_request).to receive(:head_pipeline_id) { nil }
allow(merge_request).to receive(:has_no_commits?) { false } allow(merge_request).to receive(:has_no_commits?) { false }
allow(merge_request).to receive(:all_pipelines) { [] } allow(merge_request).to receive(:all_pipelines) { [] }
...@@ -1925,8 +1925,8 @@ RSpec.describe MergeRequest, factory_default: :keep do ...@@ -1925,8 +1925,8 @@ RSpec.describe MergeRequest, factory_default: :keep do
end end
context 'has no ci' do context 'has no ci' do
it 'returns false if MR has no CI service nor pipeline, and no commits' do it 'returns false if MR has no CI integration nor pipeline, and no commits' do
allow(merge_request).to receive_message_chain(:source_project, :ci_service) { nil } allow(merge_request).to receive_message_chain(:source_project, :ci_integration) { nil }
allow(merge_request).to receive(:head_pipeline_id) { nil } allow(merge_request).to receive(:head_pipeline_id) { nil }
allow(merge_request).to receive(:all_pipelines) { [] } allow(merge_request).to receive(:all_pipelines) { [] }
allow(merge_request).to receive(:has_no_commits?) { true } allow(merge_request).to receive(:has_no_commits?) { true }
......
...@@ -5418,7 +5418,7 @@ RSpec.describe Project, factory_default: :keep do ...@@ -5418,7 +5418,7 @@ RSpec.describe Project, factory_default: :keep do
end end
end end
describe '#execute_services' do describe '#execute_integrations' do
let(:integration) { create(:integrations_slack, push_events: true, merge_requests_events: false, active: true) } let(:integration) { create(:integrations_slack, push_events: true, merge_requests_events: false, active: true) }
it 'executes integrations with the specified scope' do it 'executes integrations with the specified scope' do
...@@ -5428,7 +5428,7 @@ RSpec.describe Project, factory_default: :keep do ...@@ -5428,7 +5428,7 @@ RSpec.describe Project, factory_default: :keep do
expect(instance).to receive(:async_execute).with(data).once expect(instance).to receive(:async_execute).with(data).once
end end
integration.project.execute_services(data, :push_hooks) integration.project.execute_integrations(data, :push_hooks)
end end
it 'does not execute integration that don\'t match the specified scope' do it 'does not execute integration that don\'t match the specified scope' do
...@@ -5438,7 +5438,7 @@ RSpec.describe Project, factory_default: :keep do ...@@ -5438,7 +5438,7 @@ RSpec.describe Project, factory_default: :keep do
end end
end end
integration.project.execute_services(anything, :merge_request_hooks) integration.project.execute_integrations(anything, :merge_request_hooks)
end end
end end
...@@ -5469,16 +5469,16 @@ RSpec.describe Project, factory_default: :keep do ...@@ -5469,16 +5469,16 @@ RSpec.describe Project, factory_default: :keep do
end end
end end
describe '#has_active_services?' do describe '#has_active_integrations?' do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
it { expect(project.has_active_services?).to be_falsey } it { expect(project.has_active_integrations?).to be_falsey }
it 'returns true when a matching service exists' do it 'returns true when a matching service exists' do
create(:custom_issue_tracker_integration, push_events: true, merge_requests_events: false, project: project) create(:custom_issue_tracker_integration, push_events: true, merge_requests_events: false, project: project)
expect(project.has_active_services?(:merge_request_hooks)).to be_falsey expect(project.has_active_integrations?(:merge_request_hooks)).to be_falsey
expect(project.has_active_services?).to be_truthy expect(project.has_active_integrations?).to be_truthy
end end
end end
...@@ -5911,7 +5911,7 @@ RSpec.describe Project, factory_default: :keep do ...@@ -5911,7 +5911,7 @@ RSpec.describe Project, factory_default: :keep do
allow(subject).to receive(:disabled_integrations).and_return(%w[prometheus]) allow(subject).to receive(:disabled_integrations).and_return(%w[prometheus])
end end
it 'returns only enabled services sorted' do it 'returns only enabled integrations sorted' do
expect(subject.find_or_initialize_integrations).to match [ expect(subject.find_or_initialize_integrations).to match [
have_attributes(title: 'JetBrains TeamCity'), have_attributes(title: 'JetBrains TeamCity'),
have_attributes(title: 'Pushover') have_attributes(title: 'Pushover')
...@@ -5955,7 +5955,7 @@ RSpec.describe Project, factory_default: :keep do ...@@ -5955,7 +5955,7 @@ RSpec.describe Project, factory_default: :keep do
create(:prometheus_integration, :template, api_url: 'https://prometheus.template.com/') create(:prometheus_integration, :template, api_url: 'https://prometheus.template.com/')
end end
it 'builds the service from the instance integration' do it 'builds the integration from the instance integration' do
expect(subject.find_or_initialize_integration('prometheus').api_url).to eq('https://prometheus.instance.com/') expect(subject.find_or_initialize_integration('prometheus').api_url).to eq('https://prometheus.instance.com/')
end end
end end
...@@ -5965,13 +5965,13 @@ RSpec.describe Project, factory_default: :keep do ...@@ -5965,13 +5965,13 @@ RSpec.describe Project, factory_default: :keep do
create(:prometheus_integration, :template, api_url: 'https://prometheus.template.com/') create(:prometheus_integration, :template, api_url: 'https://prometheus.template.com/')
end end
it 'builds the service from the template' do it 'builds the integration from the template' do
expect(subject.find_or_initialize_integration('prometheus').api_url).to eq('https://prometheus.template.com/') expect(subject.find_or_initialize_integration('prometheus').api_url).to eq('https://prometheus.template.com/')
end end
end end
context 'without an exisiting integration, or instance-level or template' do context 'without an exisiting integration, or instance-level or template' do
it 'builds the service' do it 'builds the integration' do
expect(subject.find_or_initialize_integration('prometheus')).to be_a(::Integrations::Prometheus) expect(subject.find_or_initialize_integration('prometheus')).to be_a(::Integrations::Prometheus)
expect(subject.find_or_initialize_integration('prometheus').api_url).to be_nil expect(subject.find_or_initialize_integration('prometheus').api_url).to be_nil
end end
...@@ -6662,16 +6662,16 @@ RSpec.describe Project, factory_default: :keep do ...@@ -6662,16 +6662,16 @@ RSpec.describe Project, factory_default: :keep do
create(:prometheus_integration, project: project, manual_configuration: manual_configuration) create(:prometheus_integration, project: project, manual_configuration: manual_configuration)
end end
context 'when project has an activated prometheus service' do context 'when project has an activated prometheus integration' do
let(:manual_configuration) { true } let(:manual_configuration) { true }
it { is_expected.to be_truthy } it { is_expected.to be_truthy }
end end
context 'when project has an inactive prometheus service' do context 'when project has an inactive prometheus integration' do
let(:manual_configuration) { false } let(:manual_configuration) { false }
it 'the service is marked as inactive' do it 'the integration is marked as inactive' do
expect(subject).to be_falsey expect(subject).to be_falsey
end end
end end
......
...@@ -11,17 +11,17 @@ RSpec.describe MergeRequestPresenter do ...@@ -11,17 +11,17 @@ RSpec.describe MergeRequestPresenter do
subject { described_class.new(resource).ci_status } subject { described_class.new(resource).ci_status }
context 'when no head pipeline' do context 'when no head pipeline' do
it 'return status using CiService' do it 'return status from Ci integration' do
ci_service = double(Integrations::MockCi) ci_integration = double(Integrations::MockCi)
ci_status = double ci_status = double
allow(resource.source_project) allow(resource.source_project)
.to receive(:ci_service) .to receive(:ci_integration)
.and_return(ci_service) .and_return(ci_integration)
allow(resource).to receive(:head_pipeline).and_return(nil) allow(resource).to receive(:head_pipeline).and_return(nil)
expect(ci_service).to receive(:commit_status) expect(ci_integration).to receive(:commit_status)
.with(resource.diff_head_sha, resource.source_branch) .with(resource.diff_head_sha, resource.source_branch)
.and_return(ci_status) .and_return(ci_status)
......
...@@ -59,7 +59,7 @@ RSpec.describe Git::BaseHooksService do ...@@ -59,7 +59,7 @@ RSpec.describe Git::BaseHooksService do
end end
end end
describe 'project hooks and services' do describe 'project hooks and integrations' do
context 'hooks' do context 'hooks' do
before do before do
expect(project).to receive(:has_active_hooks?).and_return(active) expect(project).to receive(:has_active_hooks?).and_return(active)
...@@ -88,45 +88,45 @@ RSpec.describe Git::BaseHooksService do ...@@ -88,45 +88,45 @@ RSpec.describe Git::BaseHooksService do
end end
end end
context 'services' do context 'with integrations' do
before do before do
expect(project).to receive(:has_active_services?).and_return(active) expect(project).to receive(:has_active_integrations?).and_return(active)
end end
context 'active services' do context 'with active integrations' do
let(:active) { true } let(:active) { true }
it 'executes the services' do it 'executes the services' do
expect(subject).to receive(:push_data).at_least(:once).and_call_original expect(subject).to receive(:push_data).at_least(:once).and_call_original
expect(project).to receive(:execute_services) expect(project).to receive(:execute_integrations)
subject.execute subject.execute
end end
end end
context 'inactive services' do context 'with inactive integrations' do
let(:active) { false } let(:active) { false }
it 'does not execute the services' do it 'does not execute the services' do
expect(subject).not_to receive(:push_data) expect(subject).not_to receive(:push_data)
expect(project).not_to receive(:execute_services) expect(project).not_to receive(:execute_integrations)
subject.execute subject.execute
end end
end end
end end
context 'execute_project_hooks param set to false' do context 'when execute_project_hooks param is set to false' do
before do before do
params[:execute_project_hooks] = false params[:execute_project_hooks] = false
allow(project).to receive(:has_active_hooks?).and_return(true) allow(project).to receive(:has_active_hooks?).and_return(true)
allow(project).to receive(:has_active_services?).and_return(true) allow(project).to receive(:has_active_integrations?).and_return(true)
end end
it 'does not execute hooks and services' do it 'does not execute hooks and integrations' do
expect(project).not_to receive(:execute_hooks) expect(project).not_to receive(:execute_hooks)
expect(project).not_to receive(:execute_services) expect(project).not_to receive(:execute_integrations)
subject.execute subject.execute
end end
......
...@@ -323,7 +323,7 @@ RSpec.describe Issues::CloseService do ...@@ -323,7 +323,7 @@ RSpec.describe Issues::CloseService do
context 'when issue is not confidential' do context 'when issue is not confidential' do
it 'executes issue hooks' do it 'executes issue hooks' do
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks) expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks)
expect(project).to receive(:execute_services).with(an_instance_of(Hash), :issue_hooks) expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :issue_hooks)
described_class.new(project: project, current_user: user).close_issue(issue) described_class.new(project: project, current_user: user).close_issue(issue)
end end
...@@ -334,7 +334,7 @@ RSpec.describe Issues::CloseService do ...@@ -334,7 +334,7 @@ RSpec.describe Issues::CloseService do
issue = create(:issue, :confidential, project: project) issue = create(:issue, :confidential, project: project)
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks) expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks)
expect(project).to receive(:execute_services).with(an_instance_of(Hash), :confidential_issue_hooks) expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :confidential_issue_hooks)
described_class.new(project: project, current_user: user).close_issue(issue) described_class.new(project: project, current_user: user).close_issue(issue)
end end
......
...@@ -230,7 +230,7 @@ RSpec.describe Issues::CreateService do ...@@ -230,7 +230,7 @@ RSpec.describe Issues::CreateService do
opts = { title: 'Title', description: 'Description', confidential: false } opts = { title: 'Title', description: 'Description', confidential: false }
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks) expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks)
expect(project).to receive(:execute_services).with(an_instance_of(Hash), :issue_hooks) expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :issue_hooks)
described_class.new(project: project, current_user: user, params: opts, spam_params: spam_params).execute described_class.new(project: project, current_user: user, params: opts, spam_params: spam_params).execute
end end
...@@ -239,7 +239,7 @@ RSpec.describe Issues::CreateService do ...@@ -239,7 +239,7 @@ RSpec.describe Issues::CreateService do
opts = { title: 'Title', description: 'Description', confidential: true } opts = { title: 'Title', description: 'Description', confidential: true }
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks) expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks)
expect(project).to receive(:execute_services).with(an_instance_of(Hash), :confidential_issue_hooks) expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :confidential_issue_hooks)
described_class.new(project: project, current_user: user, params: opts, spam_params: spam_params).execute described_class.new(project: project, current_user: user, params: opts, spam_params: spam_params).execute
end end
......
...@@ -65,7 +65,7 @@ RSpec.describe Issues::ReopenService do ...@@ -65,7 +65,7 @@ RSpec.describe Issues::ReopenService do
context 'when issue is not confidential' do context 'when issue is not confidential' do
it 'executes issue hooks' do it 'executes issue hooks' do
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks) expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks)
expect(project).to receive(:execute_services).with(an_instance_of(Hash), :issue_hooks) expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :issue_hooks)
described_class.new(project: project, current_user: user).execute(issue) described_class.new(project: project, current_user: user).execute(issue)
end end
...@@ -76,7 +76,7 @@ RSpec.describe Issues::ReopenService do ...@@ -76,7 +76,7 @@ RSpec.describe Issues::ReopenService do
issue = create(:issue, :confidential, :closed, project: project) issue = create(:issue, :confidential, :closed, project: project)
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks) expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks)
expect(project).to receive(:execute_services).with(an_instance_of(Hash), :confidential_issue_hooks) expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :confidential_issue_hooks)
described_class.new(project: project, current_user: user).execute(issue) described_class.new(project: project, current_user: user).execute(issue)
end end
......
...@@ -537,7 +537,7 @@ RSpec.describe Issues::UpdateService, :mailer do ...@@ -537,7 +537,7 @@ RSpec.describe Issues::UpdateService, :mailer do
it 'executes confidential issue hooks' do it 'executes confidential issue hooks' do
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks) expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks)
expect(project).to receive(:execute_services).with(an_instance_of(Hash), :confidential_issue_hooks) expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :confidential_issue_hooks)
update_issue(confidential: true) update_issue(confidential: true)
end end
......
...@@ -104,9 +104,9 @@ RSpec.describe MergeRequests::HandleAssigneesChangeService do ...@@ -104,9 +104,9 @@ RSpec.describe MergeRequests::HandleAssigneesChangeService do
context 'when execute_hooks option is set to true' do context 'when execute_hooks option is set to true' do
let(:options) { { execute_hooks: true } } let(:options) { { execute_hooks: true } }
it 'execute hooks and services' do it 'executes hooks and integrations' do
expect(merge_request.project).to receive(:execute_hooks).with(anything, :merge_request_hooks) expect(merge_request.project).to receive(:execute_hooks).with(anything, :merge_request_hooks)
expect(merge_request.project).to receive(:execute_services).with(anything, :merge_request_hooks) expect(merge_request.project).to receive(:execute_integrations).with(anything, :merge_request_hooks)
expect(service).to receive(:enqueue_jira_connect_messages_for).with(merge_request) expect(service).to receive(:enqueue_jira_connect_messages_for).with(merge_request)
execute execute
......
...@@ -21,7 +21,7 @@ RSpec.describe Notes::PostProcessService do ...@@ -21,7 +21,7 @@ RSpec.describe Notes::PostProcessService do
it do it do
expect(project).to receive(:execute_hooks) expect(project).to receive(:execute_hooks)
expect(project).to receive(:execute_services) expect(project).to receive(:execute_integrations)
described_class.new(@note).execute described_class.new(@note).execute
end end
...@@ -29,16 +29,16 @@ RSpec.describe Notes::PostProcessService do ...@@ -29,16 +29,16 @@ RSpec.describe Notes::PostProcessService do
context 'with a confidential issue' do context 'with a confidential issue' do
let(:issue) { create(:issue, :confidential, project: project) } let(:issue) { create(:issue, :confidential, project: project) }
it "doesn't call note hooks/services" do it "doesn't call note hooks/integrations" do
expect(project).not_to receive(:execute_hooks).with(anything, :note_hooks) expect(project).not_to receive(:execute_hooks).with(anything, :note_hooks)
expect(project).not_to receive(:execute_services).with(anything, :note_hooks) expect(project).not_to receive(:execute_integrations).with(anything, :note_hooks)
described_class.new(@note).execute described_class.new(@note).execute
end end
it "calls confidential-note hooks/services" do it "calls confidential-note hooks/integrations" do
expect(project).to receive(:execute_hooks).with(anything, :confidential_note_hooks) expect(project).to receive(:execute_hooks).with(anything, :confidential_note_hooks)
expect(project).to receive(:execute_services).with(anything, :confidential_note_hooks) expect(project).to receive(:execute_integrations).with(anything, :confidential_note_hooks)
described_class.new(@note).execute described_class.new(@note).execute
end end
......
...@@ -13,7 +13,7 @@ RSpec.shared_examples 'creates an alert management alert or errors' do ...@@ -13,7 +13,7 @@ RSpec.shared_examples 'creates an alert management alert or errors' do
it 'executes the alert service hooks' do it 'executes the alert service hooks' do
expect_next_instance_of(AlertManagement::Alert) do |alert| expect_next_instance_of(AlertManagement::Alert) do |alert|
expect(alert).to receive(:execute_services) expect(alert).to receive(:execute_integrations)
end end
subject subject
...@@ -84,7 +84,7 @@ end ...@@ -84,7 +84,7 @@ end
# - `alert`, the alert for which events should be incremented # - `alert`, the alert for which events should be incremented
RSpec.shared_examples 'adds an alert management alert event' do RSpec.shared_examples 'adds an alert management alert event' do
specify do specify do
expect(alert).not_to receive(:execute_services) expect(alert).not_to receive(:execute_integrations)
expect { subject }.to change { alert.reload.events }.by(1) expect { subject }.to change { alert.reload.events }.by(1)
......
...@@ -20,7 +20,7 @@ end ...@@ -20,7 +20,7 @@ end
RSpec.shared_examples 'processes incident issues' do |with_issue: false| RSpec.shared_examples 'processes incident issues' do |with_issue: false|
before do before do
allow_next_instance_of(AlertManagement::Alert) do |alert| allow_next_instance_of(AlertManagement::Alert) do |alert|
allow(alert).to receive(:execute_services) allow(alert).to receive(:execute_integrations)
end end
end end
......
...@@ -378,7 +378,7 @@ RSpec.describe PostReceive do ...@@ -378,7 +378,7 @@ RSpec.describe PostReceive do
allow(Project).to receive(:find_by).and_return(project) allow(Project).to receive(:find_by).and_return(project)
expect(project).to receive(:execute_hooks).twice expect(project).to receive(:execute_hooks).twice
expect(project).to receive(:execute_services).twice expect(project).to receive(:execute_integrations).twice
perform perform
end end
......
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