Welcome to mirror list, hosted at ThFree Co, Russian Federation.

project_alerting_settings.rb « factories « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ef0beb6b98ab194bd9b15178bf328b7d80681fc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

FactoryBot.define do
  factory :project_alerting_setting, class: 'Alerting::ProjectAlertingSetting' do
    project
    token { SecureRandom.hex }

    # Remove in next required stop after %16.4
    # https://gitlab.com/gitlab-org/gitlab/-/issues/338838
    transient do
      sync_http_integrations { false }
    end

    trait :with_http_integration do
      sync_http_integrations { true }
    end

    # for simplicity, let factory exclude the AlertManagement::HttpIntegration
    # created in after_commit callback on model
    after(:create) do |setting, evaluator|
      next if evaluator.sync_http_integrations

      setting.project.alert_management_http_integrations.last!.destroy!
    end
  end
end