diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-07-27 21:45:17 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-07-28 18:55:29 +0800 |
commit | f35563b2385b6c1261d4150a14671367b3631615 (patch) | |
tree | d4d5432a066ea9c1eaace77ed0a475640e4d9cb3 /spec/factories/protected_branches.rb | |
parent | 190fae5f0cef11d68c7385be0c4013931796f958 (diff) | |
download | gitlab-ce-f35563b2385b6c1261d4150a14671367b3631615.tar.gz |
Make access level more compatible with EE
So the behaviour would be similar in CE and EE
Diffstat (limited to 'spec/factories/protected_branches.rb')
-rw-r--r-- | spec/factories/protected_branches.rb | 50 |
1 files changed, 41 insertions, 9 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 |