Patch #12078

User#allowed_to? should return true or false

Added by Anonymous about 5 years ago. Updated about 5 years ago.

Status:ClosedStart date:
Priority:LowDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Code cleanup/refactoring
Target version:2.2.0

Description

The attached patch fixes a minor bug in User.allowed_to?

Specifically, that method should return a boolean, but it actually sometimes returns a Role instead. This is because .detect is used when really .any? should be used.

I am not aware of this causing any serious issues, but I noticed this during debugging and was greatly confused when allowed_to? suddenly returned a Role ;).

0001-Replace-incorrect-.detect-call-by-.any.patch Magnifier - Patch changing .detect to .any? (1.13 KB) Anonymous, 2012-10-11 16:31

Associated revisions

Revision 10614
Added by Jean-Philippe Lang about 5 years ago

Fixed that User#allowed_to? should return true or false (#12078).

History

#1 Updated by Etienne Massip about 5 years ago

  • Category set to Code cleanup/refactoring

#2 Updated by Jean-Philippe Lang about 5 years ago

  • Subject changed from Replace incorrect uses of .detect by .any? to User#allowed_to? should return true or false
  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Target version set to 2.2.0

Committed in r10614. Another change was required so that User#allowed_to? return true or false and tests were updated.

Also available in: Atom PDF