2019-12-26 22:10:19 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
require 'spec_helper'
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
RSpec.describe Gitlab::Favicon, :request_store do
|
|
|
|
describe '.main' do
|
|
|
|
it 'defaults to favicon.png' do
|
2019-12-04 20:38:33 +05:30
|
|
|
stub_rails_env('production')
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(described_class.main).to match_asset_path '/assets/favicon.png'
|
|
|
|
end
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
it 'has blue favicon for development', unless: Gitlab.ee? do
|
2019-12-04 20:38:33 +05:30
|
|
|
stub_rails_env('development')
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(described_class.main).to match_asset_path '/assets/favicon-blue.png'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has yellow favicon for canary' do
|
|
|
|
stub_env('CANARY', 'true')
|
|
|
|
expect(described_class.main).to match_asset_path 'favicon-yellow.png'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'uses the custom favicon if a favicon appearance is present' do
|
|
|
|
create :appearance, favicon: fixture_file_upload('spec/fixtures/dk.png')
|
|
|
|
expect(described_class.main).to match %r{/uploads/-/system/appearance/favicon/\d+/dk.png}
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'asset host' do
|
|
|
|
before do
|
2019-12-04 20:38:33 +05:30
|
|
|
stub_rails_env('production')
|
2018-11-08 19:23:39 +05:30
|
|
|
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(ActionController::Base).to receive(:asset_host).and_return('http://assets.local')
|
|
|
|
expect(described_class.main).to match %r{^http://localhost/assets/favicon-(?:\h+).png$}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
describe '.ci_status_overlay' do
|
|
|
|
subject { described_class.ci_status_overlay('favicon_status_created') }
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
it 'returns the overlay for the status' do
|
|
|
|
expect(subject).to match_asset_path '/assets/ci_favicons/favicon_status_created.png'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
describe '.mr_status_overlay' do
|
|
|
|
subject { described_class.mr_status_overlay('favicon_status_merged') }
|
|
|
|
|
|
|
|
it 'returns the overlay for the status' do
|
|
|
|
expect(subject).to match_asset_path '/assets/mr_favicons/favicon_status_merged.png'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
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
|
2019-12-21 20:55:43 +05:30
|
|
|
favicon_status_preparing
|
2018-11-08 19:23:39 +05:30
|
|
|
favicon_status_running
|
2018-12-05 23:21:45 +05:30
|
|
|
favicon_status_scheduled
|
2018-11-08 19:23:39 +05:30
|
|
|
favicon_status_skipped
|
|
|
|
favicon_status_success
|
|
|
|
favicon_status_warning
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|