Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0f7784c
added Post#deleted_by_owner? predicate
Oaphi Sep 5, 2025
c7fc046
fixed server error when rendering posts/_expanded if deleter user is …
Oaphi Sep 5, 2025
a078946
fixed server error when rendering reactions from hard-deleted users
Oaphi Sep 5, 2025
037f560
fixed unexpected error when opening a comment thread lock modal
Oaphi Sep 5, 2025
595d9d1
added missing locked_at column to comment threads
Oaphi Sep 5, 2025
0dd8fa1
added Ability#post_score_percent_for(user) nil-safe method
Oaphi Sep 6, 2025
94076a2
added Ability#edit_score_percent_for(user) nil-safe method
Oaphi Sep 6, 2025
d32ae6b
added Ability#flag_score_percent_for(user) nil-safe method
Oaphi Sep 6, 2025
f89cf87
consider abilities with threshold set to 0 to be automatically reached
Oaphi Sep 6, 2025
4f8465b
added failure path tests for score_percent_for methods of Ability model
Oaphi Sep 6, 2025
5de8faa
added auto success path tests for score_percent_for methods of Abilit…
Oaphi Sep 6, 2025
d12c773
added test for edit_score_percent_for actual calculation
Oaphi Sep 6, 2025
aed68e6
added test for flag_score_percent_for actual calculation
Oaphi Sep 6, 2025
85797f1
added missing 'everyone' user ability to new user fixtures
Oaphi Sep 6, 2025
f67cb47
added missing 'unrestricted' user ability to new user fixtures
Oaphi Sep 6, 2025
4ad6032
made User#ability_on? tests more robust
Oaphi Sep 6, 2025
bbd8420
added test for post_score_percent_for actual calculation
Oaphi Sep 6, 2025
9968126
made ability score user fixtures clearer in intent
Oaphi Sep 6, 2025
ce1dcbb
moved comment thread locking into a proper lock_thread action with er…
Oaphi Sep 7, 2025
92014eb
don't forget to remove testing overrides
Oaphi Sep 7, 2025
5149019
split thread restrict actions into individual actions
Oaphi Sep 7, 2025
a191df6
split thread unrestrict actions into individual actions
Oaphi Sep 7, 2025
b22c736
disambiguated post_scorer_question fixture's meaning of 'positively s…
Oaphi Sep 8, 2025
bc6bacb
finished splitting up thread_restrict action
Oaphi Sep 9, 2025
3b974bf
restored follow comment thread client-side functionality
Oaphi Sep 9, 2025
027d186
fixed retrict actions on expanded thread view loading inline version …
Oaphi Sep 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/models/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ def closeable?
post_type.is_closeable
end

# Is the post deleted by the owner?
# @return [Boolean] check result
def deleted_by_owner?
deleted_by&.same_as?(user)
end

# @return [Boolean] whether there is a suggested edit pending for this post
def pending_suggested_edit?
SuggestedEdit.where(post_id: id, active: true).any?
Expand Down
11 changes: 5 additions & 6 deletions app/views/posts/_expanded.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,23 @@
</div>
<% end %>

<% if post.deleted %>
<% if post.deleted? %>
<div class="notice has-margin-2">
<p class="has-font-weight-normal">
<strong>Deleted</strong> by <%= user_link post.deleted_by %>
on <%= post.deleted_at.strftime('%b %e, %Y at %H:%M') %>
</p>
<hr>
<% if post.deleted_by.id == post.user_id %>
<% if post.deleted_by_owner? %>
<p>
The author of this post decided to delete it. It can only be seen by users with the Curate privilege.
The author of this post decided to delete it. It can only be seen by users with the Curate ability.
</p>
<% else %>
<p>
This post was deleted and can only be seen by users with the Curate privilege.
This post was deleted and can only be seen by users with the Curate ability.
</p>
<% end %>

<p>Users with the Curate privilege may vote to restore this post if it has been deleted incorrectly.</p>
<p>Users with the Curate ability may vote to restore this post if it has been deleted incorrectly.</p>
</div>
<% end %>

Expand Down
7 changes: 4 additions & 3 deletions app/views/reactions/_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<% end %>
</div>

<%# TODO: eager load instead %>
<% host = post.community.host %>

<% post.reaction_list.each do |rt, rr| %>
<div class="modal is-with-backdrop reaction-info-modal"
id="reaction-info-<%= post.id %>-<%= rt.id %>">
Expand All @@ -43,9 +46,7 @@
</tr>
<% rr.each do |r| %>
<tr>
<td>
<%= link_to rtl_safe_username(r.user), user_path(r.user), dir: 'ltr'%>
</td>
<td><%= user_link(r.user, { host: host }) %></td>
<td class="comment-col">
<% if r.comment %>
<div class="muted-p">
Expand Down
6 changes: 6 additions & 0 deletions test/models/post_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,10 @@ class PostTest < ActiveSupport::TestCase
end
end
end

test 'deleted_by_owner? should correctly determine if the post is deleted by its owner' do
posts.reject(&:deleted).each do |post|
assert_not post.deleted_by_owner?
end
end
end