Commit 338fef9e authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '333711-customize-this-page-banner-shows-up-when-it-shouldn-t' into 'master'

Customize this page banner shows up when it shouldn't

See merge request gitlab-org/gitlab!64307
parents edc8f5fb 404dbbc7
...@@ -43,7 +43,7 @@ module UserCalloutsHelper ...@@ -43,7 +43,7 @@ module UserCalloutsHelper
end end
def show_customize_homepage_banner? def show_customize_homepage_banner?
!user_dismissed?(CUSTOMIZE_HOMEPAGE) current_user.default_dashboard? && !user_dismissed?(CUSTOMIZE_HOMEPAGE)
end end
def show_feature_flags_new_version? def show_feature_flags_new_version?
......
...@@ -808,6 +808,10 @@ class User < ApplicationRecord ...@@ -808,6 +808,10 @@ class User < ApplicationRecord
# Instance methods # Instance methods
# #
def default_dashboard?
dashboard == self.class.column_defaults['dashboard']
end
def full_path def full_path
username username
end end
......
...@@ -3,15 +3,6 @@ ...@@ -3,15 +3,6 @@
= content_for :meta_tags do = content_for :meta_tags do
= auto_discovery_link_tag(:atom, dashboard_projects_url(rss_url_options), title: "All activity") = auto_discovery_link_tag(:atom, dashboard_projects_url(rss_url_options), title: "All activity")
- if show_customize_homepage_banner?
= content_for :customize_homepage_banner do
.gl-display-none.gl-md-display-block{ class: "gl-pt-6! gl-pb-2! #{(container_class unless @no_container)} #{@content_class}" }
.js-customize-homepage-banner{ data: { svg_path: image_path('illustrations/monitoring/getting_started.svg'),
preferences_behavior_path: profile_preferences_path(anchor: 'behavior'),
callouts_path: user_callouts_path,
callouts_feature_id: UserCalloutsHelper::CUSTOMIZE_HOMEPAGE,
track_label: 'home_page' } }
= render_dashboard_ultimate_trial(current_user) = render_dashboard_ultimate_trial(current_user)
- page_title _("Projects") - page_title _("Projects")
......
- if show_customize_homepage_banner?
= content_for :customize_homepage_banner do
.gl-display-none.gl-md-display-block{ class: "gl-pt-6! gl-pb-2! #{(container_class unless @no_container)} #{@content_class}" }
.js-customize-homepage-banner{ data: { svg_path: image_path('illustrations/monitoring/getting_started.svg'),
preferences_behavior_path: profile_preferences_path(anchor: 'behavior'),
callouts_path: user_callouts_path,
callouts_feature_id: UserCalloutsHelper::CUSTOMIZE_HOMEPAGE,
track_label: 'home_page' } }
= render template: 'dashboard/projects/index'
...@@ -93,7 +93,7 @@ RSpec.describe RootController do ...@@ -93,7 +93,7 @@ RSpec.describe RootController do
it 'renders the default dashboard' do it 'renders the default dashboard' do
get :index get :index
expect(response).to render_template 'dashboard/projects/index' expect(response).to render_template 'root/index'
end end
end end
end end
......
...@@ -128,11 +128,31 @@ RSpec.describe RootController do ...@@ -128,11 +128,31 @@ RSpec.describe RootController do
end end
end end
context 'who uses the default dashboard setting' do context 'who uses the default dashboard setting', :aggregate_failures do
it 'renders the default dashboard' do render_views
get :index
context 'with customize homepage banner' do
it 'renders the default dashboard' do
get :index
expect(response).to render_template 'root/index'
expect(response.body).to have_css('.js-customize-homepage-banner')
end
end
context 'without customize homepage banner' do
before do
Users::DismissUserCalloutService.new(
container: nil, current_user: user, params: { feature_name: UserCalloutsHelper::CUSTOMIZE_HOMEPAGE }
).execute
end
it 'renders the default dashboard' do
get :index
expect(response).to render_template 'dashboard/projects/index' expect(response).to render_template 'root/index'
expect(response.body).not_to have_css('.js-customize-homepage-banner')
end
end end
end end
end end
......
...@@ -18,12 +18,6 @@ RSpec.describe 'Dashboard Projects' do ...@@ -18,12 +18,6 @@ RSpec.describe 'Dashboard Projects' do
end end
end end
it 'shows the customize banner', :js do
visit dashboard_projects_path
expect(page).to have_content('Do you want to customize this page?')
end
context 'when user has access to the project' do context 'when user has access to the project' do
it 'shows role badge' do it 'shows role badge' do
visit dashboard_projects_path visit dashboard_projects_path
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Root path' do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
before do
project.add_developer(user)
sign_in(user)
end
it 'shows the customize banner', :js do
visit root_path
expect(page).to have_content('Do you want to customize this page?')
end
end
...@@ -97,7 +97,17 @@ RSpec.describe UserCalloutsHelper do ...@@ -97,7 +97,17 @@ RSpec.describe UserCalloutsHelper do
allow(helper).to receive(:user_dismissed?).with(described_class::CUSTOMIZE_HOMEPAGE) { false } allow(helper).to receive(:user_dismissed?).with(described_class::CUSTOMIZE_HOMEPAGE) { false }
end end
it { is_expected.to be true } context 'when user is on the default dashboard' do
it { is_expected.to be true }
end
context 'when user is not on the default dashboard' do
before do
user.dashboard = 'stars'
end
it { is_expected.to be false }
end
end end
context 'when user dismissed' do context 'when user dismissed' do
......
...@@ -5756,6 +5756,20 @@ RSpec.describe User do ...@@ -5756,6 +5756,20 @@ RSpec.describe User do
end end
end end
describe '#default_dashboard?' do
it 'is the default dashboard' do
user = build(:user)
expect(user.default_dashboard?).to be true
end
it 'is not the default dashboard' do
user = build(:user, dashboard: 'stars')
expect(user.default_dashboard?).to be false
end
end
describe '.dormant' do describe '.dormant' do
it 'returns dormant users' do it 'returns dormant users' do
freeze_time do freeze_time 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