Make deprecated scopes of Runner explicit
This commit is contained in:
parent
ca93faf15f
commit
d3bcb06dc6
|
@ -30,9 +30,9 @@ module Ci
|
||||||
scope :ordered, -> { order(id: :desc) }
|
scope :ordered, -> { order(id: :desc) }
|
||||||
|
|
||||||
# BACKWARD COMPATIBILITY: There are needed to maintain compatibility with `AVAILABLE_SCOPES` used by `lib/api/runners.rb`
|
# BACKWARD COMPATIBILITY: There are needed to maintain compatibility with `AVAILABLE_SCOPES` used by `lib/api/runners.rb`
|
||||||
scope :shared, -> { instance_type }
|
scope :deprecated_shared, -> { instance_type }
|
||||||
# this should get replaced with `project_type.or(group_type)` once using Rails5
|
# this should get replaced with `project_type.or(group_type)` once using Rails5
|
||||||
scope :specific, -> { where(runner_type: [runner_types[:project_type], runner_types[:group_type]]) }
|
scope :deprecated_specific, -> { where(runner_type: [runner_types[:project_type], runner_types[:group_type]]) }
|
||||||
|
|
||||||
scope :belonging_to_project, -> (project_id) {
|
scope :belonging_to_project, -> (project_id) {
|
||||||
joins(:runner_projects).where(ci_runner_projects: { project_id: project_id })
|
joins(:runner_projects).where(ci_runner_projects: { project_id: project_id })
|
||||||
|
|
|
@ -170,6 +170,11 @@ module API
|
||||||
render_api_error!('Scope contains invalid value', 400)
|
render_api_error!('Scope contains invalid value', 400)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Support deprecated scopes
|
||||||
|
if runners.respond_to?("deprecated_#{scope}")
|
||||||
|
scope = "deprecated_#{scope}"
|
||||||
|
end
|
||||||
|
|
||||||
runners.public_send(scope) # rubocop:disable GitlabSecurity/PublicSend
|
runners.public_send(scope) # rubocop:disable GitlabSecurity/PublicSend
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,17 @@ describe API::Runners do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'filters runners by scope' do
|
||||||
|
get api('/runners/all?scope=shared', admin)
|
||||||
|
|
||||||
|
shared = json_response.all? { |r| r['is_shared'] }
|
||||||
|
expect(response).to have_gitlab_http_status(200)
|
||||||
|
expect(response).to include_pagination_headers
|
||||||
|
expect(json_response).to be_an Array
|
||||||
|
expect(json_response[0]).to have_key('ip_address')
|
||||||
|
expect(shared).to be_truthy
|
||||||
|
end
|
||||||
|
|
||||||
it 'filters runners by scope' do
|
it 'filters runners by scope' do
|
||||||
get api('/runners/all?scope=specific', admin)
|
get api('/runners/all?scope=specific', admin)
|
||||||
|
|
||||||
|
@ -584,7 +595,7 @@ describe API::Runners do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'enables a instance-wide runner' do
|
it 'enables a instance type runner' do
|
||||||
expect do
|
expect do
|
||||||
post api("/projects/#{project.id}/runners", admin), runner_id: shared_runner.id
|
post api("/projects/#{project.id}/runners", admin), runner_id: shared_runner.id
|
||||||
end.to change { project.runners.count }.by(1)
|
end.to change { project.runners.count }.by(1)
|
||||||
|
|
Loading…
Reference in New Issue