Fix spec/features/admin/admin_runners_spec.rb + test style improvements
This commit is contained in:
parent
b7b8232466
commit
0e5c1a89f0
3 changed files with 20 additions and 14 deletions
|
@ -18,15 +18,21 @@ describe Projects::Settings::CiCdController do
|
||||||
expect(response).to render_template(:show)
|
expect(response).to render_template(:show)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets assignable project runners' do
|
context 'with group runners' do
|
||||||
group = create(:group, runners: [create(:ci_runner)], parent: create(:group))
|
let(:group_runner) { create(:ci_runner) }
|
||||||
group.add_master(user)
|
let(:parent_group) { create(:group) }
|
||||||
project_runner = create(:ci_runner, projects: [create(:project, group: group)])
|
let(:group) { create(:group, runners: [group_runner], parent: parent_group) }
|
||||||
create(:ci_runner, :shared)
|
let(:other_project) { create(:project, group: group) }
|
||||||
|
let!(:project_runner) { create(:ci_runner, projects: [other_project]) }
|
||||||
|
let!(:shared_runner) { create(:ci_runner, :shared) }
|
||||||
|
|
||||||
get :show, namespace_id: project.namespace, project_id: project
|
it 'sets assignable project runners only' do
|
||||||
|
group.add_master(user)
|
||||||
|
|
||||||
expect(assigns(:assignable_runners)).to eq [project_runner]
|
get :show, namespace_id: project.namespace, project_id: project
|
||||||
|
|
||||||
|
expect(assigns(:assignable_runners)).to eq [project_runner]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -61,10 +61,10 @@ describe "Admin Runners" do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'group runner' do
|
context 'group runner' do
|
||||||
it 'shows the label and does not show the project count' do
|
let(:group) { create(:group) }
|
||||||
group = create :group
|
let!(:runner) { create(:ci_runner, groups: [group], runner_type: :group_type) }
|
||||||
runner = create :ci_runner, groups: [group]
|
|
||||||
|
|
||||||
|
it 'shows the label and does not show the project count' do
|
||||||
visit admin_runners_path
|
visit admin_runners_path
|
||||||
|
|
||||||
within "#runner_#{runner.id}" do
|
within "#runner_#{runner.id}" do
|
||||||
|
|
|
@ -21,8 +21,9 @@ describe Ci::Runner do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'either_projects_or_group' do
|
context 'either_projects_or_group' do
|
||||||
|
let(:group) { create(:group) }
|
||||||
|
|
||||||
it 'disallows assigning to a group if already assigned to a group' do
|
it 'disallows assigning to a group if already assigned to a group' do
|
||||||
group = create(:group)
|
|
||||||
runner = create(:ci_runner, groups: [group])
|
runner = create(:ci_runner, groups: [group])
|
||||||
|
|
||||||
runner.groups << build(:group)
|
runner.groups << build(:group)
|
||||||
|
@ -42,7 +43,6 @@ describe Ci::Runner do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'disallows assigning to a project if already assigned to a group' do
|
it 'disallows assigning to a project if already assigned to a group' do
|
||||||
group = create(:group)
|
|
||||||
runner = create(:ci_runner, groups: [group])
|
runner = create(:ci_runner, groups: [group])
|
||||||
|
|
||||||
runner.projects << build(:project)
|
runner.projects << build(:project)
|
||||||
|
@ -189,9 +189,9 @@ describe Ci::Runner do
|
||||||
# globally shared
|
# globally shared
|
||||||
shared_runner = create :ci_runner, :shared
|
shared_runner = create :ci_runner, :shared
|
||||||
|
|
||||||
expect(described_class.owned_or_shared(project.id)).to match_array [
|
expect(described_class.owned_or_shared(project.id)).to contain_exactly(
|
||||||
group_runner, project_runner, shared_runner
|
group_runner, project_runner, shared_runner
|
||||||
]
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue