Commit beabf5db authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #8091 from cirosantilli/factor-ability-abilities

Factor abilities methods
parents 26175e44 b66a1527
...@@ -5,7 +5,6 @@ class ApplicationController < ActionController::Base ...@@ -5,7 +5,6 @@ class ApplicationController < ActionController::Base
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :reject_blocked! before_filter :reject_blocked!
before_filter :check_password_expiration before_filter :check_password_expiration
before_filter :add_abilities
before_filter :ldap_security_check before_filter :ldap_security_check
before_filter :default_headers before_filter :default_headers
before_filter :add_gon_variables before_filter :add_gon_variables
...@@ -72,7 +71,7 @@ class ApplicationController < ActionController::Base ...@@ -72,7 +71,7 @@ class ApplicationController < ActionController::Base
end end
def abilities def abilities
@abilities ||= Six.new Ability.abilities
end end
def can?(object, action, subject) def can?(object, action, subject)
...@@ -113,10 +112,6 @@ class ApplicationController < ActionController::Base ...@@ -113,10 +112,6 @@ class ApplicationController < ActionController::Base
nil nil
end end
def add_abilities
abilities << Ability
end
def authorize_project!(action) def authorize_project!(action)
return access_denied! unless can?(current_user, action, project) return access_denied! unless can?(current_user, action, project)
end end
......
class Explore::GroupsController < ApplicationController class Explore::GroupsController < ApplicationController
skip_before_filter :authenticate_user!, skip_before_filter :authenticate_user!,
:reject_blocked, :set_current_user_for_observers, :reject_blocked, :set_current_user_for_observers
:add_abilities
layout "explore" layout "explore"
......
class Explore::ProjectsController < ApplicationController class Explore::ProjectsController < ApplicationController
skip_before_filter :authenticate_user!, skip_before_filter :authenticate_user!,
:reject_blocked, :reject_blocked
:add_abilities
layout 'explore' layout 'explore'
......
...@@ -262,5 +262,13 @@ class Ability ...@@ -262,5 +262,13 @@ class Ability
end end
rules rules
end end
def abilities
@abilities ||= begin
abilities = Six.new
abilities << self
abilities
end
end
end end
end end
...@@ -330,11 +330,7 @@ class User < ActiveRecord::Base ...@@ -330,11 +330,7 @@ class User < ActiveRecord::Base
end end
def abilities def abilities
@abilities ||= begin Ability.abilities
abilities = Six.new
abilities << Ability
abilities
end
end end
def can_select_namespace? def can_select_namespace?
......
...@@ -6,11 +6,7 @@ class BaseService ...@@ -6,11 +6,7 @@ class BaseService
end end
def abilities def abilities
@abilities ||= begin Ability.abilities
abilities = Six.new
abilities << Ability
abilities
end
end end
def can?(object, action, subject) def can?(object, action, subject)
......
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