comments: allow new users to comment.
Remove the rule that users less than a week old can't leave comments.
This commit is contained in:
@@ -83,8 +83,6 @@ class Comment < ApplicationRecord
|
|||||||
def validate_creator_is_not_limited
|
def validate_creator_is_not_limited
|
||||||
if creator.is_comment_limited? && !do_not_bump_post?
|
if creator.is_comment_limited? && !do_not_bump_post?
|
||||||
errors.add(:base, "You can only post #{Danbooru.config.member_comment_limit} comments per hour")
|
errors.add(:base, "You can only post #{Danbooru.config.member_comment_limit} comments per hour")
|
||||||
elsif !creator.can_comment?
|
|
||||||
errors.add(:base, "You can not post comments within 1 week of sign up")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -394,14 +394,6 @@ class User < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_comment?
|
|
||||||
if is_gold?
|
|
||||||
true
|
|
||||||
else
|
|
||||||
created_at <= Danbooru.config.member_comment_time_threshold
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def is_comment_limited?
|
def is_comment_limited?
|
||||||
if is_gold?
|
if is_gold?
|
||||||
false
|
false
|
||||||
@@ -506,7 +498,7 @@ class User < ApplicationRecord
|
|||||||
api_burst_limit remaining_api_limit statement_timeout
|
api_burst_limit remaining_api_limit statement_timeout
|
||||||
favorite_group_limit favorite_limit tag_query_limit
|
favorite_group_limit favorite_limit tag_query_limit
|
||||||
is_comment_limited?
|
is_comment_limited?
|
||||||
can_comment? max_saved_searches theme
|
max_saved_searches theme
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,9 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h6>Post/Comment Limiting</h6>
|
<h6>Post Limiting</h6>
|
||||||
<p>You cannot upload a post or comment during the first week of signing up.</p>
|
<p>You cannot upload a post during the first week of signing up.</p>
|
||||||
<p>After the initial period, you can post up to two comments an hour and a variable number of posts based on how many of your previous uploads were approved or deleted.</p>
|
<p>After the initial period, you can post a variable number of posts based on how many of your previous uploads were approved or deleted.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="section">
|
<div class="section">
|
||||||
|
|||||||
@@ -133,10 +133,6 @@ module Danbooru
|
|||||||
40000
|
40000
|
||||||
end
|
end
|
||||||
|
|
||||||
def member_comment_time_threshold
|
|
||||||
1.week.ago
|
|
||||||
end
|
|
||||||
|
|
||||||
# https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration
|
# https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration
|
||||||
# https://guides.rubyonrails.org/configuring.html#configuring-action-mailer
|
# https://guides.rubyonrails.org/configuring.html#configuring-action-mailer
|
||||||
def mail_delivery_method
|
def mail_delivery_method
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ class CommentVotesControllerTest < ActionDispatch::IntegrationTest
|
|||||||
setup do
|
setup do
|
||||||
CurrentUser.user = @user = create(:user)
|
CurrentUser.user = @user = create(:user)
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
|
||||||
@comment = create(:comment)
|
@comment = create(:comment)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ class CommentsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
|
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
|
||||||
Danbooru.config.stubs(:member_comment_limit).returns(100)
|
Danbooru.config.stubs(:member_comment_limit).returns(100)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ module Moderator
|
|||||||
@user = create(:gold_user)
|
@user = create(:gold_user)
|
||||||
end
|
end
|
||||||
@admin = create(:admin_user)
|
@admin = create(:admin_user)
|
||||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "show action" do
|
context "show action" do
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ class CommentTest < ActiveSupport::TestCase
|
|||||||
setup do
|
setup do
|
||||||
@post = FactoryBot.create(:post)
|
@post = FactoryBot.create(:post)
|
||||||
Danbooru.config.stubs(:member_comment_limit).returns(100)
|
Danbooru.config.stubs(:member_comment_limit).returns(100)
|
||||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "added in an edit" do
|
context "added in an edit" do
|
||||||
@@ -82,24 +81,9 @@ class CommentTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "created by a limited user" do
|
|
||||||
setup do
|
|
||||||
Danbooru.config.stubs(:member_comment_limit).returns(5)
|
|
||||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.ago)
|
|
||||||
end
|
|
||||||
|
|
||||||
should "fail creation" do
|
|
||||||
post = FactoryBot.create(:post)
|
|
||||||
comment = FactoryBot.build(:comment, post: post)
|
|
||||||
comment.save
|
|
||||||
assert_equal(["You can not post comments within 1 week of sign up"], comment.errors.full_messages)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "created by an unlimited user" do
|
context "created by an unlimited user" do
|
||||||
setup do
|
setup do
|
||||||
Danbooru.config.stubs(:member_comment_limit).returns(100)
|
Danbooru.config.stubs(:member_comment_limit).returns(100)
|
||||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "that is then deleted" do
|
context "that is then deleted" do
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "limit comment votes" do
|
should "limit comment votes" do
|
||||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
|
||||||
Danbooru.config.stubs(:member_comment_limit).returns(10)
|
Danbooru.config.stubs(:member_comment_limit).returns(10)
|
||||||
assert(@user.can_comment_vote?)
|
assert(@user.can_comment_vote?)
|
||||||
|
|
||||||
@@ -51,18 +50,6 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
assert(@user.can_comment_vote?)
|
assert(@user.can_comment_vote?)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "limit comments" do
|
|
||||||
assert(!@user.can_comment?)
|
|
||||||
@user.update_column(:level, User::Levels::GOLD)
|
|
||||||
assert(@user.can_comment?)
|
|
||||||
@user.update_column(:level, User::Levels::MEMBER)
|
|
||||||
@user.update_column(:created_at, 1.year.ago)
|
|
||||||
assert(@user.can_comment?)
|
|
||||||
assert(!@user.is_comment_limited?)
|
|
||||||
create_list(:comment, Danbooru.config.member_comment_limit, creator: @user)
|
|
||||||
assert(@user.is_comment_limited?)
|
|
||||||
end
|
|
||||||
|
|
||||||
should "authenticate" do
|
should "authenticate" do
|
||||||
assert(User.authenticate(@user.name, "password"), "Authentication should have succeeded")
|
assert(User.authenticate(@user.name, "password"), "Authentication should have succeeded")
|
||||||
assert(!User.authenticate(@user.name, "password2"), "Authentication should not have succeeded")
|
assert(!User.authenticate(@user.name, "password2"), "Authentication should not have succeeded")
|
||||||
|
|||||||
Reference in New Issue
Block a user