闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
997 B

  1. require 'rails_helper'
  2. RSpec.describe NotifyService do
  3. subject do
  4. -> { described_class.new.call(recipient, activity) }
  5. end
  6. let(:user) { Fabricate(:user) }
  7. let(:recipient) { user.account }
  8. let(:activity) { Fabricate(:follow, target_account: recipient) }
  9. it { is_expected.to change(Notification, :count).by(1) }
  10. describe 'email' do
  11. before do
  12. ActionMailer::Base.deliveries.clear
  13. notification_emails = user.settings.notification_emails
  14. user.settings.notification_emails = notification_emails.merge('follow' => enabled)
  15. end
  16. context 'when email notification is enabled' do
  17. let(:enabled) { true }
  18. it 'sends email' do
  19. is_expected.to change(ActionMailer::Base.deliveries, :count).by(1)
  20. end
  21. end
  22. context 'when email notification is disabled' do
  23. let(:enabled) { false }
  24. it "doesn't send email" do
  25. is_expected.to_not change(ActionMailer::Base.deliveries, :count).from(0)
  26. end
  27. end
  28. end
  29. end