mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-17 15:47:15 +01:00
Fix HTTP 500 on POST /api/v1/admin/ip_blocks
(#29308)
This commit is contained in:
parent
3a762cddf6
commit
0db7558822
@ -24,7 +24,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
|
||||
|
@ -12,6 +12,8 @@ RSpec.describe IpBlock do
|
||||
it { is_expected.to validate_presence_of(:severity) }
|
||||
|
||||
it { is_expected.to validate_uniqueness_of(:ip) }
|
||||
|
||||
it { is_expected.to allow_values(:sign_up_requires_approval, :sign_up_block, :no_access).for(:severity) }
|
||||
end
|
||||
|
||||
describe '#to_log_human_identifier' do
|
||||
|
@ -187,6 +187,16 @@ RSpec.describe 'IP Blocks' do
|
||||
.to start_with('application/json')
|
||||
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…
x
Reference in New Issue
Block a user