From 213a49620398ba3b29159ef7b94fdbe32cb30f08 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Wed, 22 Feb 2017 13:31:40 +0530 Subject: [PATCH] FIX: show all staff events related to the target user --- .../javascripts/admin/routes/admin-user-index.js.es6 | 2 +- lib/guardian.rb | 2 +- spec/components/guardian_spec.rb | 8 ++------ 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/admin/routes/admin-user-index.js.es6 b/app/assets/javascripts/admin/routes/admin-user-index.js.es6 index ba3b7c318a5..6a735a247ab 100644 --- a/app/assets/javascripts/admin/routes/admin-user-index.js.es6 +++ b/app/assets/javascripts/admin/routes/admin-user-index.js.es6 @@ -33,7 +33,7 @@ export default Discourse.Route.extend({ viewActionLogs(username) { const controller = this.controllerFor('adminLogs.staffActionLogs'); this.transitionTo('adminLogs.staffActionLogs').then(() => { - controller._changeFilters({ acting_user: username }); + controller._changeFilters({ target_user: username }); }); } } diff --git a/lib/guardian.rb b/lib/guardian.rb index abdd927dcfa..4a369938849 100644 --- a/lib/guardian.rb +++ b/lib/guardian.rb @@ -159,7 +159,7 @@ class Guardian end def can_view_action_logs?(target) - is_staff? && target && target.staff? + is_staff? && target end # Can we approve it? diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rb index 370e61ce2bc..a140c3c0744 100644 --- a/spec/components/guardian_spec.rb +++ b/spec/components/guardian_spec.rb @@ -289,12 +289,8 @@ describe Guardian do expect(Guardian.new(moderator).can_view_action_logs?(nil)).to be_falsey end - it 'is false for non-staff target user' do - expect(Guardian.new(moderator).can_view_action_logs?(user)).to be_falsey - end - - it 'is true for staff target user' do - expect(Guardian.new(moderator).can_view_action_logs?(admin)).to be_truthy + it 'is true when target user is present' do + expect(Guardian.new(moderator).can_view_action_logs?(user)).to be_truthy end end