diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-05-29 11:25:48 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-05-29 11:25:48 +0300 |
commit | 2a1130343a7b18faadcc2adbd99cfdb0e4304dc6 (patch) | |
tree | 2b8cea0e8803d099f607e51eea8d3b22f396d004 /spec/requests/api/pipelines_spec.rb | |
parent | 393f24ad8c90b68b10e78fcf6dd8b3fa4fb93c4e (diff) |
Improve pipelines API specs related to special parameters
Diffstat (limited to 'spec/requests/api/pipelines_spec.rb')
-rw-r--r-- | spec/requests/api/pipelines_spec.rb | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb index 689eea6506d..9e6957e9922 100644 --- a/spec/requests/api/pipelines_spec.rb +++ b/spec/requests/api/pipelines_spec.rb @@ -232,20 +232,26 @@ describe API::Pipelines do context 'when order_by and sort are specified' do context 'when order_by user_id' do - before { 3.times { create(:ci_pipeline, project: project, user: create(:user)) } } + before do + 3.times do + create(:ci_pipeline, project: project, user: create(:user)) + end + end - it 'sorts as user_id: :asc' do - get api("/projects/#{project.id}/pipelines", user), order_by: 'user_id', sort: 'asc' + context 'when sort parameter is valid' do + it 'sorts as user_id: :desc' do + get api("/projects/#{project.id}/pipelines", user), order_by: 'user_id', sort: 'desc' - expect(response).to have_http_status(:ok) - expect(response).to include_pagination_headers - expect(json_response).not_to be_empty + expect(response).to have_http_status(:ok) + expect(response).to include_pagination_headers + expect(json_response).not_to be_empty - pipeline_ids = Ci::Pipeline.all.order(:user_id).map(&:id) - expect(json_response.map { |r| r['id'] }).to eq(pipeline_ids) + pipeline_ids = Ci::Pipeline.all.order(user_id: :desc).pluck(:id) + expect(json_response.map { |r| r['id'] }).to eq(pipeline_ids) + end end - context 'when sort is invalid' do + context 'when sort parameter is invalid' do it 'returns bad_request' do get api("/projects/#{project.id}/pipelines", user), order_by: 'user_id', sort: 'invalid_sort' |