bans: fix exception when username is blank.
Fix exception when submitting the ban form and the username is blank.
This commit is contained in:
@@ -43,7 +43,7 @@ class Ban < ApplicationRecord
|
||||
end
|
||||
|
||||
def validate_user_is_bannable
|
||||
errors.add(:user, "is already banned") if user.is_banned?
|
||||
errors.add(:user, "is already banned") if user&.is_banned?
|
||||
end
|
||||
|
||||
def update_user_on_create
|
||||
|
||||
@@ -100,6 +100,11 @@ class BansControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
should "not raise an exception on a blank username" do
|
||||
post_auth bans_path, @mod, params: {}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
context "update action" do
|
||||
|
||||
Reference in New Issue
Block a user