diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-05-22 13:04:07 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-05-22 13:04:07 +0200 |
commit | 76a7157c76c47fd4f835a27eeeda7b42012936be (patch) | |
tree | 2af829764f509e7d35a9418062a33310d7da48f1 | |
parent | fb706d69abb2bb8f07f78b2a14206027f062cc30 (diff) | |
download | gitlab-ce-76a7157c76c47fd4f835a27eeeda7b42012936be.tar.gz |
Abstract persisted/legacy stages in pipeline model
-rw-r--r-- | app/controllers/projects/pipelines_controller.rb | 2 | ||||
-rw-r--r-- | app/models/ci/pipeline.rb | 10 | ||||
-rw-r--r-- | app/serializers/pipeline_details_entity.rb | 7 | ||||
-rw-r--r-- | spec/controllers/projects/pipelines_controller_spec.rb | 11 |
4 files changed, 18 insertions, 12 deletions
diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 172642a1225..7c18c0c4fcb 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -1,5 +1,5 @@ class Projects::PipelinesController < Projects::ApplicationController - # before_action :whitelist_query_limiting, only: [:create, :retry] + before_action :whitelist_query_limiting, only: [:create, :retry] # TODO? before_action :pipeline, except: [:index, :new, :create, :charts] before_action :commit, only: [:show, :builds, :failures] before_action :authorize_read_pipeline! diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 774d5eb8125..9dac56fcd57 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -249,6 +249,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. diff --git a/app/serializers/pipeline_details_entity.rb b/app/serializers/pipeline_details_entity.rb index 2438a5bbbdf..d58572a5f87 100644 --- a/app/serializers/pipeline_details_entity.rb +++ b/app/serializers/pipeline_details_entity.rb @@ -1,11 +1,6 @@ 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 diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb index d5a0d32054b..c8080056f69 100644 --- a/spec/controllers/projects/pipelines_controller_spec.rb +++ b/spec/controllers/projects/pipelines_controller_spec.rb @@ -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 |