From 366eff41695271e62d0de67c7862a194e3022b30 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 16 Aug 2020 17:04:13 -0500 Subject: [PATCH] posts: show only last successful flag on deleted posts. In the "This post was deleted" notice, show only the last successful flag, instead of all previous flags (which may include rejected flags). --- app/views/posts/partials/show/_notices.html.erb | 6 +++--- test/functional/posts_controller_test.rb | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/views/posts/partials/show/_notices.html.erb b/app/views/posts/partials/show/_notices.html.erb index 8a1e37a51..77ded1850 100644 --- a/app/views/posts/partials/show/_notices.html.erb +++ b/app/views/posts/partials/show/_notices.html.erb @@ -25,9 +25,9 @@ <% elsif post.is_deleted? %>
- <% if post.flags.any? %> -

This post was deleted for the following reasons:

- <%= render "post_flags/reasons", flags: post.flags %> + <% if post.flags.succeeded.last.present? %> +

This post was deleted for the following reason:

+ <%= render "post_flags/reasons", flag: post.flags.succeeded.last %> <% else %>

This post was deleted

<% end %> diff --git a/test/functional/posts_controller_test.rb b/test/functional/posts_controller_test.rb index 89431f69d..d0f36c3f3 100644 --- a/test/functional/posts_controller_test.rb +++ b/test/functional/posts_controller_test.rb @@ -540,6 +540,15 @@ class PostsControllerTest < ActionDispatch::IntegrationTest end end + context "a deleted post" do + should "render" do + @post.delete!("no", user: @user) + get post_path(@post) + + assert_response :success + end + end + context "with pools" do should "render the pool list" do as(@user) { @post.update(tag_string: "newpool:comic") }