File changed. Contains only whitespace changes. Show whitespace changes.
---
title: Fix Piwik not working
merge_request: 32234
author:
type: fixed
require 'spec_helper' require 'spec_helper'
describe 'layouts/_head' do describe 'layouts/_head' do
include StubConfiguration
before do before do
allow(view).to receive(:current_application_settings).and_return(Gitlab::CurrentSettings.current_application_settings) allow(view).to receive(:current_application_settings).and_return(Gitlab::CurrentSettings.current_application_settings)
end end
...@@ -87,6 +89,24 @@ describe 'layouts/_head' do ...@@ -87,6 +89,24 @@ describe 'layouts/_head' do
end end
end end
context 'when a Piwik config is set' do
let(:piwik_host) { 'piwik.example.com' }
before do
stub_config(extra: {
piwik_url: piwik_host,
piwik_site_id: 12345
})
end
it 'add a Piwik Javascript' do
render
expect(rendered).to match(/<script.*>.*var u="\/\/#{piwik_host}\/".*<\/script>/m)
expect(rendered).to match(%r(<noscript>.*<img src="//#{piwik_host}/piwik.php.*</noscript>))
end
end
def stub_helper_with_safe_string(method) def stub_helper_with_safe_string(method)
allow_any_instance_of(PageLayoutHelper).to receive(method) allow_any_instance_of(PageLayoutHelper).to receive(method)
.and_return(%q{foo" http-equiv="refresh}.html_safe) .and_return(%q{foo" http-equiv="refresh}.html_safe)
... ...
......