Commit 66b97bc2 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Abstract persisted/legacy stages in pipeline model

Conflicts:
	app/controllers/projects/pipelines_controller.rb
parent 9d1b37c3
......@@ -262,6 +262,16 @@ module Ci
stage unless stage.statuses_count.zero?
end
##
# TODO consider switching to persisted stages only in pipelines table
# (not necessairly in the show pipeline page because of #23257.
# Hide this behind two feature flags - enabled / disabled and only
# gitlab-ce / everywhere.
#
def stages
super
end
def legacy_stages
# TODO, this needs refactoring, see gitlab-ce#26481.
......
class PipelineDetailsEntity < PipelineEntity
expose :details do
##
# TODO consider switching to persisted stages only in pipelines table
# (not necessairly in the show pipeline page because of #23257.
# Hide this behind two feature flags - enabled / disabled and only
# gitlab-ce / everywhere.
expose :stages, as: :stages, using: StageEntity
expose :stages, using: StageEntity
expose :artifacts, using: BuildArtifactEntity
expose :manual_actions, using: BuildActionEntity
end
......
......@@ -17,8 +17,7 @@ describe Projects::PipelinesController do
describe 'GET index.json' do
before do
%w(pending running running success canceled)
.each_with_index do |status, index|
%w(pending running success failed).each_with_index do |status, index|
create_pipeline(status, project.commit("HEAD~#{index}"))
end
end
......@@ -32,11 +31,13 @@ describe Projects::PipelinesController do
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 '2'
expect(json_response['pipelines'].count).to eq 4
expect(json_response['count']['all']).to eq '4'
expect(json_response['count']['running']).to eq '1'
expect(json_response['count']['pending']).to eq '1'
expect(json_response['count']['finished']).to eq '2'
puts queries.log
puts "Queries count: #{queries.count}"
expect(queries.count).to be < 32
end
......
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