Commit 28c48804 authored by Stan Hu's avatar Stan Hu
Browse files

Fix failing test in spec/workers/post_receive_spec.rb

This is what was happening before:

1. `Project#set_timestamps_for_create` was called at creation time
and set the `last_activity_at` and `last_repository_updated_at`
to the current timestamp T.

2. The test ran `PostReceive#perform`, which then called
`PostReceive#process_wiki_changes`. If less than 500 milliseconds
elapsed since T, then the update would just set the timestamp to T.

To fix this problem, we can just use Timecop to ensure at least
one second has elapsed after attempting to process changes.

parent 3daa53e8
......@@ -141,11 +141,18 @@
let(:gl_repository) { "wiki-#{}" }
it 'updates project activity' do, key_id, base64_changes)
# Force Project#set_timestamps_for_create to initialize timestamps
expect { project.reload }
.to change(project, :last_activity_at)
.and change(project, :last_repository_updated_at)
# MySQL drops milliseconds in the timestamps, so advance at least
# a second to ensure we see changes.
Timecop.freeze(1.second.from_now) do
expect do, key_id, base64_changes)
project.reload change(project, :last_activity_at)
.and change(project, :last_repository_updated_at)
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