appeals_controller_spec.rb 861 B

123456789101112131415161718192021222324252627
  1. require 'rails_helper'
  2. RSpec.describe Disputes::AppealsController, type: :controller do
  3. render_views
  4. before { sign_in current_user, scope: :user }
  5. let!(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
  6. describe '#create' do
  7. let(:current_user) { Fabricate(:user) }
  8. let(:strike) { Fabricate(:account_warning, target_account: current_user.account) }
  9. before do
  10. allow(AdminMailer).to receive(:new_appeal).and_return(double('email', deliver_later: nil))
  11. post :create, params: { strike_id: strike.id, appeal: { text: 'Foo' } }
  12. end
  13. it 'notifies staff about new appeal' do
  14. expect(AdminMailer).to have_received(:new_appeal).with(admin.account, Appeal.last)
  15. end
  16. it 'redirects back to the strike page' do
  17. expect(response).to redirect_to(disputes_strike_path(strike.id))
  18. end
  19. end
  20. end