Fix failing 500 errors when deploy tokens are used to clone
A DeployToken responds to `:username`, but it returns the username for the token, not a User object. Don't attempt to log user activity in this case. Closes gitlab-org/gitlab-ee#7080
This commit is contained in:
parent
93c7b6c51a
commit
1436423a49
2 changed files with 13 additions and 0 deletions
|
@ -11,6 +11,7 @@ module Users
|
|||
author.user
|
||||
end
|
||||
|
||||
@user = nil unless @user.is_a?(User)
|
||||
@activity = activity
|
||||
end
|
||||
|
||||
|
|
|
@ -28,6 +28,18 @@ describe Users::ActivityService do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when a bad object is passed' do
|
||||
let(:fake_object) { double(username: 'hello') }
|
||||
|
||||
it 'does not record activity' do
|
||||
service = described_class.new(fake_object, 'pull')
|
||||
|
||||
expect(service).not_to receive(:record_activity)
|
||||
|
||||
service.execute
|
||||
end
|
||||
end
|
||||
|
||||
context 'when last activity is today' do
|
||||
let(:last_activity_on) { Date.today }
|
||||
|
||||
|
|
Loading…
Reference in a new issue