Commit 0e5c1a89 authored by Dylan Griffith's avatar Dylan Griffith

Fix spec/features/admin/admin_runners_spec.rb + test style improvements

parent b7b82324
......@@ -18,17 +18,23 @@ 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))
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) }
it 'sets assignable project runners only' do
group.add_master(user)
project_runner = create(:ci_runner, projects: [create(:project, group: group)])
create(:ci_runner, :shared)
get :show, namespace_id: project.namespace, project_id: project
expect(assigns(:assignable_runners)).to eq [project_runner]
end
end
end
describe '#reset_cache' do
before do
......
......@@ -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
......
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