gitlab-org--gitlab-foss/spec/factories/ci/runners.rb

62 lines
1.2 KiB
Ruby
Raw Normal View History

FactoryBot.define do
factory :ci_runner, class: Ci::Runner do
sequence(:description) { |n| "My runner#{n}" }
2015-08-25 21:42:46 -04:00
platform "darwin"
active true
2017-09-02 03:31:14 -04:00
access_level :not_protected
2015-08-25 21:42:46 -04:00
runner_type :instance_type
2018-05-23 09:29:48 -04:00
trait :online do
contacted_at { Time.now }
2018-05-23 09:29:48 -04:00
end
trait :instance do
runner_type :instance_type
2015-08-25 21:42:46 -04:00
end
trait :group do
runner_type :group_type
2018-05-28 06:55:13 -04:00
after(:build) do |runner, evaluator|
runner.groups << build(:group) if runner.groups.empty?
end
end
trait :project do
runner_type :project_type
2018-05-28 06:55:13 -04:00
after(:build) do |runner, evaluator|
runner.projects << build(:project) if runner.projects.empty?
end
end
2018-05-28 11:58:46 -04:00
trait :without_projects do
# we use that to create invalid runner:
# the one without projects
after(:create) do |runner, evaluator|
runner.runner_projects.delete_all
end
end
trait :inactive do
active false
end
trait :ref_protected do
access_level :ref_protected
end
trait :tagged_only do
run_untagged false
tag_list %w(tag1 tag2)
end
trait :locked do
locked true
end
2015-08-25 21:42:46 -04:00
end
end