diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-22 21:06:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-22 21:06:42 +0000 |
commit | d5e0416021aa6de53b89f9d415f368226d9326e5 (patch) | |
tree | 9a3e3bd6d1aac10cfde7f0079f784a489491a48b /spec | |
parent | 24fe7aa2aa199b2aace0cfec26d744f51d7e2167 (diff) | |
download | gitlab-ce-d5e0416021aa6de53b89f9d415f368226d9326e5.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/helpers/application_settings_helper_spec.rb | 5 | ||||
-rw-r--r-- | spec/models/application_setting_spec.rb | 30 | ||||
-rw-r--r-- | spec/requests/api/settings_spec.rb | 48 | ||||
-rw-r--r-- | spec/views/layouts/_head.html.haml_spec.rb | 24 |
4 files changed, 106 insertions, 1 deletions
diff --git a/spec/helpers/application_settings_helper_spec.rb b/spec/helpers/application_settings_helper_spec.rb index 705523f1110..38af4aab0ef 100644 --- a/spec/helpers/application_settings_helper_spec.rb +++ b/spec/helpers/application_settings_helper_spec.rb @@ -36,4 +36,9 @@ describe ApplicationSettingsHelper do it_behaves_like 'when HTTP protocol is in use', 'https' it_behaves_like 'when HTTP protocol is in use', 'http' + + context 'with tracking parameters' do + it { expect(visible_attributes).to include(*%i(snowplow_collector_hostname snowplow_cookie_domain snowplow_enabled snowplow_site_id))} + it { expect(visible_attributes).to include(*%i(pendo_enabled pendo_url))} + end end diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index 7bef3d30064..d16e83bb5df 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -64,6 +64,36 @@ describe ApplicationSetting do it { is_expected.not_to allow_value('three').for(:push_event_activities_limit) } it { is_expected.not_to allow_value(nil).for(:push_event_activities_limit) } + context 'when snowplow is enabled' do + before do + setting.snowplow_enabled = true + end + + it { is_expected.not_to allow_value(nil).for(:snowplow_collector_hostname) } + it { is_expected.to allow_value("snowplow.gitlab.com").for(:snowplow_collector_hostname) } + it { is_expected.not_to allow_value('/example').for(:snowplow_collector_hostname) } + end + + context 'when snowplow is not enabled' do + it { is_expected.to allow_value(nil).for(:snowplow_collector_hostname) } + end + + context 'when pendo is enabled' do + before do + setting.pendo_enabled = true + end + + it { is_expected.not_to allow_value(nil).for(:pendo_url) } + it { is_expected.to allow_value(http).for(:pendo_url) } + it { is_expected.to allow_value(https).for(:pendo_url) } + it { is_expected.not_to allow_value(ftp).for(:pendo_url) } + it { is_expected.not_to allow_value('http://127.0.0.1').for(:pendo_url) } + end + + context 'when pendo is not enabled' do + it { is_expected.to allow_value(nil).for(:pendo_url) } + end + context "when user accepted let's encrypt terms of service" do before do setting.update(lets_encrypt_terms_of_service_accepted: true) diff --git a/spec/requests/api/settings_spec.rb b/spec/requests/api/settings_spec.rb index f3bfb258029..ffaa29fd924 100644 --- a/spec/requests/api/settings_spec.rb +++ b/spec/requests/api/settings_spec.rb @@ -220,6 +220,54 @@ describe API::Settings, 'Settings' do end end + context "pendo tracking settings" do + let(:settings) do + { + pendo_url: "https://pendo.example.com", + pendo_enabled: true + } + end + + let(:attribute_names) { settings.keys.map(&:to_s) } + + it "includes the attributes in the API" do + get api("/application/settings", admin) + + expect(response).to have_gitlab_http_status(200) + attribute_names.each do |attribute| + expect(json_response.keys).to include(attribute) + end + end + + it "allows updating the settings" do + put api("/application/settings", admin), params: settings + + expect(response).to have_gitlab_http_status(200) + settings.each do |attribute, value| + expect(ApplicationSetting.current.public_send(attribute)).to eq(value) + end + end + + context "missing pendo_url value when pendo_enabled is true" do + it "returns a blank parameter error message" do + put api("/application/settings", admin), params: { pendo_enabled: true } + + expect(response).to have_gitlab_http_status(400) + expect(json_response["error"]).to eq("pendo_url is missing") + end + + it "handles validation errors" do + put api("/application/settings", admin), params: settings.merge({ + pendo_url: nil + }) + + expect(response).to have_gitlab_http_status(400) + message = json_response["message"] + expect(message["pendo_url"]).to include("can't be blank") + end + end + end + context "missing plantuml_url value when plantuml_enabled is true" do it "returns a blank parameter error message" do put api("/application/settings", admin), params: { plantuml_enabled: true } diff --git a/spec/views/layouts/_head.html.haml_spec.rb b/spec/views/layouts/_head.html.haml_spec.rb index e9b3334fffc..41e685f185a 100644 --- a/spec/views/layouts/_head.html.haml_spec.rb +++ b/spec/views/layouts/_head.html.haml_spec.rb @@ -84,7 +84,7 @@ describe 'layouts/_head' do allow(Gitlab::CurrentSettings).to receive(:snowplow_collector_hostname).and_return('www.snow.plow') end - it 'add a snowplow script tag with asset host' do + it 'adds a snowplow script tag with asset host' do render expect(rendered).to match('http://test.host/assets/snowplow/') expect(rendered).to match('window.snowplow') @@ -92,6 +92,28 @@ describe 'layouts/_head' do end end + context 'when pendo is enabled' do + it 'adds a pendo initialization snippet with url', :aggregate_failures do + allow(Gitlab::CurrentSettings).to receive(:pendo_enabled?).and_return(true) + allow(Gitlab::CurrentSettings).to receive(:pendo_url).and_return('www.pen.do') + + render + + expect(rendered).to match('pendo.initialize') + expect(rendered).to match('www.pen.do') + end + end + + context 'when pendo is not enabled' do + it 'do not add pendo snippet' do + allow(Gitlab::CurrentSettings).to receive(:pendo_enabled?).and_return(false) + + render + + expect(rendered).not_to match('pendo.initialize') + end + end + context 'when a Piwik config is set' do let(:piwik_host) { 'piwik.example.com' } |