Commit 58171a67 authored by Rémy Coutable's avatar Rémy Coutable

Extract EE-specific code from spec/factories/protected_tags.rb

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent da0d263a
# frozen_string_literal: true
FactoryBot.modify do
factory :protected_tag do
transient do
authorize_user_to_create nil
authorize_group_to_create nil
end
trait :developers_can_create do
transient do
default_access_level false
end
after(:build) do |protected_tag|
protected_tag.create_access_levels.new(access_level: Gitlab::Access::DEVELOPER)
end
end
trait :no_one_can_create do
transient do
default_access_level false
end
after(:build) do |protected_tag|
protected_tag.create_access_levels.new(access_level: Gitlab::Access::NO_ACCESS)
end
end
trait :maintainers_can_create do
transient do
default_access_level false
end
after(:build) do |protected_tag|
protected_tag.create_access_levels.new(access_level: Gitlab::Access::MAINTAINER)
end
end
after(:build) do |protected_tag, evaluator|
if evaluator.authorize_user_to_create
protected_tag.create_access_levels.new(user: evaluator.authorize_user_to_create)
end
if evaluator.authorize_group_to_create
protected_tag.create_access_levels.new(group: evaluator.authorize_group_to_create)
end
end
end
end
......@@ -4,10 +4,6 @@ FactoryBot.define do
project
transient do
# EE
authorize_user_to_create nil
authorize_group_to_create nil
default_access_level true
end
......@@ -42,15 +38,6 @@ FactoryBot.define do
end
after(:build) do |protected_tag, evaluator|
# EE
if evaluator.authorize_user_to_create
protected_tag.create_access_levels.new(user: evaluator.authorize_user_to_create)
end
if evaluator.authorize_group_to_create
protected_tag.create_access_levels.new(group: evaluator.authorize_group_to_create)
end
if evaluator.default_access_level
protected_tag.create_access_levels.new(access_level: Gitlab::Access::MAINTAINER)
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