reduce constraints for when to show forum post vote links (#3691)
This commit is contained in:
@@ -139,8 +139,7 @@ class ForumPost < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def votable?
|
def votable?
|
||||||
# shortcut to eliminate posts that are probably not tag change requests
|
body.to_s.match?(/->/)
|
||||||
body =~ /->/ && (bulk_update_request.present? || tag_alias.present? || tag_implication.present?) && created_at >= TagRelationship::EXPIRY.days.ago
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def voted?(user, score)
|
def voted?(user, score)
|
||||||
|
|||||||
@@ -11,6 +11,6 @@
|
|||||||
<%= render "forum_post_votes/vote", vote: vote, forum_post: forum_post %>
|
<%= render "forum_post_votes/vote", vote: vote, forum_post: forum_post %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if forum_post.tag_change_request.is_pending? && !votes.by(CurrentUser.user.id).exists? %>
|
<% if forum_post.tag_change_request && forum_post.tag_change_request.is_pending? && !votes.by(CurrentUser.user.id).exists? %>
|
||||||
<%= render "forum_post_votes/add_vote", vote: votes.by(CurrentUser.user.id).first, forum_post: forum_post %>
|
<%= render "forum_post_votes/add_vote", vote: votes.by(CurrentUser.user.id).first, forum_post: forum_post %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
%>
|
%>
|
||||||
|
|
||||||
<li class="vote-score-<%= vote.vote_type %>">
|
<li class="vote-score-<%= vote.vote_type %>">
|
||||||
<% if forum_post.tag_change_request.is_pending? && vote.creator_id == CurrentUser.id %>
|
<% if forum_post.tag_change_request && forum_post.tag_change_request.is_pending? && vote.creator_id == CurrentUser.id %>
|
||||||
<%= link_to content_tag(:i, nil, class: "far #{vote.fa_class}"), forum_post_votes_path(forum_post_id: forum_post.id, format: "js"), remote: true, method: :delete %>
|
<%= link_to content_tag(:i, nil, class: "far #{vote.fa_class}"), forum_post_votes_path(forum_post_id: forum_post.id, format: "js"), remote: true, method: :delete %>
|
||||||
<%= link_to_user vote.creator %>
|
<%= link_to_user vote.creator %>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|||||||
@@ -15,10 +15,9 @@ class ForumPostsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
context "with votes" do
|
context "with votes" do
|
||||||
setup do
|
setup do
|
||||||
as_user do
|
as_user do
|
||||||
as(@user) do
|
@tag_alias = create(:tag_alias, forum_post: @forum_post, status: "pending")
|
||||||
@tag_alias = create(:tag_alias, forum_post: @forum_post, status: "pending")
|
@vote = create(:forum_post_vote, forum_post: @forum_post, score: 1)
|
||||||
@vote = create(:forum_post_vote, forum_post: @forum_post, score: 1)
|
@forum_post.reload
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ class ForumPostsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "hide the vote links" do
|
should "hide the vote links" do
|
||||||
assert_select "a[title='Vote up']"
|
assert_select "a[title='Vote up']", false
|
||||||
end
|
end
|
||||||
|
|
||||||
should "still render existing votes" do
|
should "still render existing votes" do
|
||||||
|
|||||||
Reference in New Issue
Block a user