From cbd6ca6985c1a7eefcfa5b3ca170fdf1865aee45 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin <godfat@godfat.org> Date: Tue, 14 Jun 2016 16:07:57 +0800 Subject: [PATCH] Rename specific_for to available_for: Feedback from: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4093#note_12413950 --- app/controllers/projects/runners_controller.rb | 2 +- app/models/ci/runner.rb | 2 +- spec/models/ci/runner_spec.rb | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/projects/runners_controller.rb b/app/controllers/projects/runners_controller.rb index bc4c5bd4575..798d668f251 100644 --- a/app/controllers/projects/runners_controller.rb +++ b/app/controllers/projects/runners_controller.rb @@ -7,7 +7,7 @@ class Projects::RunnersController < Projects::ApplicationController def index @runners = project.runners.ordered @specific_runners = current_user.ci_authorized_runners. - specific_for(project).ordered.page(params[:page]).per(20) + available_for(project).ordered.page(params[:page]).per(20) @shared_runners = Ci::Runner.shared.active @shared_runners_count = @shared_runners.count(:all) end diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index bb1cffdcae6..101817e1f56 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -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) end - scope :specific_for, ->(project) do + scope :available_for, ->(project) do # TODO: That `to_sql` is needed to workaround a weird Rails bug. # Without that, placeholders would miss one and couldn't match. where(locked: false). diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb index 9a6bc6b96c1..51e60ef8ada 100644 --- a/spec/models/ci/runner_spec.rb +++ b/spec/models/ci/runner_spec.rb @@ -259,7 +259,7 @@ describe Ci::Runner, models: true do end end - describe '.specific_for' do + describe '.available_for' do let(:runner) { create(:ci_runner) } let(:project) { create(:project) } let(:another_project) { create(:project) } @@ -274,13 +274,13 @@ describe Ci::Runner, models: true do end context 'should not give owned runner' do - subject { Ci::Runner.specific_for(project) } + subject { Ci::Runner.available_for(project) } it { is_expected.to be_empty } end context 'should not give shared runner' do - subject { Ci::Runner.specific_for(another_project) } + subject { Ci::Runner.available_for(another_project) } it { is_expected.to be_empty } end @@ -288,13 +288,13 @@ describe Ci::Runner, models: true do context 'with unlocked runner' do context 'should not give owned runner' do - subject { Ci::Runner.specific_for(project) } + subject { Ci::Runner.available_for(project) } it { is_expected.to be_empty } end context 'should give a specific runner' do - subject { Ci::Runner.specific_for(another_project) } + subject { Ci::Runner.available_for(another_project) } it { is_expected.to contain_exactly(runner) } end @@ -306,13 +306,13 @@ describe Ci::Runner, models: true do end context 'should not give owned runner' do - subject { Ci::Runner.specific_for(project) } + subject { Ci::Runner.available_for(project) } it { is_expected.to be_empty } end context 'should not give a locked runner' do - subject { Ci::Runner.specific_for(another_project) } + subject { Ci::Runner.available_for(another_project) } it { is_expected.to be_empty } end -- GitLab