Commit 5374f423 authored by Krasimir Angelov's avatar Krasimir Angelov

Add tests for ProjectFeature's #public_pages? and #private_pages?

parent 91af0cf4
......@@ -174,4 +174,58 @@ describe ProjectFeature do
it { is_expected.to eq(ProjectFeature::ENABLED) }
end
end
describe '#public_pages?' do
it 'returns true if Pages access controll is not enabled' do
stub_config(pages: { access_control: false })
project_feature = described_class.new
expect(project_feature.public_pages?).to eq(true)
end
context 'Pages access control is enabled' do
before do
stub_config(pages: { access_control: true })
end
it 'returns true if Pages access level is public' do
project_feature = described_class.new(pages_access_level: described_class::PUBLIC)
expect(project_feature.public_pages?).to eq(true)
end
it 'returns true if Pages access level is enabled and the project is public' do
project = build(:project, :public)
project_feature = described_class.new(project: project, pages_access_level: described_class::ENABLED)
expect(project_feature.public_pages?).to eq(true)
end
it 'returns false if pages or the project are not public' do
project = build(:project, :private)
project_feature = described_class.new(project: project, pages_access_level: described_class::ENABLED)
expect(project_feature.public_pages?).to eq(false)
end
end
describe '#private_pages?' do
subject(:project_feature) { described_class.new }
it 'returns false if public_pages? is true' do
expect(project_feature).to receive(:public_pages?).and_return(true)
expect(project_feature.private_pages?).to eq(false)
end
it 'returns true if public_pages? is false' do
expect(project_feature).to receive(:public_pages?).and_return(false)
expect(project_feature.private_pages?).to eq(true)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment