mirror of
https://github.com/mastodon/mastodon.git
synced 2025-05-28 20:47:10 +00:00
Enable validate: true
on CustomFilter#action
(#34434)
This commit is contained in:
parent
6d94c9f4e7
commit
aadff24099
|
@ -33,7 +33,7 @@ class CustomFilter < ApplicationRecord
|
||||||
include Expireable
|
include Expireable
|
||||||
include Redisable
|
include Redisable
|
||||||
|
|
||||||
enum :action, { warn: 0, hide: 1, blur: 2 }, suffix: :action
|
enum :action, { warn: 0, hide: 1, blur: 2 }, suffix: :action, validate: true
|
||||||
|
|
||||||
belongs_to :account
|
belongs_to :account
|
||||||
has_many :keywords, class_name: 'CustomFilterKeyword', inverse_of: :custom_filter, dependent: :destroy
|
has_many :keywords, class_name: 'CustomFilterKeyword', inverse_of: :custom_filter, dependent: :destroy
|
||||||
|
|
|
@ -115,6 +115,21 @@ RSpec.describe 'Filters' do
|
||||||
.to start_with('application/json')
|
.to start_with('application/json')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when the given filter_action value is invalid' do
|
||||||
|
let(:params) { { title: 'magic', filter_action: 'imaginary_value', keywords_attributes: [keyword: 'magic'] } }
|
||||||
|
|
||||||
|
it 'returns http unprocessable entity' do
|
||||||
|
subject
|
||||||
|
|
||||||
|
expect(response)
|
||||||
|
.to have_http_status(422)
|
||||||
|
expect(response.content_type)
|
||||||
|
.to start_with('application/json')
|
||||||
|
expect(response.parsed_body)
|
||||||
|
.to include(error: /Action is not included/)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET /api/v2/filters/:id' do
|
describe 'GET /api/v2/filters/:id' do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user