Fix tests and review

This commit is contained in:
Kamil Trzcinski 2017-04-06 21:57:04 +02:00
parent 9d4b6f2261
commit 57c353fca7
No known key found for this signature in database
GPG key ID: 4505F5C7E12C6A5A
5 changed files with 9 additions and 17 deletions

View file

@ -168,6 +168,8 @@ class Project < ActiveRecord::Base
has_many :environments, dependent: :destroy
has_many :deployments, dependent: :destroy
has_many :active_runners, -> { active }, through: :runner_projects, source: :runner, class_name: 'Ci::Runner'
accepts_nested_attributes_for :variables, allow_destroy: true
accepts_nested_attributes_for :project_feature
@ -1096,20 +1098,12 @@ class Project < ActiveRecord::Base
@shared_runners ||= shared_runners_available? ? Ci::Runner.shared : Ci::Runner.none
end
def active_runners
@active_runners ||= runners.active
end
def active_shared_runners
@active_shared_runners ||= shared_runners.active
end
def any_runners?(&block)
if active_runners.any?(&block)
return true
end
active_shared_runners.any?(&block)
active_runners.any?(&block) || active_shared_runners.any?(&block)
end
def valid_runners_token?(token)

View file

@ -0,0 +1,4 @@
---
title: Optimise pipelines.json endpoint
merge_request:
author:

View file

@ -76,12 +76,6 @@ excluded_attributes:
statuses:
- :trace
- :token
pipelines:
- :pending_builds
- :retryable_builds
- :cancelable_statuses
- :manual_actions
- :artifacts
methods:
labels:

View file

@ -57,6 +57,7 @@ describe Project, models: true do
it { is_expected.to have_many(:builds) }
it { is_expected.to have_many(:runner_projects) }
it { is_expected.to have_many(:runners) }
it { is_expected.to have_many(:active_runners) }
it { is_expected.to have_many(:variables) }
it { is_expected.to have_many(:triggers) }
it { is_expected.to have_many(:pages_domains) }

View file

@ -463,8 +463,7 @@ describe Ci::ProcessPipelineService, '#execute', :services do
end
def manual_actions
pipeline.reload
pipeline.manual_actions
pipeline.manual_actions(true)
end
def create_build(name, **opts)