Permalink
Browse files

added helper module for tests. fixed bugs on exceptions

  • Loading branch information...
1 parent 53e3702 commit d3d99aa85667d9b6f0f57485a5e44f808fc58dfe @mkristian committed Sep 5, 2011
Showing with 11 additions and 3 deletions.
  1. +11 −3 lib/ixtlan/guard/guard_rails.rb
@@ -13,7 +13,7 @@ module GroupsMethod
protected
def groups_for_current_user
- if current_user
+ if respond_to?(:current_user) && current_user
current_user.groups.collect do |group|
group.name
end
@@ -23,6 +23,14 @@ def groups_for_current_user
end
end
+ module RootGroup
+ protected
+
+ def groups_for_current_user
+ ['root']
+ end
+ end
+
module InstanceMethods #:nodoc:
protected
@@ -38,9 +46,9 @@ def check(flavor = nil, &block)
flavor,
&block)
if flavor
- raise ::Ixtlan::Guard::PermissionDenied.new("permission denied for '#{resource}##{action}##{flavor}'")
+ raise ::Ixtlan::Guard::PermissionDenied.new("permission denied for '#{params[:controller]}##{params[:action]}##{flavor}'")
else
- raise ::Ixtlan::Guard::PermissionDenied.new("permission denied for '#{resource}##{action}'")
+ raise ::Ixtlan::Guard::PermissionDenied.new("permission denied for '#{params[:controller]}##{params[:action]}'")
end
end
true

0 comments on commit d3d99aa

Please sign in to comment.