diff options
Diffstat (limited to 'spec/helpers/appearances_helper_spec.rb')
-rw-r--r-- | spec/helpers/appearances_helper_spec.rb | 79 |
1 files changed, 76 insertions, 3 deletions
diff --git a/spec/helpers/appearances_helper_spec.rb b/spec/helpers/appearances_helper_spec.rb index 8673353996e..2b0192d24b3 100644 --- a/spec/helpers/appearances_helper_spec.rb +++ b/spec/helpers/appearances_helper_spec.rb @@ -10,17 +10,90 @@ RSpec.describe AppearancesHelper do allow(helper).to receive(:current_user).and_return(user) end - describe '#appearance_short_name' do + describe 'pwa icon scaled' do + before do + stub_config_setting(relative_url_root: '/relative_root') + end + + shared_examples 'gets icon path' do |width| + let!(:width) { width } + + it 'returns path of icon' do + expect(helper.appearance_pwa_icon_path_scaled(width)).to match(result) + end + end + + context 'with custom icon' do + let!(:appearance) { create(:appearance, :with_pwa_icon) } + let!(:result) { "/relative_root/uploads/-/system/appearance/pwa_icon/#{appearance.id}/dk.png?width=#{width}" } + + it_behaves_like 'gets icon path', 192 + it_behaves_like 'gets icon path', 512 + end + + context 'with default icon' do + let!(:result) { "/relative_root/-/pwa-icons/logo-#{width}.png" } + + it_behaves_like 'gets icon path', 192 + it_behaves_like 'gets icon path', 512 + end + + it 'returns path of maskable logo' do + expect(helper.appearance_maskable_logo).to match('/relative_root/-/pwa-icons/maskable-logo.png') + end + + context 'with wrong input' do + let!(:result) { nil } + + it_behaves_like 'gets icon path', 19200 + end + + context 'when path is append to root' do + it 'appends root and path' do + expect(helper.append_root_path('/works_just_fine')).to match('/relative_root/works_just_fine') + end + end + end + + describe '#appearance_pwa_name' do it 'returns the default value' do create(:appearance) - expect(helper.appearance_short_name).to match('GitLab') + expect(helper.appearance_pwa_name).to match('GitLab') + end + + it 'returns the customized value' do + create(:appearance, pwa_name: 'GitLab as PWA') + + expect(helper.appearance_pwa_name).to match('GitLab as PWA') + end + end + + describe '#appearance_pwa_short_name' do + it 'returns the default value' do + create(:appearance) + + expect(helper.appearance_pwa_short_name).to match('GitLab') end it 'returns the customized value' do create(:appearance, pwa_short_name: 'Short') - expect(helper.appearance_short_name).to match('Short') + expect(helper.appearance_pwa_short_name).to match('Short') + end + end + + describe '#appearance_pwa_description' do + it 'returns the default value' do + create(:appearance) + + expect(helper.appearance_pwa_description).to include('The complete DevOps platform.') + end + + it 'returns the customized value' do + create(:appearance, pwa_description: 'This is a description') + + expect(helper.appearance_pwa_description).to match('This is a description') end end |