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)
|
||||
end
|
||||
|
||||
it 'sets assignable project runners' do
|
||||
group = create(:group, runners: [create(:ci_runner)], parent: create(:group))
|
||||
group.add_master(user)
|
||||
project_runner = create(:ci_runner, projects: [create(:project, group: group)])
|
||||
create(:ci_runner, :shared)
|
||||
context 'with group runners' do
|
||||
let(:group_runner) { create(:ci_runner) }
|
||||
let(:parent_group) { create(:group) }
|
||||
let(:group) { create(:group, runners: [group_runner], parent: parent_group) }
|
||||
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
|
||||
|
||||
|
|
|
@ -61,10 +61,10 @@ describe "Admin Runners" do
|
|||
end
|
||||
|
||||
context 'group runner' do
|
||||
it 'shows the label and does not show the project count' do
|
||||
group = create :group
|
||||
runner = create :ci_runner, groups: [group]
|
||||
let(:group) { create(:group) }
|
||||
let!(:runner) { create(:ci_runner, groups: [group], runner_type: :group_type) }
|
||||
|
||||
it 'shows the label and does not show the project count' do
|
||||
visit admin_runners_path
|
||||
|
||||
within "#runner_#{runner.id}" do
|
||||
|
|
|
@ -21,8 +21,9 @@ describe Ci::Runner do
|
|||
end
|
||||
|
||||
context 'either_projects_or_group' do
|
||||
let(:group) { create(:group) }
|
||||
|
||||
it 'disallows assigning to a group if already assigned to a group' do
|
||||
group = create(:group)
|
||||
runner = create(:ci_runner, groups: [group])
|
||||
|
||||
runner.groups << build(:group)
|
||||
|
@ -42,7 +43,6 @@ describe Ci::Runner do
|
|||
end
|
||||
|
||||
it 'disallows assigning to a project if already assigned to a group' do
|
||||
group = create(:group)
|
||||
runner = create(:ci_runner, groups: [group])
|
||||
|
||||
runner.projects << build(:project)
|
||||
|
@ -189,9 +189,9 @@ describe Ci::Runner do
|
|||
# globally 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
|
||||
]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue