Commit d2a5dd18 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'pedropombeiro/328518/add-missing-runner-scope' into 'master'

Add missing not_connected scope to Ci::Runner

See merge request gitlab-org/gitlab!61579
parents 6f8d3929 b1f542de
......@@ -39,7 +39,7 @@ module Ci
AVAILABLE_TYPES_LEGACY = %w[specific shared].freeze
AVAILABLE_TYPES = runner_types.keys.freeze
AVAILABLE_STATUSES = %w[active paused online offline].freeze
AVAILABLE_STATUSES = %w[active paused online offline not_connected].freeze
AVAILABLE_SCOPES = (AVAILABLE_TYPES_LEGACY + AVAILABLE_TYPES + AVAILABLE_STATUSES).freeze
FORM_EDITABLE = %i[description tag_list active run_untagged locked access_level maximum_timeout_human_readable].freeze
......@@ -65,6 +65,7 @@ module Ci
# did `contacted_at <= ?` the query would effectively have to do a seq
# scan.
scope :offline, -> { where.not(id: online) }
scope :not_connected, -> { where(contacted_at: nil) }
scope :ordered, -> { order(id: :desc) }
scope :with_recent_runner_queue, -> { where('contacted_at > ?', recent_queue_deadline) }
......
......@@ -13585,6 +13585,7 @@ Values for YAML processor result.
| Value | Description |
| ----- | ----------- |
| <a id="cirunnerstatusactive"></a>`ACTIVE` | A runner that is active. |
| <a id="cirunnerstatusnot_connected"></a>`NOT_CONNECTED` | A runner that is not connected. |
| <a id="cirunnerstatusoffline"></a>`OFFLINE` | A runner that is offline. |
| <a id="cirunnerstatusonline"></a>`ONLINE` | A runner that is online. |
| <a id="cirunnerstatuspaused"></a>`PAUSED` | A runner that is paused. |
......
......@@ -25,10 +25,12 @@ RSpec.describe Ci::RunnersFinder do
end
context 'filter by status' do
it 'calls the corresponding scope on Ci::Runner' do
expect(Ci::Runner).to receive(:paused).and_call_original
Ci::Runner::AVAILABLE_STATUSES.each do |status|
it "calls the corresponding :#{status} scope on Ci::Runner" do
expect(Ci::Runner).to receive(status.to_sym).and_call_original
described_class.new(current_user: admin, params: { status_status: 'paused' }).execute
described_class.new(current_user: admin, params: { status_status: status }).execute
end
end
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