Commit d7a93e3f authored by Peter Leitzen's avatar Peter Leitzen

Merge branch '219150-remove-onboarding-tour' into 'master'

Remove OnBoarding tour - BE

Closes #219150

See merge request gitlab-org/gitlab!35363
parents eb47050c 3b90e33c
......@@ -3,7 +3,6 @@
class Dashboard::ProjectsController < Dashboard::ApplicationController
include ParamsBackwardCompatibility
include RendersMemberAccess
include OnboardingExperimentHelper
include SortingHelper
include SortingPreference
include FiltersEvents
......
# frozen_string_literal: true
module OnboardingExperimentHelper
def allow_access_to_onboarding?
::Gitlab.dev_env_or_com? && Feature.enabled?(:user_onboarding)
end
end
OnboardingExperimentHelper.prepend_if_ee('EE::OnboardingExperimentHelper')
......@@ -5,32 +5,13 @@ module EE
module ProjectsController
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
include ::OnboardingExperimentHelper
private
override :render_projects
def render_projects
return redirect_to explore_onboarding_index_path if show_onboarding_welcome_page?
super
end
override :preload_associations
def preload_associations(projects)
super.with_compliance_framework_settings
end
def show_onboarding_welcome_page?
return false if onboarding_cookie_set?
return false unless allow_access_to_onboarding?
!show_projects?(projects, params)
end
def onboarding_cookie_set?
cookies['onboarding_dismissed'] == 'true'
end
end
end
end
# frozen_string_literal: true
class Explore::OnboardingController < Explore::ApplicationController
include ::OnboardingExperimentHelper
before_action :authenticate_user!
before_action :set_project!
layout 'onboarding'
private
def set_project!
@project = get_onboarding_demo_project
return render_404 unless @project && can?(current_user, :read_project, @project)
session[:onboarding_project] = { project_full_path: @project.web_url, project_name: @project.name }
end
def get_onboarding_demo_project
demo_project if allow_access_to_onboarding?
end
def demo_project
# gdk instances may not have the 'gitlab-foss' project seeded, so we will fallback
# to 'gitlab-test'
Project.find_by_full_path('gitlab-org/gitlab-foss') ||
Project.find_by_full_path('gitlab-org/gitlab-test')
end
end
......@@ -3,7 +3,6 @@
module EE
module ApplicationHelper
extend ::Gitlab::Utils::Override
include ::OnboardingExperimentHelper
DB_LAG_SHOW_THRESHOLD = 60 # seconds
LOG_CURSOR_CHECK_TIME = ::Gitlab::Geo::LogCursor::Daemon::SECONDARY_CHECK_INTERVAL
......@@ -113,10 +112,6 @@ module EE
show
end
def user_onboarding_enabled?
allow_access_to_onboarding?
end
def show_whats_new_dropdown_item?
::Gitlab.com? && ::Feature.enabled?(:whats_new_dropdown)
end
......
# frozen_string_literal: true
module EE
module OnboardingExperimentHelper
extend ::Gitlab::Utils::Override
EXPERIMENT_GROWTH_ONBOARDING_FEATURE_NAME = :experiment_growth_onboarding
override :allow_access_to_onboarding?
def allow_access_to_onboarding?
super && experiment_enabled_for_user?
end
private
def experiment_enabled_for_user?
return true unless current_user
::Feature.enabled?(EXPERIMENT_GROWTH_ONBOARDING_FEATURE_NAME, current_user, default_enabled: true)
end
end
end
# frozen_string_literal: true
namespace :explore do
resources :onboarding, only: [:index]
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Dashboard::ProjectsController do
include ExternalAuthorizationServiceHelpers
let(:user) { create(:user) }
describe 'GET #index' do
before do
sign_in(user)
end
context 'onboarding welcome page' do
before do
allow(Gitlab).to receive(:com?) { true }
end
shared_examples '200 status' do
it 'renders the index template' do
get :index
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index)
end
end
context 'when the feature is enabled' do
before do
stub_feature_flags(user_onboarding: true)
end
context 'and the user does not have projects' do
before do
stub_feature_flags(project_list_filter_bar: false)
end
it 'renders the welcome page if it has not dismissed onboarding' do
cookies[:onboarding_dismissed] = 'false'
get :index
expect(response).to redirect_to(explore_onboarding_index_path)
end
it 'renders the index template if it has dismissed the onboarding' do
cookies[:onboarding_dismissed] = 'true'
get :index
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index)
end
end
context 'and the user has projects' do
let(:project) { create(:project) }
before do
project.add_developer(user)
end
it_behaves_like '200 status'
end
end
context 'when the feature is disabled' do
before do
stub_feature_flags(user_onboarding: false)
end
it_behaves_like '200 status'
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe OnboardingExperimentHelper, type: :helper do
using RSpec::Parameterized::TableSyntax
describe '.allow_access_to_onboarding?' do
context "when we're not gitlab.com" do
it 'returns false' do
allow(::Gitlab).to receive(:com?).and_return(false)
expect(helper.allow_access_to_onboarding?).to be(false)
end
end
context "when we're gitlab.com" do
before do
allow(::Gitlab).to receive(:com?).and_return(true)
end
context 'and the :user_onboarding feature is not enabled' do
it 'returns false' do
stub_feature_flags(user_onboarding: false)
expect(helper.allow_access_to_onboarding?).to be(false)
end
end
context 'and the :user_onboarding feature is enabled' do
before do
stub_feature_flags(user_onboarding: true)
end
context 'but there is no current_user' do
it 'returns true' do
allow(helper).to receive(:current_user).and_return(nil)
expect(helper.allow_access_to_onboarding?).to be(true)
end
end
context 'and there is a current_user' do
let!(:user) { create(:user, id: 2) }
before do
allow(helper).to receive(:current_user).and_return(user)
end
context 'but experiment_growth_onboarding has not been set' do
it 'returns true' do
expect(helper.allow_access_to_onboarding?).to be(true)
end
end
context 'and experiment_growth_onboarding has been set' do
it 'checks if feature is enabled for current_user' do
Feature.enable_percentage_of_actors(
described_class::EXPERIMENT_GROWTH_ONBOARDING_FEATURE_NAME, 50)
expect(helper.allow_access_to_onboarding?).to eq(true)
end
end
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe OnboardingExperimentHelper, type: :helper do
describe '.allow_access_to_onboarding?' do
context "when we're not gitlab.com or dev env" do
it 'returns false' do
allow(::Gitlab).to receive(:dev_env_or_com?).and_return(false)
expect(helper.allow_access_to_onboarding?).to be(false)
end
end
context "when we're gitlab.com or dev env" do
before do
allow(::Gitlab).to receive(:dev_env_or_com?).and_return(true)
end
context 'and the :user_onboarding feature is not enabled' do
it 'returns false' do
stub_feature_flags(user_onboarding: false)
expect(helper.allow_access_to_onboarding?).to be(false)
end
end
context 'and the :user_onboarding feature is enabled' do
it 'returns true' do
stub_feature_flags(user_onboarding: true)
allow(helper).to receive(:current_user).and_return(create(:user))
expect(helper.allow_access_to_onboarding?).to be(true)
end
end
end
end
end
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