Fix `ArgumentError` in `/api/v1/admin/accounts/:id/action` (#25386)

th-downstream
Daniel M Brasil 1 year ago committed by GitHub
parent dc31ba1a28
commit 4a994e5b50

@ -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…
Cancel
Save