summaryrefslogtreecommitdiff
path: root/spec/models/event_spec.rb
diff options
context:
space:
mode:
authorAndreas Brandl <abrandl@gitlab.com>2018-05-28 14:58:23 +0200
committerAndreas Brandl <abrandl@gitlab.com>2018-05-29 12:51:32 +0200
commit61ea2f52bd32d5038b9eec1caf29a4d4531d03c4 (patch)
treefdc5782c18c2150fa119c3ee8c89a36d0ef45d62 /spec/models/event_spec.rb
parent71dea693c61295c16cb9c28c76b1122a3b8a3acf (diff)
downloadgitlab-ce-61ea2f52bd32d5038b9eec1caf29a4d4531d03c4.tar.gz
Throttle updates to Project#last_repository_updated_at.
Closes #35364.
Diffstat (limited to 'spec/models/event_spec.rb')
-rw-r--r--spec/models/event_spec.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb
index 8ea92410022..c1eac4fa489 100644
--- a/spec/models/event_spec.rb
+++ b/spec/models/event_spec.rb
@@ -50,6 +50,19 @@ describe Event do
end
end
+ describe '#set_last_repository_updated_at' do
+ it 'only updates once every Event::REPOSITORY_UPDATED_AT_INTERVAL minutes' do
+ last_known_timestamp = (Event::REPOSITORY_UPDATED_AT_INTERVAL - 1.minute).ago
+ project.update(last_repository_updated_at: last_known_timestamp)
+ project.reload # a reload removes fractions of seconds
+
+ expect do
+ create_push_event(project, project.owner)
+ project.reload
+ end.not_to change { project.last_repository_updated_at }
+ end
+ end
+
describe 'after_create :track_user_interacted_projects' do
let(:event) { build(:push_event, project: project, author: project.owner) }