debian-mirror-gitlab/spec/factories/protected_branches.rb

68 lines
1.7 KiB
Ruby
Raw Normal View History

2016-06-02 11:05:42 +05:30
FactoryGirl.define do
factory :protected_branch do
name
project
2016-09-13 17:45:13 +05:30
2017-09-10 17:25:29 +05:30
transient do
default_push_level true
default_merge_level true
default_access_level true
2016-09-13 17:45:13 +05:30
end
trait :developers_can_push do
2017-09-10 17:25:29 +05:30
transient do
default_push_level false
end
after(:build) do |protected_branch|
protected_branch.push_access_levels.new(access_level: Gitlab::Access::DEVELOPER)
2016-09-13 17:45:13 +05:30
end
end
trait :developers_can_merge do
2017-09-10 17:25:29 +05:30
transient do
default_merge_level false
end
after(:build) do |protected_branch|
protected_branch.merge_access_levels.new(access_level: Gitlab::Access::DEVELOPER)
2016-09-13 17:45:13 +05:30
end
end
trait :no_one_can_push do
2017-09-10 17:25:29 +05:30
transient do
default_push_level false
end
after(:build) do |protected_branch|
protected_branch.push_access_levels.new(access_level: Gitlab::Access::NO_ACCESS)
end
end
trait :masters_can_push do
transient do
default_push_level false
end
after(:build) do |protected_branch|
protected_branch.push_access_levels.new(access_level: Gitlab::Access::MASTER)
end
end
after(:build) do |protected_branch, evaluator|
if evaluator.default_access_level && evaluator.default_push_level
protected_branch.push_access_levels.new(access_level: Gitlab::Access::MASTER)
end
if evaluator.default_access_level && evaluator.default_merge_level
protected_branch.merge_access_levels.new(access_level: Gitlab::Access::MASTER)
end
end
trait :no_one_can_merge do
2016-09-13 17:45:13 +05:30
after(:create) do |protected_branch|
2017-09-10 17:25:29 +05:30
protected_branch.merge_access_levels.first.update!(access_level: Gitlab::Access::NO_ACCESS)
2016-09-13 17:45:13 +05:30
end
end
2016-06-02 11:05:42 +05:30
end
end