Commit 6f5ebc4b authored by Bob Van Landuyt's avatar Bob Van Landuyt

Only cache the event for the fork-source when it exists

It is possible for a fork not to have a source anymore, in this case
we don't need to keep track of the push event.
parent 490cce63
...@@ -16,8 +16,8 @@ module Users ...@@ -16,8 +16,8 @@ module Users
user_cache_key user_cache_key
] ]
if event.project.forked? if forked_from = event.project.forked_from_project
keys << project_cache_key(event.project.forked_from_project) keys << project_cache_key(forked_from)
end end
keys.each { |key| set_key(key, event.id) } keys.each { |key| set_key(key, event.id) }
......
---
title: Only cache last push event for existing projects when pushing to a fork
merge_request: 14989
author:
type: fixed
...@@ -22,7 +22,6 @@ describe Users::LastPushEventService do ...@@ -22,7 +22,6 @@ describe Users::LastPushEventService do
it 'caches the event for the origin project when pushing to a fork' do it 'caches the event for the origin project when pushing to a fork' do
source = build(:project, id: 5) source = build(:project, id: 5)
allow(project).to receive(:forked?).and_return(true)
allow(project).to receive(:forked_from_project).and_return(source) allow(project).to receive(:forked_from_project).and_return(source)
expect(service).to receive(:set_key) expect(service).to receive(:set_key)
......
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