Commit 047df46a976bbf756e2351c0df63494722245906

Authored by Nathan Broadbent
1 parent 9883381f
Exists in master and in 1 other branch production

Fixed bug where unwatched apps were being shown for non-admin users. Added extra…

… comment to explain how InheritedResources' begin_of_association_chain works.
Showing 1 changed file with 5 additions and 1 deletions   Show diff stats
app/controllers/apps_controller.rb
@@ -46,7 +46,9 @@ class AppsController < InheritedResources::Base @@ -46,7 +46,9 @@ class AppsController < InheritedResources::Base
46 protected 46 protected
47 def collection 47 def collection
48 # Sort apps by number of unresolved errs (highest number first) 48 # Sort apps by number of unresolved errs (highest number first)
49 - @apps ||= App.all.sort{|a,b| b.errs.unresolved.count <=> a.errs.unresolved.count } 49 + @apps ||= end_of_association_chain.all.sort{|a,b|
  50 + b.errs.unresolved.count <=> a.errs.unresolved.count
  51 + }
50 end 52 end
51 53
52 def initialize_subclassed_issue_tracker 54 def initialize_subclassed_issue_tracker
@@ -58,6 +60,8 @@ class AppsController &lt; InheritedResources::Base @@ -58,6 +60,8 @@ class AppsController &lt; InheritedResources::Base
58 end 60 end
59 61
60 def begin_of_association_chain 62 def begin_of_association_chain
  63 + # Filter the @apps collection to apps watched by the current user, unless user is an admin.
  64 + # If user is an admin, then no filter is applied, and all apps are shown.
61 current_user unless current_user.admin? 65 current_user unless current_user.admin?
62 end 66 end
63 67