diff options
author | Airat Shigapov <contact@airatshigapov.com> | 2016-10-24 16:47:18 +0300 |
---|---|---|
committer | Airat Shigapov <contact@airatshigapov.com> | 2016-10-24 22:56:28 +0300 |
commit | 05084a456596c7ebf853f2963551ea5475b34928 (patch) | |
tree | cae02338d60473fde0fa176d3a3fcc018dbd4251 /spec/requests | |
parent | ae099857b00c8d9ed48397b782ac6410114183a6 (diff) | |
download | gitlab-ce-05084a456596c7ebf853f2963551ea5475b34928.tar.gz |
Make events order spec deterministic, create only 3 record instead of 5, explicitely check for events order
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/users_spec.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index f07460bbc25..ae8639d78d5 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -960,23 +960,25 @@ describe API::API, api: true do end context 'when there are multiple events from different projects' do - let(:another_project) { create(:empty_project) } - let(:notes) { create_list(:note_on_issue, 5, project: [project, another_project].sample) } + let(:second_note) { create(:note_on_issue, project: create(:empty_project)) } + let(:third_note) { create(:note_on_issue, project: project) } before do - another_project.add_user(user, :developer) + second_note.project.add_user(user, :developer) - notes.each { |note| EventCreateService.new.leave_note(note, user) } + [second_note, third_note].each do |note| + EventCreateService.new.leave_note(note, user) + end end - it 'returns them in the correct order (from newest to oldest determined by ID field)' do + it 'returns events in the correct order (from newest to oldest)' do get api("/users/#{user.id}/events", user) comment_events = json_response.select { |e| e['action_name'] == 'commented on' } - notes.reverse.each_with_index do |note, i| - expect(note.id).to eq(comment_events[i]['target_id']) - end + expect(comment_events[0]['target_id']).to eq(third_note.id) + expect(comment_events[1]['target_id']).to eq(second_note.id) + expect(comment_events[2]['target_id']).to eq(note.id) end end end |