gitlab-org--gitlab-foss/spec/lib/gitlab/git_access_wiki_spec.rb

53 lines
1.4 KiB
Ruby
Raw Normal View History

require 'spec_helper'
2015-12-09 05:55:36 -05:00
describe Gitlab::GitAccessWiki, lib: true do
let(:access) { Gitlab::GitAccessWiki.new(user, project, 'web', authentication_abilities: authentication_abilities) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:authentication_abilities) do
2016-09-15 09:40:53 -04:00
[
:read_project,
:download_code,
:push_code
]
end
describe 'push_allowed?' do
before do
create(:protected_branch, name: 'master', project: project)
project.team << [user, :developer]
end
subject { access.check('git-receive-pack', changes) }
it { expect(subject.allowed?).to be_truthy }
end
def changes
['6f6d7e7ed 570e7b2ab refs/heads/master']
end
describe '#access_check_download!' do
subject { access.check('git-upload-pack', '_any') }
before do
project.team << [user, :developer]
end
context 'when wiki feature is enabled' do
it 'give access to download wiki code' do
expect(subject.allowed?).to be_truthy
end
end
context 'when wiki feature is disabled' do
it 'does not give access to download wiki code' do
project.project_feature.update_attribute(:wiki_access_level, ProjectFeature::DISABLED)
expect(subject.allowed?).to be_falsey
expect(subject.message).to match(/You are not allowed to download code/)
end
end
end
end