2019-10-24 20:06:14 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-23 14:24:06 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe ProtectedBranchPolicy do
|
2018-03-23 14:24:06 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:name) { 'feature' }
|
|
|
|
let(:protected_branch) { create(:protected_branch, name: name) }
|
|
|
|
let(:project) { protected_branch.project }
|
|
|
|
|
|
|
|
subject { described_class.new(user, protected_branch) }
|
|
|
|
|
2018-07-11 10:36:08 -04:00
|
|
|
it 'branches can be updated via project maintainers' do
|
|
|
|
project.add_maintainer(user)
|
2018-03-23 14:24:06 -04:00
|
|
|
|
2018-03-24 22:45:43 -04:00
|
|
|
is_expected.to be_allowed(:update_protected_branch)
|
2018-03-23 14:24:06 -04:00
|
|
|
end
|
|
|
|
|
2018-03-24 22:45:43 -04:00
|
|
|
it "branches can't be updated by guests" do
|
|
|
|
project.add_guest(user)
|
2018-03-23 14:24:06 -04:00
|
|
|
|
2018-03-24 22:45:43 -04:00
|
|
|
is_expected.to be_disallowed(:update_protected_branch)
|
2018-03-23 14:24:06 -04:00
|
|
|
end
|
|
|
|
end
|