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

    after(:create) do |protected_branch|
7 8
      protected_branch.create_push_access_level!(access_level: Gitlab::Access::MASTER)
      protected_branch.create_merge_access_level!(access_level: Gitlab::Access::MASTER)
9 10 11
    end

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

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

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