Fix Piwik not working

Due to indentation, the changes in
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/31402 broke the
templating of Piwik script header.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/66627
This commit is contained in:
Stan Hu 2019-08-26 13:03:42 -07:00
parent f687302397
commit f605898191
3 changed files with 27 additions and 2 deletions

View file

@ -11,5 +11,5 @@
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
<noscript><p><img src="//#{extra_config.piwik_url}/piwik.php?idsite=#{extra_config.piwik_site_id}" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
<noscript><p><img src="//#{extra_config.piwik_url}/piwik.php?idsite=#{extra_config.piwik_site_id}" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->

View file

@ -0,0 +1,5 @@
---
title: Fix Piwik not working
merge_request: 32234
author:
type: fixed

View file

@ -1,6 +1,8 @@
require 'spec_helper'
describe 'layouts/_head' do
include StubConfiguration
before do
allow(view).to receive(:current_application_settings).and_return(Gitlab::CurrentSettings.current_application_settings)
end
@ -87,6 +89,24 @@ describe 'layouts/_head' do
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)
allow_any_instance_of(PageLayoutHelper).to receive(method)
.and_return(%q{foo" http-equiv="refresh}.html_safe)