Commit 1f7f29b7 authored by Dylan Griffith's avatar Dylan Griffith

Style changes to spec/models/ci/runner_spec.rb

parent 80bcb376
...@@ -107,16 +107,17 @@ describe Ci::Runner do ...@@ -107,16 +107,17 @@ describe Ci::Runner do
end end
describe '.shared' do describe '.shared' do
let(:group) { create(:group) }
let(:project) { create(:project) }
it 'returns the shared group runner' do it 'returns the shared group runner' do
group = create :group runner = create(:ci_runner, :shared, groups: [group])
runner = create :ci_runner, :shared, groups: [group]
expect(described_class.shared).to eq [runner] expect(described_class.shared).to eq [runner]
end end
it 'returns the shared project runner' do it 'returns the shared project runner' do
project = create :project runner = create(:ci_runner, :shared, projects: [project])
runner = create :ci_runner, :shared, projects: [project]
expect(described_class.shared).to eq [runner] expect(described_class.shared).to eq [runner]
end end
...@@ -125,12 +126,12 @@ describe Ci::Runner do ...@@ -125,12 +126,12 @@ describe Ci::Runner do
describe '.belonging_to_project' do describe '.belonging_to_project' do
it 'returns the specific project runner' do it 'returns the specific project runner' do
# own # own
specific_project = create :project specific_project = create(:project)
specific_runner = create :ci_runner, :specific, projects: [specific_project] specific_runner = create(:ci_runner, :specific, projects: [specific_project])
# other # other
other_project = create :project other_project = create(:project)
create :ci_runner, :specific, projects: [other_project] create(:ci_runner, :specific, projects: [other_project])
expect(described_class.belonging_to_project(specific_project.id)).to eq [specific_runner] expect(described_class.belonging_to_project(specific_project.id)).to eq [specific_runner]
end end
...@@ -139,55 +140,54 @@ describe Ci::Runner do ...@@ -139,55 +140,54 @@ describe Ci::Runner do
describe '.belonging_to_any_project' do describe '.belonging_to_any_project' do
it 'returns the specific project runner' do it 'returns the specific project runner' do
# project # project
project_project = create :project project_project = create(:project)
project_runner = create :ci_runner, :specific, projects: [project_project] project_runner = create(:ci_runner, :specific, projects: [project_project])
# group # group
group = create :group group = create(:group)
create :project, group: group create(:project, group: group)
create :ci_runner, :specific, groups: [group] create(:ci_runner, :specific, groups: [group])
expect(described_class.belonging_to_any_project).to eq [project_runner] expect(described_class.belonging_to_any_project).to eq [project_runner]
end end
end end
describe '.belonging_to_parent_group_of_project' do describe '.belonging_to_parent_group_of_project' do
it 'returns the specific group runner' do let(:project) { create(:project, group: group) }
# own let(:group) { create(:group) }
specific_group = create :group let(:runner) { create(:ci_runner, :specific, groups: [group]) }
specific_project = create :project, group: specific_group let!(:unrelated_group) { create(:group) }
specific_runner = create :ci_runner, :specific, groups: [specific_group] let!(:unrelated_project) { create(:project, group: unrelated_group) }
let!(:unrelated_runner) { create(:ci_runner, :specific, groups: [unrelated_group]) }
# other
other_group = create :group
create :project, group: other_group
create :ci_runner, :specific, groups: [other_group]
expect(described_class.belonging_to_parent_group_of_project(specific_project.id)).to eq [specific_runner] it 'returns the specific group runner' do
expect(described_class.belonging_to_parent_group_of_project(project.id)).to contain_exactly(runner)
end end
it 'returns the group runner from a parent group', :nested_groups do context 'with a parent group with a runner', :nested_groups do
parent_group = create :group let(:runner) { create(:ci_runner, :specific, groups: [parent_group]) }
group = create :group, parent: parent_group let(:project) { create(:project, group: group) }
project = create :project, group: group let(:group) { create(:group, parent: parent_group) }
runner = create :ci_runner, :specific, groups: [parent_group] let(:parent_group) { create(:group) }
expect(described_class.belonging_to_parent_group_of_project(project.id)).to eq [runner] it 'returns the group runner from the parent group' do
expect(described_class.belonging_to_parent_group_of_project(project.id)).to contain_exactly(runner)
end
end end
end end
describe '.owned_or_shared' do describe '.owned_or_shared' do
it 'returns a globally shared, a project specific and a group specific runner' do it 'returns a globally shared, a project specific and a group specific runner' do
# group specific # group specific
group = create :group group = create(:group)
project = create :project, group: group project = create(:project, group: group)
group_runner = create :ci_runner, :specific, groups: [group] group_runner = create(:ci_runner, :specific, groups: [group])
# project specific # project specific
project_runner = create :ci_runner, :specific, projects: [project] project_runner = create(:ci_runner, :specific, projects: [project])
# 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 contain_exactly( expect(described_class.owned_or_shared(project.id)).to contain_exactly(
group_runner, project_runner, shared_runner group_runner, project_runner, shared_runner
......
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