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).
This commit is contained in:
evazion
2020-08-16 17:04:13 -05:00
parent 8f1276b013
commit 366eff4169
2 changed files with 12 additions and 3 deletions

View File

@@ -25,9 +25,9 @@
</div>
<% elsif post.is_deleted? %>
<div class="notice notice-small post-notice post-notice-deleted">
<% if post.flags.any? %>
<p>This post was deleted for the following reasons: </p>
<%= render "post_flags/reasons", flags: post.flags %>
<% if post.flags.succeeded.last.present? %>
<p>This post was deleted for the following reason: </p>
<%= render "post_flags/reasons", flag: post.flags.succeeded.last %>
<% else %>
<p>This post was deleted</p>
<% end %>

View File

@@ -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") }