2016-11-02 21:50:44 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 14:24:02 +00:00
|
|
|
describe Guest do
|
2017-01-26 22:44:58 +00:00
|
|
|
let(:public_project) { build_stubbed(:empty_project, :public) }
|
|
|
|
let(:private_project) { build_stubbed(:empty_project, :private) }
|
|
|
|
let(:internal_project) { build_stubbed(:empty_project, :internal) }
|
2016-11-02 21:50:44 +00:00
|
|
|
|
|
|
|
describe '.can_pull?' do
|
|
|
|
context 'when project is private' do
|
|
|
|
it 'does not allow to pull the repo' do
|
2017-07-25 17:09:00 +00:00
|
|
|
expect(described_class.can?(:download_code, private_project)).to eq(false)
|
2016-11-02 21:50:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when project is internal' do
|
|
|
|
it 'does not allow to pull the repo' do
|
2017-07-25 17:09:00 +00:00
|
|
|
expect(described_class.can?(:download_code, internal_project)).to eq(false)
|
2016-11-02 21:50:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when project is public' do
|
|
|
|
context 'when repository is disabled' do
|
|
|
|
it 'does not allow to pull the repo' do
|
|
|
|
public_project.project_feature.update_attribute(:repository_access_level, ProjectFeature::DISABLED)
|
|
|
|
|
2017-07-25 17:09:00 +00:00
|
|
|
expect(described_class.can?(:download_code, public_project)).to eq(false)
|
2016-11-02 21:50:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when repository is accessible only by team members' do
|
|
|
|
it 'does not allow to pull the repo' do
|
|
|
|
public_project.project_feature.update_attribute(:repository_access_level, ProjectFeature::PRIVATE)
|
|
|
|
|
2017-07-25 17:09:00 +00:00
|
|
|
expect(described_class.can?(:download_code, public_project)).to eq(false)
|
2016-11-02 21:50:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when repository is enabled' do
|
|
|
|
it 'allows to pull the repo' do
|
2017-07-25 17:09:00 +00:00
|
|
|
expect(described_class.can?(:download_code, public_project)).to eq(true)
|
2016-11-02 21:50:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|