diff options
Diffstat (limited to 'spec/factories')
-rw-r--r-- | spec/factories/protected_branches.rb | 50 | ||||
-rw-r--r-- | spec/factories/protected_tags.rb | 36 |
2 files changed, 71 insertions, 15 deletions
diff --git a/spec/factories/protected_branches.rb b/spec/factories/protected_branches.rb index b2695e0482a..3dbace4b38a 100644 --- a/spec/factories/protected_branches.rb +++ b/spec/factories/protected_branches.rb @@ -3,26 +3,58 @@ FactoryGirl.define do name project - after(:build) do |protected_branch| - protected_branch.push_access_levels.new(access_level: Gitlab::Access::MASTER) - protected_branch.merge_access_levels.new(access_level: Gitlab::Access::MASTER) + transient do + default_push_level true + default_merge_level true + default_access_level true end trait :developers_can_push do - after(:create) do |protected_branch| - protected_branch.push_access_levels.first.update!(access_level: Gitlab::Access::DEVELOPER) + transient do + default_push_level false + end + + after(:build) do |protected_branch| + protected_branch.push_access_levels.new(access_level: Gitlab::Access::DEVELOPER) end end trait :developers_can_merge do - after(:create) do |protected_branch| - protected_branch.merge_access_levels.first.update!(access_level: Gitlab::Access::DEVELOPER) + transient do + default_merge_level false + end + + after(:build) do |protected_branch| + protected_branch.merge_access_levels.new(access_level: Gitlab::Access::DEVELOPER) end end trait :no_one_can_push do - after(:create) do |protected_branch| - protected_branch.push_access_levels.first.update!(access_level: Gitlab::Access::NO_ACCESS) + 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 end diff --git a/spec/factories/protected_tags.rb b/spec/factories/protected_tags.rb index d8e90ae1ee1..225588b23cc 100644 --- a/spec/factories/protected_tags.rb +++ b/spec/factories/protected_tags.rb @@ -3,19 +3,43 @@ FactoryGirl.define do name project - after(:build) do |protected_tag| - protected_tag.create_access_levels.new(access_level: Gitlab::Access::MASTER) + transient do + default_access_level true end trait :developers_can_create do - after(:create) do |protected_tag| - protected_tag.create_access_levels.first.update!(access_level: Gitlab::Access::DEVELOPER) + 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 - after(:create) do |protected_tag| - protected_tag.create_access_levels.first.update!(access_level: Gitlab::Access::NO_ACCESS) + 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 :masters_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::MASTER) + end + end + + after(:build) do |protected_tag, evaluator| + if evaluator.default_access_level + protected_tag.create_access_levels.new(access_level: Gitlab::Access::MASTER) end end end |