diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-12-27 13:25:54 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-12-27 13:25:54 +0300 |
commit | d0848c085892f2e9504fcdc524c92b9e0156f2ce (patch) | |
tree | f83d25b90665047e3167051f93d55048811f2d50 /spec | |
parent | 5fabc1fd3b261d098bc8eb80b2750e14a2c979ea (diff) | |
parent | 1a24800643c64da3b67790a813edfc4e697224d3 (diff) |
Merge branch 'sh-use-system-path-for-appearance-logos' into 'master'
Use system paths for appearance logos
Closes gitlab-ee#6778
See merge request gitlab-org/gitlab-ce!24024
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/appearances.rb | 4 | ||||
-rw-r--r-- | spec/models/appearance_spec.rb | 30 |
2 files changed, 34 insertions, 0 deletions
diff --git a/spec/factories/appearances.rb b/spec/factories/appearances.rb index 18c7453bd1b..dd5129229d4 100644 --- a/spec/factories/appearances.rb +++ b/spec/factories/appearances.rb @@ -15,6 +15,10 @@ FactoryBot.define do header_logo { fixture_file_upload('spec/fixtures/dk.png') } end + trait :with_favicon do + favicon { fixture_file_upload('spec/fixtures/dk.png') } + end + trait :with_logos do with_logo with_header_logo 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 |