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
|
end
|
||||||
|
|
||||||
def validate_user_is_bannable
|
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
|
end
|
||||||
|
|
||||||
def update_user_on_create
|
def update_user_on_create
|
||||||
|
|||||||
@@ -100,6 +100,11 @@ class BansControllerTest < ActionDispatch::IntegrationTest
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "not raise an exception on a blank username" do
|
||||||
|
post_auth bans_path, @mod, params: {}
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "update action" do
|
context "update action" do
|
||||||
|
|||||||
Reference in New Issue
Block a user