mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-18 04:19:27 +00:00
Fix ArgumentError
in /api/v1/admin/accounts/:id/action
(#25386)
This commit is contained in:
parent
b9e8d2b352
commit
d9c6f70cc6
|
@ -26,6 +26,7 @@ class Admin::AccountAction
|
|||
alias include_statuses? include_statuses
|
||||
|
||||
validates :type, :target_account, :current_account, presence: true
|
||||
validates :type, inclusion: { in: TYPES }
|
||||
|
||||
def initialize(attributes = {})
|
||||
@send_email_notification = true
|
||||
|
@ -71,6 +72,10 @@ class Admin::AccountAction
|
|||
TYPES - %w(none disable)
|
||||
end
|
||||
end
|
||||
|
||||
def i18n_scope
|
||||
:activerecord
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -55,6 +55,22 @@ RSpec.describe Admin::AccountAction do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when type is invalid' do
|
||||
let(:type) { 'whatever' }
|
||||
|
||||
it 'raises an invalid record error' do
|
||||
expect { subject }.to raise_error(ActiveRecord::RecordInvalid)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when type is not given' do
|
||||
let(:type) { '' }
|
||||
|
||||
it 'raises an invalid record error' do
|
||||
expect { subject }.to raise_error(ActiveRecord::RecordInvalid)
|
||||
end
|
||||
end
|
||||
|
||||
it 'creates Admin::ActionLog' do
|
||||
expect do
|
||||
subject
|
||||
|
|
Loading…
Reference in a new issue