summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-03-19 02:50:42 +0900
committerShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-05-03 02:11:51 +0900
commit98ac988d4d9525b3f07a19e495a9c2666ebee3c6 (patch)
tree34dabbb70d716df5ad123875d24210bdc0d83115
parent8f32724fcb7f05052b53dcd365a064ad87a9535e (diff)
downloadgitlab-ce-98ac988d4d9525b3f07a19e495a9c2666ebee3c6.tar.gz
Use order instead of reorder. Improve tests.
-rw-r--r--app/finders/pipelines_finder.rb2
-rw-r--r--spec/requests/api/pipelines_spec.rb7
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