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
Kazuhiko Shiozaki
gitlab-ce
Commits
beabf5db
Commit
beabf5db
authored
Oct 28, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8091 from cirosantilli/factor-ability-abilities
Factor abilities methods
parents
26175e44
b66a1527
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
20 deletions
+13
-20
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+1
-6
app/controllers/explore/groups_controller.rb
app/controllers/explore/groups_controller.rb
+1
-2
app/controllers/explore/projects_controller.rb
app/controllers/explore/projects_controller.rb
+1
-2
app/models/ability.rb
app/models/ability.rb
+8
-0
app/models/user.rb
app/models/user.rb
+1
-5
app/services/base_service.rb
app/services/base_service.rb
+1
-5
No files found.
app/controllers/application_controller.rb
View file @
beabf5db
...
...
@@ -5,7 +5,6 @@ class ApplicationController < ActionController::Base
before_filter
:authenticate_user!
before_filter
:reject_blocked!
before_filter
:check_password_expiration
before_filter
:add_abilities
before_filter
:ldap_security_check
before_filter
:default_headers
before_filter
:add_gon_variables
...
...
@@ -72,7 +71,7 @@ class ApplicationController < ActionController::Base
end
def
abilities
@abilities
||=
Six
.
new
Ability
.
abilities
end
def
can?
(
object
,
action
,
subject
)
...
...
@@ -113,10 +112,6 @@ class ApplicationController < ActionController::Base
nil
end
def
add_abilities
abilities
<<
Ability
end
def
authorize_project!
(
action
)
return
access_denied!
unless
can?
(
current_user
,
action
,
project
)
end
...
...
app/controllers/explore/groups_controller.rb
View file @
beabf5db
class
Explore::GroupsController
<
ApplicationController
skip_before_filter
:authenticate_user!
,
:reject_blocked
,
:set_current_user_for_observers
,
:add_abilities
:reject_blocked
,
:set_current_user_for_observers
layout
"explore"
...
...
app/controllers/explore/projects_controller.rb
View file @
beabf5db
class
Explore::ProjectsController
<
ApplicationController
skip_before_filter
:authenticate_user!
,
:reject_blocked
,
:add_abilities
:reject_blocked
layout
'explore'
...
...
app/models/ability.rb
View file @
beabf5db
...
...
@@ -262,5 +262,13 @@ class Ability
end
rules
end
def
abilities
@abilities
||=
begin
abilities
=
Six
.
new
abilities
<<
self
abilities
end
end
end
end
app/models/user.rb
View file @
beabf5db
...
...
@@ -330,11 +330,7 @@ class User < ActiveRecord::Base
end
def
abilities
@abilities
||=
begin
abilities
=
Six
.
new
abilities
<<
Ability
abilities
end
Ability
.
abilities
end
def
can_select_namespace?
...
...
app/services/base_service.rb
View file @
beabf5db
...
...
@@ -6,11 +6,7 @@ class BaseService
end
def
abilities
@abilities
||=
begin
abilities
=
Six
.
new
abilities
<<
Ability
abilities
end
Ability
.
abilities
end
def
can?
(
object
,
action
,
subject
)
...
...
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