diff options
author | Stan Hu <stanhu@gmail.com> | 2017-05-29 09:15:03 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-05-29 09:25:52 +0300 |
commit | af0411313571bf69f956c52e17b8da578edf1fbf (patch) | |
tree | 49fd5f868b82ca21283a77cd4c70e01ce622e243 /spec/requests | |
parent | e5226177ac667c8ad4cc07270bbdef24031eb8a2 (diff) |
Fix failing spec in spec/requests/api/pipelines_spec.rb
The spec was trying to sort pipelines by user ID, but the same user ID
was being used for each pipeline in the spec.
Closes #33001
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/pipelines_spec.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb index f9e5316b3de..07fa0e3f526 100644 --- a/spec/requests/api/pipelines_spec.rb +++ b/spec/requests/api/pipelines_spec.rb @@ -7,7 +7,7 @@ describe API::Pipelines do let!(:pipeline) do create(:ci_empty_pipeline, project: project, sha: project.commit.id, - ref: project.default_branch) + ref: project.default_branch, user: user) end before { project.team << [user, :master] } @@ -232,7 +232,7 @@ describe API::Pipelines do context 'when order_by and sort are specified' do context 'when order_by user_id' do - let!(:pipeline) { create_list(:ci_pipeline, 2, project: project, user: create(:user)) } + before { 3.times { create(:ci_pipeline, project: project, user: create(:user)) } } it 'sorts as user_id: :asc' do get api("/projects/#{project.id}/pipelines", user), order_by: 'user_id', sort: 'asc' @@ -240,9 +240,9 @@ describe API::Pipelines do expect(response).to have_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).not_to be_empty - pipeline.sort_by { |p| p.user.id }.tap do |sorted_pipeline| - json_response.each_with_index { |r, i| expect(r['id']).to eq(sorted_pipeline[i].id) } - end + + pipeline_ids = Ci::Pipeline.all.sort_by { |p| p.user.id }.map(&:id) + expect(json_response.map { |r| r['id'] }).to eq(pipeline_ids) end context 'when sort is invalid' do |