mirror of https://github.com/mastodon/mastodon
add enum validation to IpBlock
This commit is contained in:
parent
90eb4a5d01
commit
d13c20fabe
|
@ -23,7 +23,7 @@ class IpBlock < ApplicationRecord
|
|||
sign_up_requires_approval: 5000,
|
||||
sign_up_block: 5500,
|
||||
no_access: 9999,
|
||||
}, prefix: true
|
||||
}, prefix: true, validate: true
|
||||
|
||||
validates :ip, :severity, presence: true
|
||||
validates :ip, uniqueness: true
|
||||
|
|
|
@ -166,6 +166,16 @@ RSpec.describe 'IP Blocks' do
|
|||
expect(response).to have_http_status(422)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the given severity is invalid' do
|
||||
let(:params) { { ip: '151.0.32.55', severity: 'invalid' } }
|
||||
|
||||
it 'returns http unprocessable entity' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT /api/v1/admin/ip_blocks/:id' do
|
||||
|
|
Loading…
Reference in New Issue