Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
e98438d4
Commit
e98438d4
authored
Apr 30, 2018
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert changes to User#ci_authorized_users to defer group runner API changes to later
parent
0d30b00d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
67 deletions
+15
-67
app/models/user.rb
app/models/user.rb
+2
-14
spec/models/user_spec.rb
spec/models/user_spec.rb
+13
-53
No files found.
app/models/user.rb
View file @
e98438d4
...
...
@@ -995,17 +995,10 @@ class User < ActiveRecord::Base
def
ci_authorized_runners
@ci_authorized_runners
||=
begin
project_
runner_ids
=
Ci
::
RunnerProject
runner_ids
=
Ci
::
RunnerProject
.
where
(
project:
authorized_projects
(
Gitlab
::
Access
::
MASTER
))
.
select
(
:runner_id
)
group_runner_ids
=
Ci
::
RunnerGroup
.
where
(
group_id:
owned_or_masters_groups
.
select
(
:id
))
.
select
(
:runner_id
)
union
=
Gitlab
::
SQL
::
Union
.
new
([
project_runner_ids
,
group_runner_ids
])
Ci
::
Runner
.
specific
.
where
(
"ci_runners.id IN (
#{
union
.
to_sql
}
)"
)
# rubocop:disable GitlabSecurity/SqlInjection
Ci
::
Runner
.
specific
.
where
(
id:
runner_ids
)
end
end
...
...
@@ -1194,11 +1187,6 @@ class User < ActiveRecord::Base
max_member_access_for_group_ids
([
group_id
])[
group_id
]
end
def
owned_or_masters_groups
union
=
Gitlab
::
SQL
::
Union
.
new
([
owned_groups
,
masters_groups
])
Group
.
from
(
"(
#{
union
.
to_sql
}
) namespaces"
)
end
protected
# override, from Devise::Validatable
...
...
spec/models/user_spec.rb
View file @
e98438d4
...
...
@@ -1787,12 +1787,14 @@ describe User do
describe
'#ci_authorized_runners'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:runner_1
)
{
create
(
:ci_runner
)
}
let
(
:runner_2
)
{
create
(
:ci_runner
)
}
let
(
:runner
)
{
create
(
:ci_runner
)
}
context
'without any projects nor groups'
do
let!
(
:project
)
{
create
(
:project
,
runners:
[
runner_1
])
}
let!
(
:group
)
{
create
(
:group
)
}
before
do
project
.
runners
<<
runner
end
context
'without any projects'
do
let
(
:project
)
{
create
(
:project
)
}
it
'does not load'
do
expect
(
user
.
ci_authorized_runners
).
to
be_empty
...
...
@@ -1801,38 +1803,10 @@ describe User do
context
'with personal projects runners'
do
let
(
:namespace
)
{
create
(
:namespace
,
owner:
user
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
namespace
,
runners:
[
runner_1
])
}
it
'loads'
do
expect
(
user
.
ci_authorized_runners
).
to
contain_exactly
(
runner_1
)
end
end
context
'with personal group runner'
do
let!
(
:project
)
{
create
(
:project
,
runners:
[
runner_1
])
}
let!
(
:group
)
do
create
(
:group
,
runners:
[
runner_2
]).
tap
do
|
group
|
group
.
add_owner
(
user
)
end
end
it
'loads'
do
expect
(
user
.
ci_authorized_runners
).
to
contain_exactly
(
runner_2
)
end
end
context
'with personal project and group runner'
do
let
(
:namespace
)
{
create
(
:namespace
,
owner:
user
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
namespace
,
runners:
[
runner_1
])
}
let!
(
:group
)
do
create
(
:group
,
runners:
[
runner_2
]).
tap
do
|
group
|
group
.
add_owner
(
user
)
end
end
let
(
:project
)
{
create
(
:project
,
namespace:
namespace
)
}
it
'loads'
do
expect
(
user
.
ci_authorized_runners
).
to
contain_exactly
(
runner
_1
,
runner_2
)
expect
(
user
.
ci_authorized_runners
).
to
contain_exactly
(
runner
)
end
end
...
...
@@ -1843,7 +1817,7 @@ describe User do
end
it
'loads'
do
expect
(
user
.
ci_authorized_runners
).
to
contain_exactly
(
runner
_1
)
expect
(
user
.
ci_authorized_runners
).
to
contain_exactly
(
runner
)
end
end
...
...
@@ -1860,21 +1834,7 @@ describe User do
context
'with groups projects runners'
do
let
(
:group
)
{
create
(
:group
)
}
let!
(
:project
)
{
create
(
:project
,
group:
group
,
runners:
[
runner_1
])
}
def
add_user
(
access
)
group
.
add_user
(
user
,
access
)
end
it_behaves_like
:member
end
context
'with groups runners'
do
let!
(
:group
)
do
create
(
:group
,
runners:
[
runner_1
]).
tap
do
|
group
|
group
.
add_owner
(
user
)
end
end
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
def
add_user
(
access
)
group
.
add_user
(
user
,
access
)
...
...
@@ -1884,7 +1844,7 @@ describe User do
end
context
'with other projects runners'
do
let
!
(
:project
)
{
create
(
:project
,
runners:
[
runner_1
]
)
}
let
(
:project
)
{
create
(
:project
)
}
def
add_user
(
access
)
project
.
add_role
(
user
,
access
)
...
...
@@ -1897,7 +1857,7 @@ describe User do
let
(
:group
)
{
create
(
:group
)
}
let
(
:another_user
)
{
create
(
:user
)
}
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
)
group
.
add_user
(
user
,
access
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment