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

ios_specific_templates_experiment.rb « experiments « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1731fa87be80169fbcfaa1a433f8dcb09e9c9e77 (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
27
28
29
30
# frozen_string_literal: true

class IosSpecificTemplatesExperiment < ApplicationExperiment
  before_run(if: :skip_experiment) { throw(:abort) } # rubocop:disable Cop/BanCatchThrow

  private

  def skip_experiment
    actor_not_able_to_create_pipelines? ||
      project_targets_non_ios_platforms? ||
      project_has_gitlab_ci? ||
      project_has_pipelines?
  end

  def actor_not_able_to_create_pipelines?
    !context.actor.is_a?(User) || !context.actor.can?(:create_pipeline, context.project)
  end

  def project_targets_non_ios_platforms?
    context.project.project_setting.target_platforms.exclude?('ios')
  end

  def project_has_gitlab_ci?
    context.project.has_ci? && context.project.builds_enabled?
  end

  def project_has_pipelines?
    context.project.all_pipelines.count > 0
  end
end