From c7a3fd6714519af7e3a56654dc0a403377c9dc8f Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 18 Sep 2012 15:57:44 +0200 Subject: [PATCH 1/1] Replace incorrect uses of .detect by .any? --- app/models/user.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 73c8d6c..c71eaff 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -462,7 +462,7 @@ class User < Principal roles = roles_for_project(context) return false unless roles - roles.detect {|role| + roles.any? {|role| (context.is_public? || role.member?) && role.allowed_to?(action) && (block_given? ? yield(role, self) : true) @@ -481,7 +481,7 @@ class User < Principal # authorize if user has at least one role that has this permission roles = memberships.collect {|m| m.roles}.flatten.uniq roles << (self.logged? ? Role.non_member : Role.anonymous) - roles.detect {|role| + roles.any? {|role| role.allowed_to?(action) && (block_given? ? yield(role, self) : true) } -- 1.7.12.503.g5976753