account_actions_controller_spec.rb 828 B

1234567891011121314151617181920212223242526272829303132333435
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe Admin::AccountActionsController do
  4. render_views
  5. let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
  6. before do
  7. sign_in user, scope: :user
  8. end
  9. describe 'GET #new' do
  10. let(:account) { Fabricate(:account) }
  11. it 'returns http success' do
  12. get :new, params: { account_id: account.id }
  13. expect(response).to have_http_status(:success)
  14. end
  15. end
  16. describe 'POST #create' do
  17. let(:account) { Fabricate(:account) }
  18. it 'records the account action' do
  19. expect do
  20. post :create, params: { account_id: account.id, admin_account_action: { type: 'silence' } }
  21. end.to change { account.strikes.count }.by(1)
  22. expect(response).to redirect_to(admin_account_path(account.id))
  23. end
  24. end
  25. end