mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Add severity validation
This commit is contained in:
parent
be52633ee4
commit
0b66433c08
2 changed files with 12 additions and 1 deletions
|
@ -21,7 +21,7 @@ class DomainBlock < ApplicationRecord
|
|||
include DomainNormalizable
|
||||
include DomainMaterializable
|
||||
|
||||
enum :severity, { silence: 0, suspend: 1, noop: 2 }
|
||||
enum :severity, { silence: 0, suspend: 1, noop: 2 }, validate: true
|
||||
|
||||
validates :domain, presence: true, uniqueness: true, domain: true
|
||||
|
||||
|
|
|
@ -168,6 +168,17 @@ RSpec.describe 'Domain Blocks' do
|
|||
expect(response).to have_http_status(422)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when severity is invalid' do
|
||||
let(:params) { { domain: 'bar.com', severity: :bar } }
|
||||
|
||||
it 'returns http unprocessable entity' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(body_as_json[:error]).to eq('Validation failed: Severity is not included in the list')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT /api/v1/admin/domain_blocks/:id' do
|
||||
|
|
Loading…
Reference in a new issue