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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
c1b03791
Commit
c1b03791
authored
Apr 19, 2017
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EE::ProtectedRefAccess used for Protected Tags
parent
d114feb9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
11 deletions
+14
-11
app/models/concerns/protected_branch_access.rb
app/models/concerns/protected_branch_access.rb
+1
-1
app/models/concerns/protected_ref.rb
app/models/concerns/protected_ref.rb
+2
-2
app/models/concerns/protected_tag_access.rb
app/models/concerns/protected_tag_access.rb
+1
-0
app/models/ee/protected_ref_access.rb
app/models/ee/protected_ref_access.rb
+10
-8
No files found.
app/models/concerns/protected_branch_access.rb
View file @
c1b03791
...
...
@@ -3,7 +3,7 @@ module ProtectedBranchAccess
included
do
include
ProtectedRefAccess
include
EE
::
Protected
Branch
Access
include
EE
::
Protected
Ref
Access
belongs_to
:protected_branch
...
...
app/models/concerns/protected_ref.rb
View file @
c1b03791
...
...
@@ -19,8 +19,8 @@ module ProtectedRef
# Returns access levels that grant the specified access type to the given user / group.
access_level_class
=
const_get
(
"
#{
type
}
_access_level"
.
camelize
)
scope
:"
#{
type
}
_access_by_user"
,
->
(
user
)
{
access_level_class
.
joins
(
:protected_branch
).
where
(
protected_branch_id:
self
.
ids
).
merge
(
access_level_class
.
by_user
(
user
))
}
scope
:"
#{
type
}
_access_by_group"
,
->
(
group
)
{
access_level_class
.
joins
(
:protected_branch
).
where
(
protected_branch_id:
self
.
ids
).
merge
(
access_level_class
.
by_group
(
group
))
}
scope
:"
#{
type
}
_access_by_user"
,
->
(
user
)
{
access_level_class
.
joins
(
self
.
model_name
.
singular
).
where
(
"
#{
self
.
model_name
.
singular
}
_id"
=>
self
.
ids
).
merge
(
access_level_class
.
by_user
(
user
))
}
scope
:"
#{
type
}
_access_by_group"
,
->
(
group
)
{
access_level_class
.
joins
(
self
.
model_name
.
singular
).
where
(
"
#{
self
.
model_name
.
singular
}
_id"
=>
self
.
ids
).
merge
(
access_level_class
.
by_group
(
group
))
}
end
end
...
...
app/models/concerns/protected_tag_access.rb
View file @
c1b03791
...
...
@@ -3,6 +3,7 @@ module ProtectedTagAccess
included
do
include
ProtectedRefAccess
include
EE
::
ProtectedRefAccess
belongs_to
:protected_tag
...
...
app/models/ee/protected_
branch
_access.rb
→
app/models/ee/protected_
ref
_access.rb
View file @
c1b03791
# EE-specific code related to protected branch access levels.
# EE-specific code related to protected branch
/tag
access levels.
#
# Note: Don't directly include this concern into a model class.
# Instead, include `ProtectedBranchAccess`
, which in turn includes
# t
his concern. A number of methods here depend on `ProtectedBranchAccess`
# being next up in the ancestor chain.
# Instead, include `ProtectedBranchAccess`
or `ProtectedTagAccess`, which in
# t
urn include this concern. A number of methods here depend on
#
`ProtectedRefAccess`
being next up in the ancestor chain.
module
EE
module
Protected
Branch
Access
module
Protected
Ref
Access
extend
ActiveSupport
::
Concern
included
do
belongs_to
:user
belongs_to
:group
validates
:group_id
,
uniqueness:
{
scope: :protected_branch
,
allow_nil:
true
}
validates
:user_id
,
uniqueness:
{
scope: :protected_branch
,
allow_nil:
true
}
validates
:access_level
,
uniqueness:
{
scope: :protected_branch
,
if: :role?
,
protected_type
=
self
.
parent
.
model_name
.
singular
validates
:group_id
,
uniqueness:
{
scope:
protected_type
,
allow_nil:
true
}
validates
:user_id
,
uniqueness:
{
scope:
protected_type
,
allow_nil:
true
}
validates
:access_level
,
uniqueness:
{
scope:
protected_type
,
if: :role?
,
conditions:
->
{
where
(
user_id:
nil
,
group_id:
nil
)
}
}
scope
:by_user
,
->
(
user
)
{
where
(
user:
user
)
}
...
...
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