protected_branches.rb 885 Bytes
Newer Older
1 2 3 4
FactoryGirl.define do
  factory :protected_branch do
    name
    project
5

6
    after(:build) do |protected_branch|
7 8
      protected_branch.push_access_levels.new(access_level: Gitlab::Access::MASTER)
      protected_branch.merge_access_levels.new(access_level: Gitlab::Access::MASTER)
9 10 11
    end

    trait :developers_can_push do
12
      after(:create) do |protected_branch|
13
        protected_branch.push_access_levels.first.update!(access_level: Gitlab::Access::DEVELOPER)
14
      end
15 16 17
    end

    trait :developers_can_merge do
18
      after(:create) do |protected_branch|
19
        protected_branch.merge_access_levels.first.update!(access_level: Gitlab::Access::DEVELOPER)
20
      end
21 22 23
    end

    trait :no_one_can_push do
24
      after(:create) do |protected_branch|
25
        protected_branch.push_access_levels.first.update!(access_level: Gitlab::Access::NO_ACCESS)
26
      end
27
    end
28 29
  end
end