Commit 69b20cf2 authored by Pedro Pombeiro's avatar Pedro Pombeiro

Move sorting and filtering tests to inner context

parent 5f3291f8
......@@ -184,12 +184,13 @@ RSpec.describe Ci::RunnersFinder do
describe '#execute' do
subject { described_class.new(current_user: user, group: group, params: params).execute }
context 'no params' do
context 'with user as group owner' do
before do
group.add_owner(user)
end
it 'returns all runners' do
context 'passing no params' do
it 'returns all descendant runners' do
expect(subject).to eq([runner_project_7, runner_project_6, runner_project_5,
runner_project_4, runner_project_3, runner_project_2,
runner_project_1, runner_sub_group_4, runner_sub_group_3,
......@@ -200,10 +201,6 @@ RSpec.describe Ci::RunnersFinder do
context 'with sort param' do
let(:params) { { sort: 'contacted_asc' } }
before do
group.add_owner(user)
end
it 'sorts by specified attribute' do
expect(subject).to eq([runner_group, runner_sub_group_1, runner_sub_group_2,
runner_sub_group_3, runner_sub_group_4, runner_project_1,
......@@ -216,10 +213,6 @@ RSpec.describe Ci::RunnersFinder do
context 'by search term' do
let(:params) { { search: 'runner_project_search' } }
before do
group.add_owner(user)
end
it 'returns correct runner' do
expect(subject).to eq([runner_project_3])
end
......@@ -228,10 +221,6 @@ RSpec.describe Ci::RunnersFinder do
context 'by status' do
let(:params) { { status_status: 'paused' } }
before do
group.add_owner(user)
end
it 'returns correct runner' do
expect(subject).to eq([runner_sub_group_1])
end
......@@ -240,10 +229,6 @@ RSpec.describe Ci::RunnersFinder do
context 'by tag_name' do
let(:params) { { tag_name: %w[runner_tag] } }
before do
group.add_owner(user)
end
it 'returns correct runner' do
expect(subject).to eq([runner_project_5])
end
......@@ -252,10 +237,6 @@ RSpec.describe Ci::RunnersFinder do
context 'by runner type' do
let(:params) { { type_type: 'project_type' } }
before do
group.add_owner(user)
end
it 'returns correct runners' do
expect(subject).to eq([runner_project_7, runner_project_6,
runner_project_5, runner_project_4,
......@@ -263,6 +244,7 @@ RSpec.describe Ci::RunnersFinder do
end
end
end
end
context 'when user is not group owner' do
where(:user_permission) do
......
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