From 6145e99baabf4f1778f0d998ab4d4ad27e681ea1 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 27 Jun 2013 16:58:35 +1000 Subject: [PATCH] navigate to message fixed, changed to button added spec to catch this regression in future --- .../admin/templates/flags.js.handlebars | 2 +- app/models/post_action.rb | 18 +++++++++++------- spec/models/post_action_spec.rb | 8 +++++++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/admin/templates/flags.js.handlebars b/app/assets/javascripts/admin/templates/flags.js.handlebars index 879a5d50d57..f07b12952f0 100644 --- a/app/assets/javascripts/admin/templates/flags.js.handlebars +++ b/app/assets/javascripts/admin/templates/flags.js.handlebars @@ -54,7 +54,7 @@ -
{{#linkTo 'adminUser' user}}{{avatar user imageSize="small"}}{{/linkTo}} {{message}} {{i18n admin.flags.view_message}}
+
{{#linkTo 'adminUser' user}}{{avatar user imageSize="small"}}{{/linkTo}} {{message}}
diff --git a/app/models/post_action.rb b/app/models/post_action.rb index fda896c896b..8996b9f1bd9 100644 --- a/app/models/post_action.rb +++ b/app/models/post_action.rb @@ -327,13 +327,17 @@ class PostAction < ActiveRecord::Base posts = post_ids.map{|id| post_lookup[id]} post_actions = actions.where(:post_id => post_ids) - .select('post_actions.id, - post_actions.user_id, - post_action_type_id, - post_actions.created_at, - post_actions.post_id, - post_actions.message') - .to_a + # TODO this is so far from optimal, it should not be + # selecting all the columns but the includes stops working + # with the code below + # + # .select('post_actions.id, + # post_actions.user_id, + # post_action_type_id, + # post_actions.created_at, + # post_actions.post_id, + # post_actions.message') + # .to_a post_actions.each do |pa| post = post_lookup[pa.post_id] diff --git a/spec/models/post_action_spec.rb b/spec/models/post_action_spec.rb index e32760925cf..29cf1d85cb3 100644 --- a/spec/models/post_action_spec.rb +++ b/spec/models/post_action_spec.rb @@ -15,9 +15,15 @@ describe PostAction do describe "flagged_posts_report" do it "operates correctly" do PostAction.act(codinghorror, post, PostActionType.types[:spam]) + mod_message = PostAction.act(Fabricate(:user), post, PostActionType.types[:notify_moderators], message: "this post really sucks a lot I hate it") + posts, users = PostAction.flagged_posts_report("") posts.count.should == 1 - users.count.should == 2 + first = posts.first + + users.count.should == 3 + first[:post_actions].count.should == 2 + first[:post_actions].first[:permalink].should == mod_message.related_post.topic.url end end