diff options
author | Krasimir Angelov <kangelov@gitlab.com> | 2019-09-06 17:20:05 +1200 |
---|---|---|
committer | Krasimir Angelov <kangelov@gitlab.com> | 2019-09-10 13:56:07 +1200 |
commit | 676675dc0b95194be72dfa13829b5ba06e0d1844 (patch) | |
tree | 21a2227c9ea34b715016456ef37e2f0b4eed5df2 /spec/models/pages/lookup_path_spec.rb | |
parent | 8ce331c206dd97bbfc672a554afb8bc0f8039983 (diff) | |
download | gitlab-ce-676675dc0b95194be72dfa13829b5ba06e0d1844.tar.gz |
Add support for custom domains to the internal Pages API
Update the `/internal/pages` endpoint to return virtual domain
configuration for custom domains.
Diffstat (limited to 'spec/models/pages/lookup_path_spec.rb')
-rw-r--r-- | spec/models/pages/lookup_path_spec.rb | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/spec/models/pages/lookup_path_spec.rb b/spec/models/pages/lookup_path_spec.rb new file mode 100644 index 00000000000..2146b0c9abd --- /dev/null +++ b/spec/models/pages/lookup_path_spec.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Pages::LookupPath do + let(:project) do + instance_double(Project, + id: 12345, + private_pages?: true, + pages_https_only?: true, + full_path: 'the/full/path' + ) + end + + subject(:lookup_path) { described_class.new(project) } + + describe '#project_id' do + it 'delegates to Project#id' do + expect(lookup_path.project_id).to eq(12345) + end + end + + describe '#access_control' do + it 'delegates to Project#private_pages?' do + expect(lookup_path.access_control).to eq(true) + end + end + + describe '#https_only' do + subject(:lookup_path) { described_class.new(project, domain: domain) } + + context 'when no domain provided' do + let(:domain) { nil } + + it 'delegates to Project#pages_https_only?' do + expect(lookup_path.https_only).to eq(true) + end + end + + context 'when there is domain provided' do + let(:domain) { instance_double(PagesDomain, https?: false) } + + it 'takes into account the https setting of the domain' do + expect(lookup_path.https_only).to eq(false) + end + end + end + + describe '#source' do + it 'sets the source type to "file"' do + expect(lookup_path.source[:type]).to eq('file') + end + + it 'sets the source path to the project full path suffixed with "public/' do + expect(lookup_path.source[:path]).to eq('the/full/path/public/') + end + end + + describe '#prefix' do + it 'returns "/"' do + expect(lookup_path.prefix).to eq('/') + end + end +end |