Commit 57c353fc authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix tests and review

parent 9d4b6f22
...@@ -168,6 +168,8 @@ class Project < ActiveRecord::Base ...@@ -168,6 +168,8 @@ class Project < ActiveRecord::Base
has_many :environments, dependent: :destroy has_many :environments, dependent: :destroy
has_many :deployments, 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 :variables, allow_destroy: true
accepts_nested_attributes_for :project_feature accepts_nested_attributes_for :project_feature
...@@ -1096,20 +1098,12 @@ class Project < ActiveRecord::Base ...@@ -1096,20 +1098,12 @@ class Project < ActiveRecord::Base
@shared_runners ||= shared_runners_available? ? Ci::Runner.shared : Ci::Runner.none @shared_runners ||= shared_runners_available? ? Ci::Runner.shared : Ci::Runner.none
end end
def active_runners
@active_runners ||= runners.active
end
def active_shared_runners def active_shared_runners
@active_shared_runners ||= shared_runners.active @active_shared_runners ||= shared_runners.active
end end
def any_runners?(&block) def any_runners?(&block)
if active_runners.any?(&block) active_runners.any?(&block) || active_shared_runners.any?(&block)
return true
end
active_shared_runners.any?(&block)
end end
def valid_runners_token?(token) def valid_runners_token?(token)
......
---
title: Optimise pipelines.json endpoint
merge_request:
author:
...@@ -76,12 +76,6 @@ excluded_attributes: ...@@ -76,12 +76,6 @@ excluded_attributes:
statuses: statuses:
- :trace - :trace
- :token - :token
pipelines:
- :pending_builds
- :retryable_builds
- :cancelable_statuses
- :manual_actions
- :artifacts
methods: methods:
labels: labels:
......
...@@ -57,6 +57,7 @@ describe Project, models: true do ...@@ -57,6 +57,7 @@ describe Project, models: true do
it { is_expected.to have_many(:builds) } it { is_expected.to have_many(:builds) }
it { is_expected.to have_many(:runner_projects) } it { is_expected.to have_many(:runner_projects) }
it { is_expected.to have_many(:runners) } 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(:variables) }
it { is_expected.to have_many(:triggers) } it { is_expected.to have_many(:triggers) }
it { is_expected.to have_many(:pages_domains) } it { is_expected.to have_many(:pages_domains) }
......
...@@ -463,8 +463,7 @@ describe Ci::ProcessPipelineService, '#execute', :services do ...@@ -463,8 +463,7 @@ describe Ci::ProcessPipelineService, '#execute', :services do
end end
def manual_actions def manual_actions
pipeline.reload pipeline.manual_actions(true)
pipeline.manual_actions
end end
def create_build(name, **opts) def create_build(name, **opts)
......
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