diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/controllers/registrations/experience_levels_controller_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/controllers/registrations/experience_levels_controller_spec.rb')
-rw-r--r-- | spec/controllers/registrations/experience_levels_controller_spec.rb | 127 |
1 files changed, 47 insertions, 80 deletions
diff --git a/spec/controllers/registrations/experience_levels_controller_spec.rb b/spec/controllers/registrations/experience_levels_controller_spec.rb index 015daba8682..79fa3f1474a 100644 --- a/spec/controllers/registrations/experience_levels_controller_spec.rb +++ b/spec/controllers/registrations/experience_levels_controller_spec.rb @@ -3,6 +3,8 @@ 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) } @@ -19,20 +21,11 @@ RSpec.describe Registrations::ExperienceLevelsController do context 'with an authenticated user' do before do sign_in(user) - stub_experiment_for_subject(onboarding_issues: true) end it { is_expected.to have_gitlab_http_status(:ok) } - it { is_expected.to render_template('layouts/devise_experimental_onboarding_issues') } + it { is_expected.to render_template('layouts/signup_onboarding') } it { is_expected.to render_template(:show) } - - context 'when not part of the onboarding issues experiment' do - before do - stub_experiment_for_subject(onboarding_issues: false) - end - - it { is_expected.to have_gitlab_http_status(:not_found) } - end end end @@ -45,17 +38,11 @@ RSpec.describe Registrations::ExperienceLevelsController do 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) - stub_experiment_for_subject(onboarding_issues: true) - end - - context 'when not part of the onboarding issues experiment' do - before do - stub_experiment_for_subject(onboarding_issues: false) - end - - it { is_expected.to have_gitlab_http_status(:not_found) } end context 'when user is successfully updated' do @@ -85,91 +72,57 @@ RSpec.describe Registrations::ExperienceLevelsController do end end - describe 'redirection' do - let(:project) { build(:project, namespace: namespace, creator: user, path: 'project-path') } - let(:issues_board) { build(:board, id: 123, project: project) } + context 'when "Learn GitLab" project exists' do + let(:learn_gitlab_available?) { true } before do - stub_experiment_for_subject( - onboarding_issues: true, - default_to_issues_board: default_to_issues_board_xp? - ) allow_next_instance_of(LearnGitlab) 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 'when namespace_path param is missing' do - let(:params) { super().merge(namespace_path: nil) } - - where( - default_to_issues_board_xp?: [true, false], - 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 + context 'redirection' do + context 'when namespace_path param is missing' do + let(:params) { super().merge(namespace_path: nil) } - where(:default_to_issues_board_xp?, :learn_gitlab_available?, :path) do - true | true | '/group-path/project-path/-/boards/123' - true | false | '/group-path' - false | true | '/group-path' - false | false | '/group-path' - end - - with_them do - it { is_expected.to redirect_to(path) } - end - end - end + where( + learn_gitlab_available?: [true, false] + ) - describe 'applying the chosen level' do - context 'when a "Learn GitLab" project is available' do - before do - allow_next_instance_of(LearnGitlab) do |learn_gitlab| - allow(learn_gitlab).to receive(:available?).and_return(true) - allow(learn_gitlab).to receive(:label).and_return(double(id: 1)) + with_them do + it { is_expected.to redirect_to('/') } end end - context 'when novice' do - let(:params) { super().merge(experience_level: :novice) } - - it 'adds a BoardLabel' do - expect_next_instance_of(Boards::UpdateService) do |service| - expect(service).to receive(:execute) - end + context 'when we have a namespace_path param' do + using RSpec::Parameterized::TableSyntax - subject + where(:learn_gitlab_available?, :path) do + true | '/group-path/project-path/-/boards/123' + false | '/group-path' 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 + with_them do + it { is_expected.to redirect_to(path) } end end end - context 'when no "Learn GitLab" project exists' do + context 'when novice' do let(:params) { super().merge(experience_level: :novice) } - before do - allow_next_instance_of(LearnGitlab) do |learn_gitlab| - allow(learn_gitlab).to receive(:available?).and_return(false) - end + 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) @@ -178,6 +131,20 @@ RSpec.describe Registrations::ExperienceLevelsController do end end end + + context 'when no "Learn GitLab" project exists' do + let(:params) { super().merge(experience_level: :novice) } + + before do + allow_next(LearnGitlab).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 |