From 98ac988d4d9525b3f07a19e495a9c2666ebee3c6 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Sun, 19 Mar 2017 02:50:42 +0900 Subject: [PATCH] Use order instead of reorder. Improve tests. --- app/finders/pipelines_finder.rb | 2 +- spec/requests/api/pipelines_spec.rb | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/finders/pipelines_finder.rb b/app/finders/pipelines_finder.rb index 0c91c136a8f..22507472e15 100644 --- a/app/finders/pipelines_finder.rb +++ b/app/finders/pipelines_finder.rb @@ -118,6 +118,6 @@ class PipelinesFinder else :desc end - items.reorder(order_by => sort) + items.order(order_by => sort) end end diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb index 5e20a823d39..a0122d1d300 100644 --- a/spec/requests/api/pipelines_spec.rb +++ b/spec/requests/api/pipelines_spec.rb @@ -225,8 +225,11 @@ describe API::Pipelines do expect(response).to have_http_status(200) expect(response).to include_pagination_headers - expect(json_response.first['id']).to eq(project.pipelines.order(user_id: :asc).first.id) - expect(json_response.last['id']).to eq(project.pipelines.order(user_id: :asc).last.id) + expect(json_response).not_to be_empty + pipelines = project.pipelines.order(user_id: :asc) + json_response.each_with_index do |r, i| + expect(r['id']).to eq(pipelines[i].id) + end end end -- GitLab