Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Zallmann <tzallmann@gitlab.com>2018-07-26 18:00:18 +0300
committerClement Ho <clemmakesapps@gmail.com>2018-07-26 18:00:18 +0300
commitf7ac5384258f02fc2f4da681338f928a5363b19c (patch)
tree7f675aba4cd25e505856f6095df48d72159a4f08 /spec/views
parent2fbafe1a41f846a5fd6a58d27f9fb16484edb070 (diff)
DNS Prefetching + Preconnect of assets_host (CDN Domain)
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/layouts/_head.html.haml_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/views/layouts/_head.html.haml_spec.rb b/spec/views/layouts/_head.html.haml_spec.rb
index e8e6d2e7a75..9d1efcabb80 100644
--- a/spec/views/layouts/_head.html.haml_spec.rb
+++ b/spec/views/layouts/_head.html.haml_spec.rb
@@ -29,6 +29,39 @@ describe 'layouts/_head' do
expect(rendered).to match(%{content="foo&quot; http-equiv=&quot;refresh"})
end
+ 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
+
def stub_helper_with_safe_string(method)
allow_any_instance_of(PageLayoutHelper).to receive(method)
.and_return(%q{foo" http-equiv="refresh}.html_safe)