From dc8a97ecb15294ccf0a662b11b1f6e981e0918c9 Mon Sep 17 00:00:00 2001
From: Sean McGivern <sean@mcgivern.me.uk>
Date: Wed, 4 Jul 2018 10:36:06 +0000
Subject: [PATCH] Merge branch 'ccr/flaky_mr_list_spec' into 'master'

Fix flaky spec for merge request lists

See merge request gitlab-org/gitlab-ce!20316
---
 .../shared_examples/requests/api/merge_requests_list.rb      | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/spec/support/shared_examples/requests/api/merge_requests_list.rb b/spec/support/shared_examples/requests/api/merge_requests_list.rb
index a401f7541f0..1aed8ab0113 100644
--- a/spec/support/shared_examples/requests/api/merge_requests_list.rb
+++ b/spec/support/shared_examples/requests/api/merge_requests_list.rb
@@ -136,8 +136,9 @@ shared_examples 'merge requests list' do
     it 'returns an array of merge requests in given milestone' do
       get api(endpoint_path, user), milestone: '0.9'
 
-      expect(json_response.first['title']).to eq merge_request_closed.title
-      expect(json_response.first['id']).to eq merge_request_closed.id
+      closed_issues = json_response.select { |mr| mr['id'] == merge_request_closed.id }
+      expect(closed_issues.length).to eq(1)
+      expect(closed_issues.first['title']).to eq merge_request_closed.title
     end
 
     it 'returns an array of merge requests matching state in milestone' do
-- 
2.30.9