Commit 276f4114 authored by Aishwarya Subramanian's avatar Aishwarya Subramanian

Handle when user is nil for PAT notification

Add a nil check for current_user
while determining if a banner is required
to be shown for PAT expiration.
parent ba8399bd
...@@ -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