User correct username in mobile mention notifications (#15861)
This commit is contained in:
parent
c75dd69d09
commit
10c13078cb
2 changed files with 14 additions and 1 deletions
|
|
@ -42,7 +42,7 @@ module Notifications
|
|||
title: "🗣️ New Mention",
|
||||
body: "#{I18n.t(
|
||||
message_key,
|
||||
user: mention.user.username,
|
||||
user: mention.mentionable.user.username,
|
||||
title: mentionable_title, # For an article this should be title, for comment should be article's title
|
||||
)}:\n" \
|
||||
"#{strip_tags(mention.mentionable.processed_html).strip}",
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ end
|
|||
RSpec.describe Notifications::NewMention::Send, type: :service do
|
||||
let(:user) { create(:user) }
|
||||
let!(:article) { create(:article) }
|
||||
let(:article_author) { article.user }
|
||||
let!(:mention) { create(:mention, mentionable: article, user: user) }
|
||||
|
||||
it "creates users notifications" do
|
||||
|
|
@ -47,6 +48,18 @@ RSpec.describe Notifications::NewMention::Send, type: :service do
|
|||
expect(notification.json_data["user"]["username"]).to eq(article.user.username)
|
||||
end
|
||||
|
||||
it "creates a mobile notification with name of the mentionable author" do
|
||||
user.notification_setting.update(mobile_mention_notifications: true)
|
||||
allow(PushNotifications::Send).to receive(:call)
|
||||
allow(I18n).to receive(:t).with("views.notifications.mention.article_mobile",
|
||||
user: mention.mentionable.user.username,
|
||||
title: anything).and_call_original
|
||||
|
||||
described_class.call(mention)
|
||||
expect(PushNotifications::Send).to have_received(:call)
|
||||
expect(I18n).to have_received(:t)
|
||||
end
|
||||
|
||||
it "does not send if the article has negative score already" do
|
||||
prior_notification_size = Notification.all.size
|
||||
article.update_column(:score, -1)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue