2017-09-26 11:04:37 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-09-28 04:45:50 -04:00
|
|
|
RSpec.describe Gitlab::Favicon, :request_store do
|
2017-09-28 07:57:08 -04:00
|
|
|
describe '.main' do
|
2017-12-07 07:15:49 -05:00
|
|
|
it 'defaults to favicon.png' do
|
2017-09-26 11:04:37 -04:00
|
|
|
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('production'))
|
2017-12-07 07:15:49 -05:00
|
|
|
expect(described_class.main).to match_asset_path '/assets/favicon.png'
|
2017-09-26 11:04:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has blue favicon for development' do
|
|
|
|
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('development'))
|
2017-12-07 07:15:49 -05:00
|
|
|
expect(described_class.main).to match_asset_path '/assets/favicon-blue.png'
|
2017-09-26 11:04:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has yellow favicon for canary' do
|
|
|
|
stub_env('CANARY', 'true')
|
2017-12-07 07:15:49 -05:00
|
|
|
expect(described_class.main).to match_asset_path 'favicon-yellow.png'
|
2017-09-26 11:04:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'uses the custom favicon if a favicon appearance is present' do
|
2018-06-11 07:54:25 -04:00
|
|
|
create :appearance, favicon: fixture_file_upload('spec/fixtures/dk.png')
|
2018-06-15 06:28:23 -04:00
|
|
|
expect(described_class.main).to match %r{/uploads/-/system/appearance/favicon/\d+/dk.png}
|
2017-09-26 11:04:37 -04:00
|
|
|
end
|
2018-06-20 10:00:13 -04:00
|
|
|
|
|
|
|
context 'asset host' do
|
|
|
|
before do
|
|
|
|
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('production'))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns a relative url when the asset host is not configured' do
|
|
|
|
expect(described_class.main).to match %r{^/assets/favicon-(?:\h+).png$}
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns a full url when the asset host is configured' do
|
|
|
|
allow(Gitlab::Application.config).to receive(:asset_host).and_return('http://assets.local')
|
|
|
|
expect(described_class.main).to match %r{^http://localhost/assets/favicon-(?:\h+).png$}
|
|
|
|
end
|
|
|
|
end
|
2017-09-26 11:04:37 -04:00
|
|
|
end
|
2017-09-27 07:18:49 -04:00
|
|
|
|
2017-12-06 15:04:53 -05:00
|
|
|
describe '.status_overlay' do
|
|
|
|
subject { described_class.status_overlay('favicon_status_created') }
|
2017-09-27 07:18:49 -04:00
|
|
|
|
2017-12-06 15:04:53 -05:00
|
|
|
it 'returns the overlay for the status' do
|
2017-12-07 07:15:49 -05:00
|
|
|
expect(subject).to match_asset_path '/assets/ci_favicons/favicon_status_created.png'
|
2017-09-27 07:18:49 -04:00
|
|
|
end
|
2017-12-06 15:04:53 -05:00
|
|
|
end
|
2017-09-27 07:18:49 -04:00
|
|
|
|
2017-12-06 15:04:53 -05:00
|
|
|
describe '.available_status_names' do
|
|
|
|
subject { described_class.available_status_names }
|
|
|
|
|
|
|
|
it 'returns the available status names' do
|
|
|
|
expect(subject).to eq %w(
|
|
|
|
favicon_status_canceled
|
|
|
|
favicon_status_created
|
|
|
|
favicon_status_failed
|
|
|
|
favicon_status_manual
|
|
|
|
favicon_status_not_found
|
|
|
|
favicon_status_pending
|
|
|
|
favicon_status_running
|
|
|
|
favicon_status_skipped
|
|
|
|
favicon_status_success
|
|
|
|
favicon_status_warning
|
|
|
|
)
|
2017-09-27 07:18:49 -04:00
|
|
|
end
|
|
|
|
end
|
2017-09-26 11:04:37 -04:00
|
|
|
end
|