summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/projects/settings/ci_cd_controller.rb2
-rw-r--r--app/models/user.rb4
-rw-r--r--app/policies/ci/runner_policy.rb12
-rw-r--r--lib/api/runners.rb2
-rw-r--r--lib/api/v3/runners.rb2
-rw-r--r--spec/models/user_spec.rb14
6 files changed, 18 insertions, 18 deletions
diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb
index 177c8a54099..1d850baf012 100644
--- a/app/controllers/projects/settings/ci_cd_controller.rb
+++ b/app/controllers/projects/settings/ci_cd_controller.rb
@@ -69,7 +69,7 @@ module Projects
@project_runners = @project.runners.ordered
@assignable_runners = current_user
- .ci_authorized_runners
+ .ci_owned_runners
.assignable_for(project)
.ordered
.page(params[:page]).per(20)
diff --git a/app/models/user.rb b/app/models/user.rb
index 2afe9ea77f9..226a4489261 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -999,8 +999,8 @@ class User < ActiveRecord::Base
!solo_owned_groups.present?
end
- def ci_authorized_runners
- @ci_authorized_runners ||= begin
+ def ci_owned_runners
+ @ci_owned_runners ||= begin
project_runner_ids = Ci::RunnerProject
.where(project: authorized_projects(Gitlab::Access::MASTER))
.select(:runner_id)
diff --git a/app/policies/ci/runner_policy.rb b/app/policies/ci/runner_policy.rb
index 82d8e86ae05..61912696e88 100644
--- a/app/policies/ci/runner_policy.rb
+++ b/app/policies/ci/runner_policy.rb
@@ -3,14 +3,14 @@ module Ci
with_options scope: :subject, score: 0
condition(:locked, scope: :subject) { @subject.locked? }
- condition(:authorized_runner) { @user.ci_authorized_runners.exists?(@subject.id) }
+ condition(:owned_runner) { @user.ci_owned_runners.exists?(@subject.id) }
rule { anonymous }.prevent_all
- rule { admin | authorized_runner }.enable :assign_runner
- rule { admin | authorized_runner }.enable :read_runner
- rule { admin | authorized_runner }.enable :update_runner
- rule { admin | authorized_runner }.enable :delete_runner
- rule { admin | authorized_runner }.enable :list_runner_jobs
+ rule { admin | owned_runner }.enable :assign_runner
+ rule { admin | owned_runner }.enable :read_runner
+ rule { admin | owned_runner }.enable :update_runner
+ rule { admin | owned_runner }.enable :delete_runner
+ rule { admin | owned_runner }.enable :list_runner_jobs
rule { ~admin & locked }.prevent :assign_runner
end
end
diff --git a/lib/api/runners.rb b/lib/api/runners.rb
index db9cff80cf9..4f12aeac1fd 100644
--- a/lib/api/runners.rb
+++ b/lib/api/runners.rb
@@ -14,7 +14,7 @@ module API
use :pagination
end
get do
- runners = filter_runners(current_user.ci_authorized_runners, params[:scope], without: %w(specific shared))
+ runners = filter_runners(current_user.ci_owned_runners, params[:scope], without: %w(specific shared))
present paginate(runners), with: Entities::Runner
end
diff --git a/lib/api/v3/runners.rb b/lib/api/v3/runners.rb
index c6d9957d452..8a5c46805bd 100644
--- a/lib/api/v3/runners.rb
+++ b/lib/api/v3/runners.rb
@@ -58,7 +58,7 @@ module API
end
def user_can_access_runner?(runner)
- current_user.ci_authorized_runners.exists?(runner.id)
+ current_user.ci_owned_runners.exists?(runner.id)
end
end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 52d25d20442..de15e0e62aa 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -1786,7 +1786,7 @@ describe User do
end
end
- describe '#ci_authorized_runners' do
+ describe '#ci_owned_runners' do
let(:user) { create(:user) }
let(:runner_1) { create(:ci_runner) }
let(:runner_2) { create(:ci_runner) }
@@ -1796,7 +1796,7 @@ describe User do
let!(:group) { create(:group) }
it 'does not load' do
- expect(user.ci_authorized_runners).to be_empty
+ expect(user.ci_owned_runners).to be_empty
end
end
@@ -1805,7 +1805,7 @@ describe User do
let!(:project) { create(:project, namespace: namespace, runners: [runner_1]) }
it 'loads' do
- expect(user.ci_authorized_runners).to contain_exactly(runner_1)
+ expect(user.ci_owned_runners).to contain_exactly(runner_1)
end
end
@@ -1818,7 +1818,7 @@ describe User do
end
it 'loads' do
- expect(user.ci_authorized_runners).to contain_exactly(runner_2)
+ expect(user.ci_owned_runners).to contain_exactly(runner_2)
end
end
@@ -1833,7 +1833,7 @@ describe User do
end
it 'loads' do
- expect(user.ci_authorized_runners).to contain_exactly(runner_1, runner_2)
+ expect(user.ci_owned_runners).to contain_exactly(runner_1, runner_2)
end
end
@@ -1844,7 +1844,7 @@ describe User do
end
it 'loads' do
- expect(user.ci_authorized_runners).to contain_exactly(runner_1)
+ expect(user.ci_owned_runners).to contain_exactly(runner_1)
end
end
@@ -1854,7 +1854,7 @@ describe User do
end
it 'does not load' do
- expect(user.ci_authorized_runners).to be_empty
+ expect(user.ci_owned_runners).to be_empty
end
end
end