debian-mirror-gitlab/spec/lib/gitlab/access/branch_protection_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
1.8 KiB
Ruby
Raw Normal View History

2019-03-02 22:35:43 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Access::BranchProtection do
2021-03-11 19:13:27 +05:30
using RSpec::Parameterized::TableSyntax
2019-03-02 22:35:43 +05:30
2021-03-11 19:13:27 +05:30
describe '#any?' do
2019-03-02 22:35:43 +05:30
where(:level, :result) do
Gitlab::Access::PROTECTION_NONE | false
Gitlab::Access::PROTECTION_DEV_CAN_PUSH | true
Gitlab::Access::PROTECTION_DEV_CAN_MERGE | true
Gitlab::Access::PROTECTION_FULL | true
end
with_them do
it { expect(described_class.new(level).any?).to eq(result) }
end
end
describe '#developer_can_push?' do
where(:level, :result) do
Gitlab::Access::PROTECTION_NONE | false
Gitlab::Access::PROTECTION_DEV_CAN_PUSH | true
Gitlab::Access::PROTECTION_DEV_CAN_MERGE | false
Gitlab::Access::PROTECTION_FULL | false
end
with_them do
it do
expect(described_class.new(level).developer_can_push?).to eq(result)
end
end
end
describe '#developer_can_merge?' do
where(:level, :result) do
Gitlab::Access::PROTECTION_NONE | false
Gitlab::Access::PROTECTION_DEV_CAN_PUSH | false
Gitlab::Access::PROTECTION_DEV_CAN_MERGE | true
Gitlab::Access::PROTECTION_FULL | false
end
with_them do
it do
expect(described_class.new(level).developer_can_merge?).to eq(result)
end
end
end
2020-04-08 14:13:33 +05:30
describe '#fully_protected?' do
where(:level, :result) do
Gitlab::Access::PROTECTION_NONE | false
Gitlab::Access::PROTECTION_DEV_CAN_PUSH | false
Gitlab::Access::PROTECTION_DEV_CAN_MERGE | false
Gitlab::Access::PROTECTION_FULL | true
end
with_them do
it do
expect(described_class.new(level).fully_protected?).to eq(result)
end
end
end
2019-03-02 22:35:43 +05:30
end