BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
00970606
Commit
00970606
authored
Dec 13, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract abilities checking module from ability model
parent
24dd70d3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
7 deletions
+36
-7
ability.rb
app/models/ability.rb
+0
-6
allowable.rb
lib/gitlab/allowable.rb
+8
-0
core.rb
lib/gitlab/ci/status/core.rb
+1
-1
allowable_spec.rb
spec/lib/gitlab/allowable_spec.rb
+27
-0
No files found.
app/models/ability.rb
View file @
00970606
class
Ability
module
Allowable
def
can?
(
user
,
action
,
subject
)
Ability
.
allowed?
(
user
,
action
,
subject
)
end
end
class
<<
self
# Given a list of users and a project this method returns the users that can
# read the given project.
...
...
lib/gitlab/allowable.rb
0 → 100644
View file @
00970606
module
Gitlab
module
Allowable
def
can?
(
user
,
action
,
subject
)
Ability
.
allowed?
(
user
,
action
,
subject
)
end
end
end
lib/gitlab/ci/status/core.rb
View file @
00970606
...
...
@@ -5,7 +5,7 @@ module Gitlab
#
class
Core
include
Gitlab
::
Routing
.
url_helpers
include
Ability
::
Allowable
include
Gitlab
::
Allowable
attr_reader
:subject
,
:user
...
...
spec/lib/gitlab/allowable_spec.rb
0 → 100644
View file @
00970606
require
'spec_helper'
describe
Gitlab
::
Allowable
do
subject
do
Class
.
new
.
include
(
described_class
).
new
end
describe
'#can?'
do
let
(
:user
)
{
create
(
:user
)
}
context
'when user is allowed to do something'
do
let
(
:project
)
{
create
(
:empty_project
,
:public
)
}
it
'reports correct ability to perform action'
do
expect
(
subject
.
can?
(
user
,
:read_project
,
project
)).
to
be
true
end
end
context
'when user is not allowed to do something'
do
let
(
:project
)
{
create
(
:empty_project
,
:private
)
}
it
'reports correct ability to perform action'
do
expect
(
subject
.
can?
(
user
,
:read_project
,
project
)).
to
be
false
end
end
end
end
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