1
0

unmute_service_spec.rb 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe UnmuteService do
  4. describe '#call' do
  5. let!(:account) { Fabricate(:account) }
  6. let!(:target_account) { Fabricate(:account) }
  7. context 'when account is muting target account' do
  8. before { Fabricate :mute, account: account, target_account: target_account }
  9. context 'when account follows target_account' do
  10. before { Fabricate :follow, account: account, target_account: target_account }
  11. it 'removes the account mute and sets up a merge' do
  12. expect { subject.call(account, target_account) }
  13. .to remove_account_mute
  14. expect(MergeWorker).to have_enqueued_sidekiq_job(target_account.id, account.id, 'home')
  15. end
  16. end
  17. context 'when account does not follow target_account' do
  18. it 'removes the account mute and does not create a merge' do
  19. expect { subject.call(account, target_account) }
  20. .to remove_account_mute
  21. expect(MergeWorker).to_not have_enqueued_sidekiq_job(any_args)
  22. end
  23. end
  24. def remove_account_mute
  25. change { account.reload.muting?(target_account) }
  26. .from(true)
  27. .to(false)
  28. end
  29. end
  30. context 'when account is not muting target account' do
  31. it 'does nothing and returns' do
  32. expect { subject.call(account, target_account) }
  33. .to_not(change { account.reload.muting?(target_account) })
  34. expect(MergeWorker).to_not have_enqueued_sidekiq_job(any_args)
  35. end
  36. end
  37. end
  38. end