diff options
author | Stan Hu <stanhu@gmail.com> | 2018-12-25 11:24:00 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-12-25 19:22:34 +0300 |
commit | 7036f75f6710d5b2cb188864c3c75e06721a755f (patch) | |
tree | 75d10c9f6ed4e332a3dec12ebb63e04b1f4a60b2 /spec/models/appearance_spec.rb | |
parent | 5dc656fc1f053d397ad1e6c1d85a815f03a5d634 (diff) |
Use system paths for appearance logos
When object storage is enabled, the logos used to customize a GitLab
appearance causes the time-limited URLs to be used. We fix this
by forcing all of these URLs to use the /uploads/-/system prefix
so that they will always be proxied through GitLab.
Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/6778
Diffstat (limited to 'spec/models/appearance_spec.rb')
-rw-r--r-- | spec/models/appearance_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/models/appearance_spec.rb b/spec/models/appearance_spec.rb index 35415030154..ec2e7d672f0 100644 --- a/spec/models/appearance_spec.rb +++ b/spec/models/appearance_spec.rb @@ -26,4 +26,34 @@ describe Appearance do let(:uploader_class) { AttachmentUploader } end end + + shared_examples 'logo paths' do |logo_type| + let(:appearance) { create(:appearance, "with_#{logo_type}".to_sym) } + let(:filename) { 'dk.png' } + let(:expected_path) { "/uploads/-/system/appearance/#{logo_type}/#{appearance.id}/#{filename}" } + + it 'returns nil when there is no upload' do + expect(subject.send("#{logo_type}_path")).to be_nil + end + + it 'returns a local path using the system route' do + expect(appearance.send("#{logo_type}_path")).to eq(expected_path) + end + + describe 'with asset host configured' do + let(:asset_host) { 'https://gitlab-assets.example.com' } + + before do + allow(ActionController::Base).to receive(:asset_host) { asset_host } + end + + it 'returns a full URL with the system path' do + expect(appearance.send("#{logo_type}_path")).to eq("#{asset_host}#{expected_path}") + end + end + end + + %i(logo header_logo favicon).each do |logo_type| + it_behaves_like 'logo paths', logo_type + end end |