debian-mirror-gitlab/spec/models/guest_spec.rb

48 lines
1.5 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2016-11-24 13:41:30 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe Guest do
2020-03-13 15:44:24 +05:30
let_it_be(:public_project, reload: true) { create(:project, :public) }
let_it_be(:private_project) { create(:project, :private) }
let_it_be(:internal_project) { create(:project, :internal) }
2016-11-24 13:41:30 +05:30
describe '.can_pull?' do
context 'when project is private' do
it 'does not allow to pull the repo' do
2017-09-10 17:25:29 +05:30
expect(described_class.can?(:download_code, private_project)).to eq(false)
2016-11-24 13:41:30 +05:30
end
end
context 'when project is internal' do
it 'does not allow to pull the repo' do
2017-09-10 17:25:29 +05:30
expect(described_class.can?(:download_code, internal_project)).to eq(false)
2016-11-24 13:41:30 +05:30
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-09-10 17:25:29 +05:30
expect(described_class.can?(:download_code, public_project)).to eq(false)
2016-11-24 13:41:30 +05:30
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-09-10 17:25:29 +05:30
expect(described_class.can?(:download_code, public_project)).to eq(false)
2016-11-24 13:41:30 +05:30
end
end
context 'when repository is enabled' do
it 'allows to pull the repo' do
2017-09-10 17:25:29 +05:30
expect(described_class.can?(:download_code, public_project)).to eq(true)
2016-11-24 13:41:30 +05:30
end
end
end
end
end