Commit af041131 authored by Stan Hu's avatar Stan Hu

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
parent e5226177
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment