forked from e621ng/e621ng
[Cleanup] Remove ban check when sending dmails
Banned users can't login in the first place
This commit is contained in:
parent
1c4a79d2ef
commit
9e2c7b2b5b
@ -2,7 +2,6 @@ class Dmail < ApplicationRecord
|
||||
validates :title, :body, presence: { on: :create }
|
||||
validates :title, length: { minimum: 1, maximum: 250 }
|
||||
validates :body, length: { minimum: 1, maximum: Danbooru.config.dmail_max_size }
|
||||
validate :sender_is_not_banned, on: :create
|
||||
validate :recipient_accepts_dmails, on: :create
|
||||
validate :user_not_limited, on: :create
|
||||
|
||||
@ -150,15 +149,6 @@ class Dmail < ApplicationRecord
|
||||
true
|
||||
end
|
||||
|
||||
def sender_is_not_banned
|
||||
if from.try(:is_banned?)
|
||||
errors.add(:base, "Sender is banned and cannot send messages")
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
def recipient_accepts_dmails
|
||||
unless to
|
||||
errors.add(:to_name, "not found")
|
||||
|
@ -54,19 +54,6 @@ class DmailTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "from a banned user" do
|
||||
setup do
|
||||
@user.update_attribute(:is_banned, true)
|
||||
end
|
||||
|
||||
should "not validate" do
|
||||
dmail = build(:dmail, title: "xxx", owner: @user)
|
||||
dmail.save
|
||||
assert_equal(1, dmail.errors.size)
|
||||
assert_equal(["Sender is banned and cannot send messages"], dmail.errors.full_messages)
|
||||
end
|
||||
end
|
||||
|
||||
context "search" do
|
||||
should "return results based on title contents" do
|
||||
dmail = create(:dmail, title: "xxx", body: "bbb", owner: @user)
|
||||
|
Loading…
Reference in New Issue
Block a user