Hotfix convert string from symbol (#2856)
* Convert key to string from symbol * Prefer :public_send instead oflolsob-rspec
parent
de0f63e0ac
commit
ea2e2f4857
|
@ -54,10 +54,10 @@ class NotifyService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_email
|
def send_email
|
||||||
NotificationMailer.send(@notification.type, @recipient, @notification).deliver_later
|
NotificationMailer.public_send(@notification.type, @recipient, @notification).deliver_later
|
||||||
end
|
end
|
||||||
|
|
||||||
def email_enabled?
|
def email_enabled?
|
||||||
@recipient.user.settings.notification_emails[@notification.type]
|
@recipient.user.settings.notification_emails[@notification.type.to_s]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe NotifyService do
|
||||||
|
subject do
|
||||||
|
-> { described_class.new.call(recipient, activity) }
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:user) { Fabricate(:user) }
|
||||||
|
let(:recipient) { user.account }
|
||||||
|
let(:activity) { Fabricate(:follow, target_account: recipient) }
|
||||||
|
|
||||||
|
it { is_expected.to change(Notification, :count).by(1) }
|
||||||
|
|
||||||
|
describe 'email' do
|
||||||
|
before do
|
||||||
|
ActionMailer::Base.deliveries.clear
|
||||||
|
|
||||||
|
notification_emails = user.settings.notification_emails
|
||||||
|
user.settings.notification_emails = notification_emails.merge('follow' => enabled)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when email notification is enabled' do
|
||||||
|
let(:enabled) { true }
|
||||||
|
|
||||||
|
it 'sends email' do
|
||||||
|
is_expected.to change(ActionMailer::Base.deliveries, :count).by(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when email notification is disabled' do
|
||||||
|
let(:enabled) { false }
|
||||||
|
|
||||||
|
it "doesn't send email" do
|
||||||
|
is_expected.to_not change(ActionMailer::Base.deliveries, :count).from(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue