Commit fe320385 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'onboarding-experiment-apply-advanced-filter-backend' into 'master'

Onboarding experiment apply advanced filter backend

See merge request gitlab-org/gitlab!34493
parents 67415866 dc09d179
...@@ -13,6 +13,7 @@ module Registrations ...@@ -13,6 +13,7 @@ module Registrations
current_user.experience_level = params[:experience_level] current_user.experience_level = params[:experience_level]
if current_user.save if current_user.save
hide_advanced_issues
flash[:message] = I18n.t('devise.registrations.signed_up') flash[:message] = I18n.t('devise.registrations.signed_up')
redirect_to group_path(params[:namespace_path]) redirect_to group_path(params[:namespace_path])
else else
...@@ -29,5 +30,15 @@ module Registrations ...@@ -29,5 +30,15 @@ module Registrations
def ensure_namespace_path_param def ensure_namespace_path_param
redirect_to root_path unless params[:namespace_path].present? redirect_to root_path unless params[:namespace_path].present?
end end
def hide_advanced_issues
return unless current_user.user_preference.novice?
settings = cookies[:onboarding_issues_settings]
return unless settings
modified_settings = Gitlab::Json.parse(settings).merge(hideAdvanced: true)
cookies[:onboarding_issues_settings] = modified_settings.to_json
end
end end
end end
...@@ -97,6 +97,38 @@ describe Registrations::ExperienceLevelsController do ...@@ -97,6 +97,38 @@ describe Registrations::ExperienceLevelsController do
it { is_expected.to have_gitlab_http_status(:redirect) } it { is_expected.to have_gitlab_http_status(:redirect) }
it { is_expected.to redirect_to(root_path) } it { is_expected.to redirect_to(root_path) }
end end
describe 'applying the chosen level' do
context "when an 'onboarding_issues_settings' cookie does not exist" do
let(:params) { super().merge(experience_level: :novice) }
it 'does not change the cookie' do
expect { subject }.not_to change { cookies[:onboarding_issues_settings] }
end
end
context "when an 'onboarding_issues_settings' cookie does exist" do
before do
request.cookies[:onboarding_issues_settings] = '{}'
end
context 'when novice' do
let(:params) { super().merge(experience_level: :novice) }
it "adds a 'hideAdvanced' setting to the cookie" do
expect { subject }.to change { Gitlab::Json.parse(cookies[:onboarding_issues_settings])['hideAdvanced'] }.from(nil).to(true)
end
end
context 'when experienced' do
let(:params) { super().merge(experience_level: :experienced) }
it 'does not change the cookie' do
expect { subject }.not_to change { cookies[:onboarding_issues_settings] }
end
end
end
end
end end
context 'when user update fails' do context 'when user update fails' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment