mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-26 03:11:36 +01:00
parent
523e106cbf
commit
552d69ad96
2 changed files with 30 additions and 16 deletions
|
@ -11,5 +11,7 @@ module DomainNormalizable
|
|||
|
||||
def normalize_domain
|
||||
self.domain = TagManager.instance.normalize_domain(domain&.strip)
|
||||
rescue Addressable::URI::InvalidURIError
|
||||
errors.add(:domain, :invalid)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -94,6 +94,7 @@ RSpec.describe Api::V1::Admin::DomainAllowsController, type: :controller do
|
|||
describe 'POST #create' do
|
||||
let!(:domain_allow) { Fabricate(:domain_allow, domain: 'example.com') }
|
||||
|
||||
context do
|
||||
before do
|
||||
post :create, params: { domain: 'foo.bar.com' }
|
||||
end
|
||||
|
@ -115,4 +116,15 @@ RSpec.describe Api::V1::Admin::DomainAllowsController, type: :controller do
|
|||
expect(DomainAllow.find_by(domain: 'foo.bar.com')).to_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid domain name' do
|
||||
before do
|
||||
post :create, params: { domain: 'foo bar' }
|
||||
end
|
||||
|
||||
it 'returns http unprocessable entity' do
|
||||
expect(response).to have_http_status(422)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue