Commit bff597fb authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'nil-fix-pat-notification-callout' into 'master'

Handle case when user is not present for PAT notification banner

See merge request gitlab-org/gitlab!37330
parents 828a6c76 276f4114
...@@ -89,6 +89,8 @@ module EE ...@@ -89,6 +89,8 @@ module EE
end end
def show_token_expiry_notification? def show_token_expiry_notification?
return false unless current_user
!token_expiration_enforced? && !token_expiration_enforced? &&
current_user.active? && current_user.active? &&
!user_dismissed?(PERSONAL_ACCESS_TOKEN_EXPIRY, 1.week.ago) !user_dismissed?(PERSONAL_ACCESS_TOKEN_EXPIRY, 1.week.ago)
......
...@@ -371,6 +371,17 @@ RSpec.describe EE::UserCalloutsHelper do ...@@ -371,6 +371,17 @@ RSpec.describe EE::UserCalloutsHelper do
it do it do
expect(subject).to be result expect(subject).to be result
end end
context 'when user is nil' do
before do
allow(helper).to receive(:current_user).and_return(nil)
allow(helper).to receive(:token_expiration_enforced?).and_return(false)
end
it do
expect(subject).to be false
end
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