appeal_service_spec.rb 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe AppealService, :inline_jobs do
  4. describe '#call' do
  5. let!(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
  6. context 'with an existing strike' do
  7. let(:strike) { Fabricate(:account_warning) }
  8. let(:text) { 'Appeal text' }
  9. it 'creates an appeal and notifies staff' do
  10. emails = capture_emails { subject.call(strike, text) }
  11. expect(Appeal.last)
  12. .to have_attributes(
  13. strike: strike,
  14. text: text,
  15. account: strike.target_account
  16. )
  17. expect(emails.size)
  18. .to eq(1)
  19. expect(emails.first)
  20. .to have_attributes(
  21. to: contain_exactly(admin.email),
  22. subject: eq(
  23. I18n.t(
  24. 'admin_mailer.new_appeal.subject',
  25. username: strike.target_account.acct,
  26. instance: Rails.configuration.x.local_domain
  27. )
  28. )
  29. )
  30. end
  31. end
  32. end
  33. end