Commit 4efc1c4a authored by Lin Jen-Shin's avatar Lin Jen-Shin

Rename according to:

https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4093#note_12563922

For clarification and consistency
parent 60ef0dd2
...@@ -5,9 +5,9 @@ class Projects::RunnersController < Projects::ApplicationController ...@@ -5,9 +5,9 @@ class Projects::RunnersController < Projects::ApplicationController
layout 'project_settings' layout 'project_settings'
def index def index
@runners = project.runners.ordered @project_runners = project.runners.ordered
@specific_runners = current_user.ci_authorized_runners. @assignable_runners = current_user.ci_authorized_runners.
available_for(project).ordered.page(params[:page]).per(20) assignable_for(project).ordered.page(params[:page]).per(20)
@shared_runners = Ci::Runner.shared.active @shared_runners = Ci::Runner.shared.active
@shared_runners_count = @shared_runners.count(:all) @shared_runners_count = @shared_runners.count(:all)
end end
......
...@@ -26,7 +26,7 @@ module Ci ...@@ -26,7 +26,7 @@ module Ci
.where("ci_runner_projects.gl_project_id = :project_id OR ci_runners.is_shared = true", project_id: project_id) .where("ci_runner_projects.gl_project_id = :project_id OR ci_runners.is_shared = true", project_id: project_id)
end end
scope :available_for, ->(project) do scope :assignable_for, ->(project) do
# FIXME: That `to_sql` is needed to workaround a weird Rails bug. # FIXME: That `to_sql` is needed to workaround a weird Rails bug.
# Without that, placeholders would miss one and couldn't match. # Without that, placeholders would miss one and couldn't match.
where(locked: false). where(locked: false).
...@@ -99,7 +99,7 @@ module Ci ...@@ -99,7 +99,7 @@ module Ci
end end
def can_pick?(build) def can_pick?(build)
available_for?(build.project) && accepting_tags?(build) assignable_for?(build.project) && accepting_tags?(build)
end end
def only_for?(project) def only_for?(project)
...@@ -123,7 +123,7 @@ module Ci ...@@ -123,7 +123,7 @@ module Ci
end end
end end
def available_for?(project) def assignable_for?(project)
!locked? || projects.exists?(id: project.id) !locked? || projects.exists?(id: project.id)
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
%h4 %h4
= runner_status_icon(runner) = runner_status_icon(runner)
%span.monospace %span.monospace
- if @runners.include?(runner) - if @project_runners.include?(runner)
= link_to runner.short_sha, runner_path(runner) = link_to runner.short_sha, runner_path(runner)
- if runner.locked? - if runner.locked?
= icon('lock', class: 'has-tooltip', title: 'Exclusive to this project') = icon('lock', class: 'has-tooltip', title: 'Exclusive to this project')
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
= runner.short_sha = runner.short_sha
.pull-right .pull-right
- if @runners.include?(runner) - if @project_runners.include?(runner)
- if runner.belongs_to_one_project? - if runner.belongs_to_one_project?
= link_to 'Remove runner', runner_path(runner), data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-sm' = link_to 'Remove runner', runner_path(runner), data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-sm'
- else - else
......
...@@ -17,13 +17,13 @@ ...@@ -17,13 +17,13 @@
Start runner! Start runner!
- if @runners.any? - if @project_runners.any?
%h4.underlined-title Runners activated for this project %h4.underlined-title Runners activated for this project
%ul.bordered-list.activated-specific-runners %ul.bordered-list.activated-specific-runners
= render partial: 'runner', collection: @runners, as: :runner = render partial: 'runner', collection: @project_runners, as: :runner
- if @specific_runners.any? - if @assignable_runners.any?
%h4.underlined-title Available specific runners %h4.underlined-title Available specific runners
%ul.bordered-list.available-specific-runners %ul.bordered-list.available-specific-runners
= render partial: 'runner', collection: @specific_runners, as: :runner = render partial: 'runner', collection: @assignable_runners, as: :runner
= paginate @specific_runners = paginate @assignable_runners
...@@ -263,7 +263,7 @@ describe Ci::Runner, models: true do ...@@ -263,7 +263,7 @@ describe Ci::Runner, models: true do
end end
end end
describe '.available_for' do describe '.assignable_for' do
let(:runner) { create(:ci_runner) } let(:runner) { create(:ci_runner) }
let(:project) { create(:project) } let(:project) { create(:project) }
let(:another_project) { create(:project) } let(:another_project) { create(:project) }
...@@ -278,13 +278,13 @@ describe Ci::Runner, models: true do ...@@ -278,13 +278,13 @@ describe Ci::Runner, models: true do
end end
context 'does not give owned runner' do context 'does not give owned runner' do
subject { Ci::Runner.available_for(project) } subject { Ci::Runner.assignable_for(project) }
it { is_expected.to be_empty } it { is_expected.to be_empty }
end end
context 'does not give shared runner' do context 'does not give shared runner' do
subject { Ci::Runner.available_for(another_project) } subject { Ci::Runner.assignable_for(another_project) }
it { is_expected.to be_empty } it { is_expected.to be_empty }
end end
...@@ -292,13 +292,13 @@ describe Ci::Runner, models: true do ...@@ -292,13 +292,13 @@ describe Ci::Runner, models: true do
context 'with unlocked runner' do context 'with unlocked runner' do
context 'does not give owned runner' do context 'does not give owned runner' do
subject { Ci::Runner.available_for(project) } subject { Ci::Runner.assignable_for(project) }
it { is_expected.to be_empty } it { is_expected.to be_empty }
end end
context 'does give a specific runner' do context 'does give a specific runner' do
subject { Ci::Runner.available_for(another_project) } subject { Ci::Runner.assignable_for(another_project) }
it { is_expected.to contain_exactly(runner) } it { is_expected.to contain_exactly(runner) }
end end
...@@ -310,13 +310,13 @@ describe Ci::Runner, models: true do ...@@ -310,13 +310,13 @@ describe Ci::Runner, models: true do
end end
context 'does not give owned runner' do context 'does not give owned runner' do
subject { Ci::Runner.available_for(project) } subject { Ci::Runner.assignable_for(project) }
it { is_expected.to be_empty } it { is_expected.to be_empty }
end end
context 'does not give a locked runner' do context 'does not give a locked runner' do
subject { Ci::Runner.available_for(another_project) } subject { Ci::Runner.assignable_for(another_project) }
it { is_expected.to be_empty } it { is_expected.to be_empty }
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