Commit 4caaf694 authored by Alex Pooley's avatar Alex Pooley

Merge branch 'fix_bug_with_mime_types' into 'master'

Fix validation method regarding MIME type keys

See merge request gitlab-org/gitlab!65954
parents f7b4e89c 0b4e1788
......@@ -2106,7 +2106,7 @@ class User < ApplicationRecord
end
def check_username_format
return if username.blank? || Mime::EXTENSION_LOOKUP.keys.none? { |type| username.end_with?(type) }
return if username.blank? || Mime::EXTENSION_LOOKUP.keys.none? { |type| username.end_with?(".#{type}") }
errors.add(:username, _('ending with MIME type format is not allowed.'))
end
......
......@@ -394,6 +394,7 @@ RSpec.describe User do
expect(user).not_to be_valid
expect(user.errors.full_messages).to include('Username ending with MIME type format is not allowed.')
expect(build(:user, username: "test#{type}")).to be_valid
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment