refactor guardian class for clarity & correctness

introduce NullUser to avoid type-checking
DRY up code
reduce number of multiple returns
remove some redundant/impossible logic branches
add pending test for possible bug
add test & fix for ability to flag archived posts
add #secure_category? method to topic class
Fix bug that prevented flagging of archived topics
Rename NullUser to AnonymousUser
DRY up can_<action>? methods
Fix some ownership logic, and a test, for Guardian
This commit is contained in:
Matt Van Horn
2013-05-19 23:04:53 -07:00
parent 6e95ef8196
commit 872995db57
4 changed files with 160 additions and 172 deletions

View File

@@ -745,4 +745,7 @@ class Topic < ActiveRecord::Base
self.auto_close_at = (num_days and num_days.to_i > 0.0 ? num_days.to_i.days.from_now : nil)
end
def secure_category?
category && category.secure
end
end