Commit 5f3291f8 authored by Pedro Pombeiro's avatar Pedro Pombeiro

Fix naming of RunnersFinder specs

parent a014c2b5
...@@ -33,7 +33,8 @@ RSpec.describe Ci::RunnersFinder do ...@@ -33,7 +33,8 @@ RSpec.describe Ci::RunnersFinder do
end end
end end
context 'filter by search term' do context 'filtering' do
context 'by search term' do
it 'calls Ci::Runner.search' do it 'calls Ci::Runner.search' do
expect(Ci::Runner).to receive(:search).with('term').and_call_original expect(Ci::Runner).to receive(:search).with('term').and_call_original
...@@ -41,7 +42,7 @@ RSpec.describe Ci::RunnersFinder do ...@@ -41,7 +42,7 @@ RSpec.describe Ci::RunnersFinder do
end end
end end
context 'filter by status' do context 'by status' do
Ci::Runner::AVAILABLE_STATUSES.each do |status| Ci::Runner::AVAILABLE_STATUSES.each do |status|
it "calls the corresponding :#{status} scope on Ci::Runner" do it "calls the corresponding :#{status} scope on Ci::Runner" do
expect(Ci::Runner).to receive(status.to_sym).and_call_original expect(Ci::Runner).to receive(status.to_sym).and_call_original
...@@ -51,7 +52,7 @@ RSpec.describe Ci::RunnersFinder do ...@@ -51,7 +52,7 @@ RSpec.describe Ci::RunnersFinder do
end end
end end
context 'filter by runner type' do context 'by runner type' do
it 'calls the corresponding scope on Ci::Runner' do it 'calls the corresponding scope on Ci::Runner' do
expect(Ci::Runner).to receive(:project_type).and_call_original expect(Ci::Runner).to receive(:project_type).and_call_original
...@@ -59,15 +60,16 @@ RSpec.describe Ci::RunnersFinder do ...@@ -59,15 +60,16 @@ RSpec.describe Ci::RunnersFinder do
end end
end end
context 'filter by tag_name' do context 'by tag_name' do
it 'calls the corresponding scope on Ci::Runner' do it 'calls the corresponding scope on Ci::Runner' do
expect(Ci::Runner).to receive(:tagged_with).with(%w[tag1 tag2]).and_call_original expect(Ci::Runner).to receive(:tagged_with).with(%w[tag1 tag2]).and_call_original
described_class.new(current_user: admin, params: { tag_name: %w[tag1 tag2] }).execute described_class.new(current_user: admin, params: { tag_name: %w[tag1 tag2] }).execute
end end
end end
end
context 'sort' do context 'sorting' do
let_it_be(:runner1) { create :ci_runner, created_at: '2018-07-12 07:00', contacted_at: 1.minute.ago } let_it_be(:runner1) { create :ci_runner, created_at: '2018-07-12 07:00', contacted_at: 1.minute.ago }
let_it_be(:runner2) { create :ci_runner, created_at: '2018-07-12 08:00', contacted_at: 3.minutes.ago } let_it_be(:runner2) { create :ci_runner, created_at: '2018-07-12 08:00', contacted_at: 3.minutes.ago }
let_it_be(:runner3) { create :ci_runner, created_at: '2018-07-12 09:00', contacted_at: 2.minutes.ago } let_it_be(:runner3) { create :ci_runner, created_at: '2018-07-12 09:00', contacted_at: 2.minutes.ago }
...@@ -121,7 +123,7 @@ RSpec.describe Ci::RunnersFinder do ...@@ -121,7 +123,7 @@ RSpec.describe Ci::RunnersFinder do
end end
end end
context 'non admin user' do context 'by non admin user' do
it 'returns no runners' do it 'returns no runners' do
user = create :user user = create :user
create :ci_runner, active: true create :ci_runner, active: true
...@@ -131,7 +133,7 @@ RSpec.describe Ci::RunnersFinder do ...@@ -131,7 +133,7 @@ RSpec.describe Ci::RunnersFinder do
end end
end end
context 'user is nil' do context 'when user is nil' do
it 'returns no runners' do it 'returns no runners' do
user = nil user = nil
create :ci_runner, active: true create :ci_runner, active: true
...@@ -210,7 +212,8 @@ RSpec.describe Ci::RunnersFinder do ...@@ -210,7 +212,8 @@ RSpec.describe Ci::RunnersFinder do
end end
end end
context 'filter by search term' do context 'filtering' do
context 'by search term' do
let(:params) { { search: 'runner_project_search' } } let(:params) { { search: 'runner_project_search' } }
before do before do
...@@ -222,7 +225,7 @@ RSpec.describe Ci::RunnersFinder do ...@@ -222,7 +225,7 @@ RSpec.describe Ci::RunnersFinder do
end end
end end
context 'filter by status' do context 'by status' do
let(:params) { { status_status: 'paused' } } let(:params) { { status_status: 'paused' } }
before do before do
...@@ -234,7 +237,7 @@ RSpec.describe Ci::RunnersFinder do ...@@ -234,7 +237,7 @@ RSpec.describe Ci::RunnersFinder do
end end
end end
context 'filter by tag_name' do context 'by tag_name' do
let(:params) { { tag_name: %w[runner_tag] } } let(:params) { { tag_name: %w[runner_tag] } }
before do before do
...@@ -246,7 +249,7 @@ RSpec.describe Ci::RunnersFinder do ...@@ -246,7 +249,7 @@ RSpec.describe Ci::RunnersFinder do
end end
end end
context 'filter by runner type' do context 'by runner type' do
let(:params) { { type_type: 'project_type' } } let(:params) { { type_type: 'project_type' } }
before do before do
...@@ -259,8 +262,9 @@ RSpec.describe Ci::RunnersFinder do ...@@ -259,8 +262,9 @@ RSpec.describe Ci::RunnersFinder do
runner_project_3, runner_project_2, runner_project_1]) runner_project_3, runner_project_2, runner_project_1])
end end
end end
end
context 'user has no access to runners' do context 'when user is not group owner' do
where(:user_permission) do where(:user_permission) do
[:maintainer, :developer, :reporter, :guest] [:maintainer, :developer, :reporter, :guest]
end end
...@@ -276,13 +280,13 @@ RSpec.describe Ci::RunnersFinder do ...@@ -276,13 +280,13 @@ RSpec.describe Ci::RunnersFinder do
end end
end end
context 'user with no access' do context 'when user has no access' do
it 'returns no runners' do it 'returns no runners' do
expect(subject).to be_empty expect(subject).to be_empty
end end
end end
context 'user is nil' do context 'when user is nil' do
let_it_be(:user) { nil } let_it_be(:user) { nil }
it 'returns no runners' do it 'returns no runners' do
...@@ -294,7 +298,7 @@ RSpec.describe Ci::RunnersFinder do ...@@ -294,7 +298,7 @@ RSpec.describe Ci::RunnersFinder do
describe '#sort_key' do describe '#sort_key' do
subject { described_class.new(current_user: user, group: group, params: params).sort_key } subject { described_class.new(current_user: user, group: group, params: params).sort_key }
context 'no params' do context 'without params' do
it 'returns created_at_desc' do it 'returns created_at_desc' do
expect(subject).to eq('created_at_desc') expect(subject).to eq('created_at_desc')
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