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
def whats_new_version_digest
ReleaseHighlight.most_recent_version_digest
end
def display_whats_new?
Gitlab.dev_env_org_or_com? || user_signed_in?
end
end
......@@ -120,7 +120,8 @@
= 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')
#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)
.js-set-status-modal-wrapper{ data: user_status_data }
%li
- if display_whats_new?
%li
%button.gl-justify-content-space-between.gl-align-items-center.js-whats-new-trigger{ type: 'button', class: 'gl-display-flex!' }
= _("What's new")
%span.js-whats-new-notification-count.whats-new-notification-count
......
---
title: Hide What's New for unauthenticated users
merge_request: 59330
author:
type: changed
......@@ -2,9 +2,34 @@
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) }
context 'when not logged in' do
it 'and on .com it renders' do
allow(Gitlab).to receive(:com?).and_return(true)
visit user_path(user)
page.within '.header-help' do
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)
page.within '.header-help' do
find('.header-help-dropdown-toggle').click
expect(page).not_to have_button(text: "What's new")
end
end
end
context 'when logged in', :js do
before do
sign_in(user)
end
......@@ -32,4 +57,5 @@ RSpec.describe "renders a `whats new` dropdown item", :js do
expect(page).not_to have_selector('.js-whats-new-notification-count')
end
end
end
end
......@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe WhatsNewHelper do
include Devise::Test::ControllerHelpers
describe '#whats_new_version_digest' do
let(:digest) { 'digest' }
......@@ -32,4 +34,30 @@ RSpec.describe WhatsNewHelper do
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
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