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

Fix naming of RunnersFinder specs

parent a014c2b5
...@@ -33,41 +33,43 @@ RSpec.describe Ci::RunnersFinder do ...@@ -33,41 +33,43 @@ RSpec.describe Ci::RunnersFinder do
end end
end end
context 'filter by search term' do context 'filtering' do
it 'calls Ci::Runner.search' do context 'by search term' do
expect(Ci::Runner).to receive(:search).with('term').and_call_original it 'calls Ci::Runner.search' do
expect(Ci::Runner).to receive(:search).with('term').and_call_original
described_class.new(current_user: admin, params: { search: 'term' }).execute described_class.new(current_user: admin, params: { search: 'term' }).execute
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
described_class.new(current_user: admin, params: { status_status: status }).execute described_class.new(current_user: admin, params: { status_status: status }).execute
end
end 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
described_class.new(current_user: admin, params: { type_type: 'project_type' }).execute described_class.new(current_user: admin, params: { type_type: 'project_type' }).execute
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,57 +212,59 @@ RSpec.describe Ci::RunnersFinder do ...@@ -210,57 +212,59 @@ RSpec.describe Ci::RunnersFinder do
end end
end end
context 'filter by search term' do context 'filtering' do
let(:params) { { search: 'runner_project_search' } } context 'by search term' do
let(:params) { { search: 'runner_project_search' } }
before do before do
group.add_owner(user) group.add_owner(user)
end end
it 'returns correct runner' do it 'returns correct runner' do
expect(subject).to eq([runner_project_3]) expect(subject).to eq([runner_project_3])
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
group.add_owner(user) group.add_owner(user)
end end
it 'returns correct runner' do it 'returns correct runner' do
expect(subject).to eq([runner_sub_group_1]) expect(subject).to eq([runner_sub_group_1])
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
group.add_owner(user) group.add_owner(user)
end end
it 'returns correct runner' do it 'returns correct runner' do
expect(subject).to eq([runner_project_5]) expect(subject).to eq([runner_project_5])
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
group.add_owner(user) group.add_owner(user)
end end
it 'returns correct runners' do it 'returns correct runners' do
expect(subject).to eq([runner_project_7, runner_project_6, expect(subject).to eq([runner_project_7, runner_project_6,
runner_project_5, runner_project_4, runner_project_5, runner_project_4,
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