summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-08-02 11:17:00 -0700
committerStan Hu <stanhu@gmail.com>2018-08-02 11:18:31 -0700
commit1436423a490fe9f4c1ee1ccb8ecaa6240eed2906 (patch)
tree96aeebc6a85639996b106282663de41c41a7966f /spec/services
parent93c7b6c51a49a1939a876f2510a69e59827ac816 (diff)
downloadgitlab-ce-1436423a490fe9f4c1ee1ccb8ecaa6240eed2906.tar.gz
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
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/users/activity_service_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/services/users/activity_service_spec.rb b/spec/services/users/activity_service_spec.rb
index f20849e6924..719b4adf212 100644
--- a/spec/services/users/activity_service_spec.rb
+++ b/spec/services/users/activity_service_spec.rb
@@ -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 }