Commit a1c7cced authored by Saikat Sarkar's avatar Saikat Sarkar

Merge branch '337965-cleanup-experience-level-controller' into 'master'

Remove experience level controllers

See merge request gitlab-org/gitlab!69491
parents 16540aba 699ea2b4
......@@ -39,36 +39,6 @@
}
}
.signup-page[data-page^='registrations:experience_levels'] {
$card-shadow-color: rgba(var(--black, $black), 0.2);
.page-wrap {
background-color: var(--white, $white);
}
.card-deck {
max-width: 828px;
}
.card {
transition: box-shadow 0.3s ease-in-out;
}
.card:hover {
box-shadow: 0 $gl-spacing-scale-3 $gl-spacing-scale-5 $card-shadow-color;
}
@media (min-width: $breakpoint-sm) {
.card-deck .card {
margin: 0 $gl-spacing-scale-3;
}
}
.stretched-link:hover {
text-decoration: none;
}
}
.edit-profile {
max-width: 460px;
}
# frozen_string_literal: true
module Registrations
class ExperienceLevelsController < ApplicationController
layout 'minimal'
before_action :ensure_namespace_path_param
feature_category :onboarding
def update
current_user.experience_level = params[:experience_level]
if current_user.save
hide_advanced_issues
if learn_gitlab.available?
redirect_to namespace_project_board_path(params[:namespace_path], learn_gitlab.project, learn_gitlab.board)
else
redirect_to group_path(params[:namespace_path])
end
else
render :show
end
end
private
def ensure_namespace_path_param
redirect_to root_path unless params[:namespace_path].present?
end
def hide_advanced_issues
return unless current_user.user_preference.novice?
return unless learn_gitlab.available?
Boards::UpdateService.new(learn_gitlab.project, current_user, label_ids: [learn_gitlab.label.id]).execute(learn_gitlab.board)
end
def learn_gitlab
@learn_gitlab ||= LearnGitlab::Project.new(current_user)
end
end
end
......@@ -307,7 +307,6 @@ class User < ApplicationRecord
:gitpod_enabled, :gitpod_enabled=,
:setup_for_company, :setup_for_company=,
:render_whitespace_in_code, :render_whitespace_in_code=,
:experience_level, :experience_level=,
:markdown_surround_selection, :markdown_surround_selection=,
to: :user_preference
......
......@@ -20,7 +20,7 @@ class UserPreference < ApplicationRecord
less_than_or_equal_to: Gitlab::TabWidth::MAX
}
enum experience_level: { novice: 0, experienced: 1 }
ignore_columns :experience_level, remove_with: '14.10', remove_after: '2021-03-22'
default_value_for :tab_width, value: Gitlab::TabWidth::DEFAULT, allows_nil: false
default_value_for :timezone, value: Time.zone.tzinfo.name, allows_nil: false
......
- page_title _('What’s your experience level?')
- @hide_flash = true
.gl-display-flex.gl-flex-direction-column.gl-align-items-center
= image_tag 'learn-gitlab-avatar.jpg', width: '90'
%h2.gl-text-center.gl-mt-3.gl-mb-3= _('Hello there')
%p.gl-text-center.gl-font-lg.gl-mb-6= _('Welcome to the guided GitLab tour')
%h3.gl-text-center.gl-font-lg.gl-mt-6.gl-mb-0= _('What describes you best?')
.card-deck.gl-mt-6
.card
.card-body.gl-display-flex.gl-py-8.gl-pr-5.gl-pl-7
.gl-align-self-center.gl-pr-6
= image_tag 'novice.svg', width: '78', height: '78', alt: ''
%div
%p.gl-font-lg.gl-font-weight-bold.gl-mb-2= _('Novice')
%p= _('I’m not familiar with the basics of DevOps.')
= link_to _('Show me the basics'), users_sign_up_experience_level_path(experience_level: :novice, namespace_path: params[:namespace_path]), method: :patch, class: 'stretched-link'
.card
.card-body.gl-display-flex.gl-py-8.gl-pr-5.gl-pl-7
.gl-align-self-center.gl-pr-6
= image_tag 'experienced.svg', width: '78', height: '78', alt: ''
%div
%p.gl-font-lg.gl-font-weight-bold.gl-mb-2= _('Experienced')
%p= _('I’m familiar with the basics of DevOps.')
= link_to _('Show me advanced features'), users_sign_up_experience_level_path(experience_level: :experienced, namespace_path: params[:namespace_path]), method: :patch, class: 'stretched-link'
......@@ -63,8 +63,6 @@ Rails.application.routes.draw do
end
end
resource :experience_level, only: [:show, :update]
Gitlab.ee do
resources :groups, only: [:new, :create]
resources :projects, only: [:new, :create]
......
......@@ -13635,9 +13635,6 @@ msgstr ""
msgid "Expected documents: %{expected_documents}"
msgstr ""
msgid "Experienced"
msgstr ""
msgid "ExperimentSubject|Must have exactly one of User, Namespace, or Project."
msgstr ""
......@@ -16555,9 +16552,6 @@ msgstr ""
msgid "Hello %{name},"
msgstr ""
msgid "Hello there"
msgstr ""
msgid "Hello, %{name}!"
msgstr ""
......@@ -18964,15 +18958,9 @@ msgstr ""
msgid "Iteration|cannot be more than 500 years in the future"
msgstr ""
msgid "I’m familiar with the basics of DevOps."
msgstr ""
msgid "I’m joining my team who’s already on GitLab"
msgstr ""
msgid "I’m not familiar with the basics of DevOps."
msgstr ""
msgid "Jaeger URL"
msgstr ""
......@@ -23130,9 +23118,6 @@ msgstr ""
msgid "November"
msgstr ""
msgid "Novice"
msgstr ""
msgid "Now, personalize your GitLab experience"
msgstr ""
......@@ -30905,15 +30890,9 @@ msgstr ""
msgid "Show list"
msgstr ""
msgid "Show me advanced features"
msgstr ""
msgid "Show me how to add a pipeline"
msgstr ""
msgid "Show me the basics"
msgstr ""
msgid "Show one file at a time"
msgstr ""
......@@ -37698,9 +37677,6 @@ msgstr ""
msgid "Welcome to GitLab,%{br_tag}%{name}!"
msgstr ""
msgid "Welcome to the guided GitLab tour"
msgstr ""
msgid "Welcome, %{name}!"
msgstr ""
......@@ -37719,9 +37695,6 @@ msgstr ""
msgid "What are you searching for?"
msgstr ""
msgid "What describes you best?"
msgstr ""
msgid "What does this command do?"
msgstr ""
......@@ -37749,9 +37722,6 @@ msgstr ""
msgid "What's new"
msgstr ""
msgid "What’s your experience level?"
msgstr ""
msgid "When a deployment job is successful, skip older deployment jobs that are still pending."
msgstr ""
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Registrations::ExperienceLevelsController do
include AfterNextHelpers
let_it_be(:namespace) { create(:group, path: 'group-path' ) }
let_it_be(:user) { create(:user) }
let(:params) { { namespace_path: namespace.to_param } }
describe 'GET #show' do
subject { get :show, params: params }
context 'with an unauthenticated user' do
it { is_expected.to have_gitlab_http_status(:redirect) }
it { is_expected.to redirect_to(new_user_session_path) }
end
context 'with an authenticated user' do
before do
sign_in(user)
end
it { is_expected.to have_gitlab_http_status(:ok) }
it { is_expected.to render_template('layouts/minimal') }
it { is_expected.to render_template(:show) }
end
end
describe 'PUT/PATCH #update' do
subject { patch :update, params: params }
context 'with an unauthenticated user' do
it { is_expected.to have_gitlab_http_status(:redirect) }
it { is_expected.to redirect_to(new_user_session_path) }
end
context 'with an authenticated user' do
let_it_be(:project) { build(:project, namespace: namespace, creator: user, path: 'project-path') }
let_it_be(:issues_board) { build(:board, id: 123, project: project) }
before do
sign_in(user)
end
context 'when user is successfully updated' do
context 'when no experience_level is sent' do
before do
user.user_preference.update_attribute(:experience_level, :novice)
end
it 'will unset the user’s experience level' do
expect { subject }.to change { user.reload.experience_level }.to(nil)
end
end
context 'when an expected experience level is sent' do
let(:params) { super().merge(experience_level: :novice) }
it 'sets the user’s experience level' do
expect { subject }.to change { user.reload.experience_level }.from(nil).to('novice')
end
end
context 'when an unexpected experience level is sent' do
let(:params) { super().merge(experience_level: :nonexistent) }
it 'raises an exception' do
expect { subject }.to raise_error(ArgumentError, "'nonexistent' is not a valid experience_level")
end
end
context 'when "Learn GitLab" project exists' do
let(:learn_gitlab_available?) { true }
before do
allow_next_instance_of(LearnGitlab::Project) do |learn_gitlab|
allow(learn_gitlab).to receive(:available?).and_return(learn_gitlab_available?)
allow(learn_gitlab).to receive(:project).and_return(project)
allow(learn_gitlab).to receive(:board).and_return(issues_board)
allow(learn_gitlab).to receive(:label).and_return(double(id: 1))
end
end
context 'redirection' do
context 'when namespace_path param is missing' do
let(:params) { super().merge(namespace_path: nil) }
where(
learn_gitlab_available?: [true, false]
)
with_them do
it { is_expected.to redirect_to('/') }
end
end
context 'when we have a namespace_path param' do
using RSpec::Parameterized::TableSyntax
where(:learn_gitlab_available?, :path) do
true | '/group-path/project-path/-/boards/123'
false | '/group-path'
end
with_them do
it { is_expected.to redirect_to(path) }
end
end
end
context 'when novice' do
let(:params) { super().merge(experience_level: :novice) }
it 'adds a BoardLabel' do
expect_next(Boards::UpdateService).to receive(:execute)
subject
end
end
context 'when experienced' do
let(:params) { super().merge(experience_level: :experienced) }
it 'does not add a BoardLabel' do
expect(Boards::UpdateService).not_to receive(:new)
subject
end
end
end
context 'when no "Learn GitLab" project exists' do
let(:params) { super().merge(experience_level: :novice) }
before do
allow_next(LearnGitlab::Project).to receive(:available?).and_return(false)
end
it 'does not add a BoardLabel' do
expect(Boards::UpdateService).not_to receive(:new)
subject
end
end
end
context 'when user update fails' do
before do
allow_any_instance_of(User).to receive(:save).and_return(false)
end
it { is_expected.to render_template(:show) }
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Experience level screen' do
let_it_be(:user) { create(:user, :unconfirmed) }
let_it_be(:group) { create(:group) }
before do
group.add_owner(user)
gitlab_sign_in(user)
visit users_sign_up_experience_level_path(namespace_path: group.to_param)
end
subject { page }
it 'shows the intro content' do
is_expected.to have_content('Hello there')
is_expected.to have_content('Welcome to the guided GitLab tour')
is_expected.to have_content('What describes you best?')
end
it 'shows the option for novice' do
is_expected.to have_content('Novice')
is_expected.to have_content('I’m not familiar with the basics of DevOps')
is_expected.to have_content('Show me the basics')
end
it 'shows the option for experienced' do
is_expected.to have_content('Experienced')
is_expected.to have_content('I’m familiar with the basics of DevOps')
is_expected.to have_content('Show me advanced features')
end
it 'does not display any flash messages' do
is_expected.not_to have_selector('.flash-container')
is_expected.not_to have_content("Please check your email (#{user.email}) to verify that you own this address and unlock the power of CI/CD")
end
it 'does not include the footer links' do
is_expected.not_to have_link('Help')
is_expected.not_to have_link('About GitLab')
end
end
......@@ -65,9 +65,6 @@ RSpec.describe User do
it { is_expected.to delegate_method(:render_whitespace_in_code).to(:user_preference) }
it { is_expected.to delegate_method(:render_whitespace_in_code=).to(:user_preference).with_arguments(:args) }
it { is_expected.to delegate_method(:experience_level).to(:user_preference) }
it { is_expected.to delegate_method(:experience_level=).to(:user_preference).with_arguments(:args) }
it { is_expected.to delegate_method(:markdown_surround_selection).to(:user_preference) }
it { is_expected.to delegate_method(:markdown_surround_selection=).to(:user_preference).with_arguments(:args) }
......
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