2016-08-18 14:20:50 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'layouts/_head' do
|
2017-08-31 05:47:03 -04:00
|
|
|
before do
|
|
|
|
allow(view).to receive(:current_application_settings).and_return(Gitlab::CurrentSettings.current_application_settings)
|
|
|
|
end
|
|
|
|
|
2016-08-18 14:20:50 -04:00
|
|
|
it 'escapes HTML-safe strings in page_title' do
|
|
|
|
stub_helper_with_safe_string(:page_title)
|
|
|
|
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to match(%{content="foo" http-equiv="refresh"})
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'escapes HTML-safe strings in page_description' do
|
|
|
|
stub_helper_with_safe_string(:page_description)
|
|
|
|
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to match(%{content="foo" http-equiv="refresh"})
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'escapes HTML-safe strings in page_image' do
|
|
|
|
stub_helper_with_safe_string(:page_image)
|
|
|
|
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to match(%{content="foo" http-equiv="refresh"})
|
|
|
|
end
|
|
|
|
|
2018-07-26 11:00:18 -04:00
|
|
|
context 'when an asset_host is set and feature is activated in the config it will' do
|
|
|
|
let(:asset_host) { 'http://assets' }
|
|
|
|
|
|
|
|
before do
|
|
|
|
stub_feature_flags(asset_host_prefetch: true)
|
|
|
|
allow(ActionController::Base).to receive(:asset_host).and_return(asset_host)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'add a link dns-prefetch tag' do
|
|
|
|
render
|
|
|
|
expect(rendered).to match('<link href="http://assets" rel="dns-prefetch">')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'add a link preconnect tag' do
|
|
|
|
render
|
|
|
|
expect(rendered).to match('<link crossorigin="" href="http://assets" rel="preconnnect">')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when an asset_host is set and feature is not activated in the config it will' do
|
|
|
|
let(:asset_host) { 'http://assets' }
|
|
|
|
|
|
|
|
before do
|
|
|
|
stub_feature_flags(asset_host_prefetch: false)
|
|
|
|
allow(ActionController::Base).to receive(:asset_host).and_return(asset_host)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'not add a link dns-prefetch tag' do
|
|
|
|
render
|
|
|
|
expect(rendered).not_to match('<link href="http://assets" rel="dns-prefetch">')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-02-14 01:54:34 -05:00
|
|
|
it 'adds selected syntax highlight stylesheet' do
|
|
|
|
allow_any_instance_of(PreferencesHelper).to receive(:user_color_scheme).and_return("solarised-light")
|
|
|
|
|
|
|
|
render
|
|
|
|
|
2019-02-21 19:58:37 -05:00
|
|
|
expect(rendered).to match('<link rel="stylesheet" media="all" href="/stylesheets/highlight/themes/solarised-light.css" />')
|
2019-02-14 01:54:34 -05:00
|
|
|
end
|
|
|
|
|
2016-08-18 14:20:50 -04:00
|
|
|
def stub_helper_with_safe_string(method)
|
|
|
|
allow_any_instance_of(PageLayoutHelper).to receive(method)
|
|
|
|
.and_return(%q{foo" http-equiv="refresh}.html_safe)
|
|
|
|
end
|
|
|
|
end
|