Commit 68a4fcce authored by Markus Koller's avatar Markus Koller

Merge branch 'jswain_whats_new_self_managed_authenticated' into 'master'

Hide What's New for unauthenticated users

See merge request gitlab-org/gitlab!59330
parents 06d3ff06 c0b727db
...@@ -8,4 +8,8 @@ module WhatsNewHelper ...@@ -8,4 +8,8 @@ module WhatsNewHelper
def whats_new_version_digest def whats_new_version_digest
ReleaseHighlight.most_recent_version_digest ReleaseHighlight.most_recent_version_digest
end end
def display_whats_new?
Gitlab.dev_env_org_or_com? || user_signed_in?
end
end end
...@@ -120,7 +120,8 @@ ...@@ -120,7 +120,8 @@
= sprite_icon('ellipsis_h', size: 12, css_class: 'more-icon js-navbar-toggle-right') = sprite_icon('ellipsis_h', size: 12, css_class: 'more-icon js-navbar-toggle-right')
= sprite_icon('close', size: 12, css_class: 'close-icon js-navbar-toggle-left') = sprite_icon('close', size: 12, css_class: 'close-icon js-navbar-toggle-left')
#whats-new-app{ data: { version_digest: whats_new_version_digest } } - if display_whats_new?
#whats-new-app{ data: { version_digest: whats_new_version_digest } }
- if can?(current_user, :update_user_status, current_user) - if can?(current_user, :update_user_status, current_user)
.js-set-status-modal-wrapper{ data: user_status_data } .js-set-status-modal-wrapper{ data: user_status_data }
%li - if display_whats_new?
%button.gl-justify-content-space-between.gl-align-items-center.js-whats-new-trigger{ type: 'button', class: 'gl-display-flex!' } %li
= _("What's new") %button.gl-justify-content-space-between.gl-align-items-center.js-whats-new-trigger{ type: 'button', class: 'gl-display-flex!' }
%span.js-whats-new-notification-count.whats-new-notification-count = _("What's new")
= whats_new_most_recent_release_items_count %span.js-whats-new-notification-count.whats-new-notification-count
= whats_new_most_recent_release_items_count
---
title: Hide What's New for unauthenticated users
merge_request: 59330
author:
type: changed
...@@ -2,34 +2,60 @@ ...@@ -2,34 +2,60 @@
require "spec_helper" require "spec_helper"
RSpec.describe "renders a `whats new` dropdown item", :js do RSpec.describe "renders a `whats new` dropdown item" do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
before do context 'when not logged in' do
sign_in(user) it 'and on .com it renders' do
end allow(Gitlab).to receive(:com?).and_return(true)
it 'shows notification dot and count and removes it once viewed' do visit user_path(user)
visit root_dashboard_path
page.within '.header-help' do page.within '.header-help' do
expect(page).to have_selector('.notification-dot', visible: true) find('.header-help-dropdown-toggle').click
find('.header-help-dropdown-toggle').click expect(page).to have_button(text: "What's new")
end
end
it "doesn't render what's new" do
visit user_path(user)
expect(page).to have_button(text: "What's new") page.within '.header-help' do
expect(page).to have_selector('.js-whats-new-notification-count') find('.header-help-dropdown-toggle').click
expect(page).not_to have_button(text: "What's new")
end
end
end
find('button', text: "What's new").click context 'when logged in', :js do
before do
sign_in(user)
end end
find('.whats-new-drawer .gl-drawer-close-button').click it 'shows notification dot and count and removes it once viewed' do
find('.header-help-dropdown-toggle').click visit root_dashboard_path
page.within '.header-help' do
expect(page).to have_selector('.notification-dot', visible: true)
find('.header-help-dropdown-toggle').click
expect(page).to have_button(text: "What's new")
expect(page).to have_selector('.js-whats-new-notification-count')
find('button', text: "What's new").click
end
find('.whats-new-drawer .gl-drawer-close-button').click
find('.header-help-dropdown-toggle').click
page.within '.header-help' do page.within '.header-help' do
expect(page).not_to have_selector('.notification-dot', visible: true) expect(page).not_to have_selector('.notification-dot', visible: true)
expect(page).to have_button(text: "What's new") expect(page).to have_button(text: "What's new")
expect(page).not_to have_selector('.js-whats-new-notification-count') expect(page).not_to have_selector('.js-whats-new-notification-count')
end
end end
end end
end end
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe WhatsNewHelper do RSpec.describe WhatsNewHelper do
include Devise::Test::ControllerHelpers
describe '#whats_new_version_digest' do describe '#whats_new_version_digest' do
let(:digest) { 'digest' } let(:digest) { 'digest' }
...@@ -32,4 +34,30 @@ RSpec.describe WhatsNewHelper do ...@@ -32,4 +34,30 @@ RSpec.describe WhatsNewHelper do
end end
end end
end end
describe '#display_whats_new?' do
subject { helper.display_whats_new? }
it 'returns true when gitlab.com' do
allow(Gitlab).to receive(:dev_env_org_or_com?).and_return(true)
expect(subject).to be true
end
context 'when self-managed' do
before do
allow(Gitlab).to receive(:dev_env_org_or_com?).and_return(false)
end
it 'returns true if user is signed in' do
sign_in(create(:user))
expect(subject).to be true
end
it "returns false if user isn't signed in" do
expect(subject).to be false
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