diff options
author | Krasimir Angelov <kangelov@gitlab.com> | 2019-09-11 05:25:21 +0300 |
---|---|---|
committer | Krasimir Angelov <kangelov@gitlab.com> | 2019-09-11 05:25:21 +0300 |
commit | 5374f423204386a4c3e6ab887214de58c0113d75 (patch) | |
tree | ec8379447d6f228fd8e4cd90c2537c8f02feb594 /spec | |
parent | 91af0cf4070c4017cd52d8bf621a2d9de1f4b315 (diff) |
Add tests for ProjectFeature's #public_pages? and #private_pages?61927-pages-custom-domain-virtual-domain
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/project_feature_spec.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/models/project_feature_spec.rb b/spec/models/project_feature_spec.rb index dc7a8433064..e6505bb4a51 100644 --- a/spec/models/project_feature_spec.rb +++ b/spec/models/project_feature_spec.rb @@ -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 |