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
|
||||
if creator.is_comment_limited? && !do_not_bump_post?
|
||||
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
|
||||
|
||||
|
||||
@@ -394,14 +394,6 @@ class User < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def can_comment?
|
||||
if is_gold?
|
||||
true
|
||||
else
|
||||
created_at <= Danbooru.config.member_comment_time_threshold
|
||||
end
|
||||
end
|
||||
|
||||
def is_comment_limited?
|
||||
if is_gold?
|
||||
false
|
||||
@@ -506,7 +498,7 @@ class User < ApplicationRecord
|
||||
api_burst_limit remaining_api_limit statement_timeout
|
||||
favorite_group_limit favorite_limit tag_query_limit
|
||||
is_comment_limited?
|
||||
can_comment? max_saved_searches theme
|
||||
max_saved_searches theme
|
||||
]
|
||||
end
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
</ul>
|
||||
|
||||
<div class="section">
|
||||
<h6>Post/Comment Limiting</h6>
|
||||
<p>You cannot upload a post or comment 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>
|
||||
<h6>Post Limiting</h6>
|
||||
<p>You cannot upload a post during the first week of signing up.</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 class="section">
|
||||
|
||||
@@ -133,10 +133,6 @@ module Danbooru
|
||||
40000
|
||||
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/configuring.html#configuring-action-mailer
|
||||
def mail_delivery_method
|
||||
|
||||
@@ -5,7 +5,6 @@ class CommentVotesControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
CurrentUser.user = @user = create(:user)
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
||||
@comment = create(:comment)
|
||||
end
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ class CommentsControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
CurrentUser.user = @user
|
||||
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)
|
||||
end
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ module Moderator
|
||||
@user = create(:gold_user)
|
||||
end
|
||||
@admin = create(:admin_user)
|
||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
||||
end
|
||||
|
||||
context "show action" do
|
||||
|
||||
@@ -17,7 +17,6 @@ class CommentTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@post = FactoryBot.create(:post)
|
||||
Danbooru.config.stubs(:member_comment_limit).returns(100)
|
||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
||||
end
|
||||
|
||||
context "added in an edit" do
|
||||
@@ -82,24 +81,9 @@ class CommentTest < ActiveSupport::TestCase
|
||||
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
|
||||
setup do
|
||||
Danbooru.config.stubs(:member_comment_limit).returns(100)
|
||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
||||
end
|
||||
|
||||
context "that is then deleted" do
|
||||
|
||||
@@ -40,7 +40,6 @@ class UserTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
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)
|
||||
assert(@user.can_comment_vote?)
|
||||
|
||||
@@ -51,18 +50,6 @@ class UserTest < ActiveSupport::TestCase
|
||||
assert(@user.can_comment_vote?)
|
||||
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
|
||||
assert(User.authenticate(@user.name, "password"), "Authentication should have succeeded")
|
||||
assert(!User.authenticate(@user.name, "password2"), "Authentication should not have succeeded")
|
||||
|
||||
Reference in New Issue
Block a user