debian-mirror-gitlab/spec/models/concerns/protected_ref_access_spec.rb

46 lines
1.2 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2018-03-27 19:54:05 +05:30
require 'spec_helper'
describe ProtectedRefAccess do
2019-07-07 11:18:12 +05:30
include ExternalAuthorizationServiceHelpers
2018-03-27 19:54:05 +05:30
subject(:protected_ref_access) do
2018-11-18 11:00:15 +05:30
create(:protected_branch, :maintainers_can_push).push_access_levels.first
2018-03-27 19:54:05 +05:30
end
let(:project) { protected_ref_access.project }
describe '#check_access' do
it 'is always true for admins' do
admin = create(:admin)
expect(protected_ref_access.check_access(admin)).to be_truthy
end
2018-11-18 11:00:15 +05:30
it 'is true for maintainers' do
maintainer = create(:user)
project.add_maintainer(maintainer)
2018-03-27 19:54:05 +05:30
2018-11-18 11:00:15 +05:30
expect(protected_ref_access.check_access(maintainer)).to be_truthy
2018-03-27 19:54:05 +05:30
end
it 'is for developers of the project' do
developer = create(:user)
project.add_developer(developer)
expect(protected_ref_access.check_access(developer)).to be_falsy
end
2019-07-07 11:18:12 +05:30
context 'external authorization' do
it 'is false if external authorization denies access' do
maintainer = create(:user)
project.add_maintainer(maintainer)
external_service_deny_access(maintainer, project)
expect(protected_ref_access.check_access(maintainer)).to be_falsey
end
end
2018-03-27 19:54:05 +05:30
end
end