BigW Consortium Gitlab

Commit bbd4cd11 by Dylan Griffith

Fix spec for User#ci_owned_runners

parent ec614728
...@@ -1858,12 +1858,10 @@ describe User do ...@@ -1858,12 +1858,10 @@ describe User do
describe '#ci_owned_runners' do describe '#ci_owned_runners' do
let(:user) { create(:user) } let(:user) { create(:user) }
let!(:project) { create(:project) }
let(:runner) { create(:ci_runner, :project, projects: [project]) } let(:runner) { create(:ci_runner, :project, projects: [project]) }
context 'without any projects nor groups' do context 'without any projects nor groups' do
let!(:project) { create(:project, runners: [runner_1]) }
let!(:group) { create(:group) }
it 'does not load' do it 'does not load' do
expect(user.ci_owned_runners).to be_empty expect(user.ci_owned_runners).to be_empty
end end
...@@ -1871,38 +1869,40 @@ describe User do ...@@ -1871,38 +1869,40 @@ describe User do
context 'with personal projects runners' do context 'with personal projects runners' do
let(:namespace) { create(:namespace, owner: user) } let(:namespace) { create(:namespace, owner: user) }
let!(:project) { create(:project, namespace: namespace, runners: [runner_1]) } let!(:project) { create(:project, namespace: namespace) }
it 'loads' do it 'loads' do
expect(user.ci_owned_runners).to contain_exactly(runner_1) expect(user.ci_owned_runners).to contain_exactly(runner)
end end
end end
context 'with personal group runner' do context 'with personal group runner' do
let!(:project) { create(:project, runners: [runner_1]) } let!(:project) { create(:project) }
let(:group_runner) { create(:ci_runner, :group, groups: [group]) }
let!(:group) do let!(:group) do
create(:group, runners: [runner_2]).tap do |group| create(:group).tap do |group|
group.add_owner(user) group.add_owner(user)
end end
end end
it 'loads' do it 'loads' do
expect(user.ci_owned_runners).to contain_exactly(runner_2) expect(user.ci_owned_runners).to contain_exactly(group_runner)
end end
end end
context 'with personal project and group runner' do context 'with personal project and group runner' do
let(:namespace) { create(:namespace, owner: user) } let(:namespace) { create(:namespace, owner: user) }
let!(:project) { create(:project, namespace: namespace, runners: [runner_1]) } let!(:project) { create(:project, namespace: namespace) }
let!(:group_runner) { create(:ci_runner, :group, groups: [group]) }
let!(:group) do let!(:group) do
create(:group, runners: [runner_2]).tap do |group| create(:group).tap do |group|
group.add_owner(user) group.add_owner(user)
end end
end end
it 'loads' do it 'loads' do
expect(user.ci_owned_runners).to contain_exactly(runner_1, runner_2) expect(user.ci_owned_runners).to contain_exactly(runner, group_runner)
end end
end end
...@@ -1913,7 +1913,7 @@ describe User do ...@@ -1913,7 +1913,7 @@ describe User do
end end
it 'loads' do it 'loads' do
expect(user.ci_owned_runners).to contain_exactly(runner_1) expect(user.ci_owned_runners).to contain_exactly(runner)
end end
end end
...@@ -1930,7 +1930,7 @@ describe User do ...@@ -1930,7 +1930,7 @@ describe User do
context 'with groups projects runners' do context 'with groups projects runners' do
let(:group) { create(:group) } let(:group) { create(:group) }
let!(:project) { create(:project, group: group, runners: [runner_1]) } let!(:project) { create(:project, group: group) }
def add_user(access) def add_user(access)
group.add_user(user, access) group.add_user(user, access)
...@@ -1940,11 +1940,8 @@ describe User do ...@@ -1940,11 +1940,8 @@ describe User do
end end
context 'with groups runners' do context 'with groups runners' do
let!(:group) do let!(:runner) { create(:ci_runner, :group, groups: [group]) }
create(:group, runners: [runner_1]).tap do |group| let!(:group) { create(:group) }
group.add_owner(user)
end
end
def add_user(access) def add_user(access)
group.add_user(user, access) group.add_user(user, access)
...@@ -1954,7 +1951,7 @@ describe User do ...@@ -1954,7 +1951,7 @@ describe User do
end end
context 'with other projects runners' do context 'with other projects runners' do
let!(:project) { create(:project, runners: [runner_1]) } let!(:project) { create(:project) }
def add_user(access) def add_user(access)
project.add_role(user, access) project.add_role(user, access)
...@@ -1967,7 +1964,7 @@ describe User do ...@@ -1967,7 +1964,7 @@ describe User do
let(:group) { create(:group) } let(:group) { create(:group) }
let(:another_user) { create(:user) } let(:another_user) { create(:user) }
let(:subgroup) { create(:group, parent: group) } let(:subgroup) { create(:group, parent: group) }
let!(:project) { create(:project, group: subgroup, runners: [runner_1]) } let!(:project) { create(:project, group: subgroup) }
def add_user(access) def add_user(access)
group.add_user(user, access) group.add_user(user, access)
......
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