Commit 3662f147 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Improve specs for pipelines controller

parent fc3d2141
......@@ -17,11 +17,44 @@ describe Projects::PipelinesController do
describe 'GET index.json' do
before do
%w(pending running success failed).each_with_index do |status, index|
%w(pending running success failed canceled).each_with_index do |status, index|
create_pipeline(status, project.commit("HEAD~#{index}"))
end
end
context 'when using persisted stages', :request_store do
before do
stub_feature_flags(ci_pipeline_persisted_stages: true)
end
it 'returns serialized pipelines', :request_store do
queries = ActiveRecord::QueryRecorder.new do
get_pipelines_index_json
end
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('pipeline')
expect(json_response).to include('pipelines')
expect(json_response['pipelines'].count).to eq 5
expect(json_response['count']['all']).to eq '5'
expect(json_response['count']['running']).to eq '1'
expect(json_response['count']['pending']).to eq '1'
expect(json_response['count']['finished']).to eq '3'
json_response.dig('pipelines', 0, 'details', 'stages').tap do |stages|
expect(stages.count).to eq 3
end
expect(queries.count).to be
end
end
context 'when using legacy stages', :request_store do
before do
stub_feature_flags(ci_pipeline_persisted_stages: false)
end
it 'returns JSON with serialized pipelines', :request_store do
queries = ActiveRecord::QueryRecorder.new do
get_pipelines_index_json
......@@ -31,12 +64,18 @@ describe Projects::PipelinesController do
expect(response).to match_response_schema('pipeline')
expect(json_response).to include('pipelines')
expect(json_response['pipelines'].count).to eq 4
expect(json_response['count']['all']).to eq '4'
expect(json_response['pipelines'].count).to eq 5
expect(json_response['count']['all']).to eq '5'
expect(json_response['count']['running']).to eq '1'
expect(json_response['count']['pending']).to eq '1'
expect(json_response['count']['finished']).to eq '2'
expect(queries.count).to be < 30
expect(json_response['count']['finished']).to eq '3'
json_response.dig('pipelines', 0, 'details', 'stages').tap do |stages|
expect(stages.count).to eq 3
end
expect(queries.count).to be_within(3).of(30)
end
end
it 'does not include coverage data for the pipelines' 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