2018-09-07 10:32:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Usage stats consent' do
|
2018-09-07 10:32:28 -04:00
|
|
|
context 'when signed in' do
|
|
|
|
let(:user) { create(:admin, created_at: 8.days.ago) }
|
|
|
|
let(:message) { 'To help improve GitLab, we would like to periodically collect usage information.' }
|
|
|
|
|
|
|
|
before do
|
2019-07-25 10:54:02 -04:00
|
|
|
if Gitlab.ee?
|
|
|
|
allow_any_instance_of(EE::User)
|
|
|
|
.to receive(:has_current_license?)
|
|
|
|
.and_return(false)
|
|
|
|
else
|
|
|
|
allow(user)
|
|
|
|
.to receive(:has_current_license?)
|
|
|
|
.and_return(false)
|
|
|
|
end
|
2018-09-07 10:32:28 -04:00
|
|
|
|
|
|
|
gitlab_sign_in(user)
|
2020-11-23 10:09:37 -05:00
|
|
|
gitlab_enable_admin_mode_sign_in(user)
|
2018-09-07 10:32:28 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'hides the banner permanently when sets usage stats' do
|
|
|
|
visit root_dashboard_path
|
|
|
|
|
|
|
|
expect(page).to have_content(message)
|
|
|
|
|
2021-06-29 08:08:48 -04:00
|
|
|
click_link 'Send service data'
|
2018-09-07 10:32:28 -04:00
|
|
|
|
|
|
|
expect(page).not_to have_content(message)
|
|
|
|
expect(page).to have_content('Application settings saved successfully')
|
|
|
|
|
|
|
|
gitlab_sign_out
|
|
|
|
gitlab_sign_in(user)
|
|
|
|
visit root_dashboard_path
|
|
|
|
|
|
|
|
expect(page).not_to have_content(message)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows banner on next session if user did not set usage stats' do
|
|
|
|
visit root_dashboard_path
|
|
|
|
|
|
|
|
expect(page).to have_content(message)
|
|
|
|
|
|
|
|
gitlab_sign_out
|
|
|
|
gitlab_sign_in(user)
|
|
|
|
visit root_dashboard_path
|
|
|
|
|
|
|
|
expect(page).to have_content(message)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|