From 65a2b8da12052495df2fe3c5815b1aed13206ab8 Mon Sep 17 00:00:00 2001 From: Dennis Schubert Date: Thu, 6 Sep 2018 01:35:12 +0200 Subject: [PATCH] Include PostsHelper in NotifierHelper Fixes #7852 closes #7853 --- Changelog.md | 2 +- app/helpers/notifier_helper.rb | 5 +++-- spec/mailers/notifier_spec.rb | 8 ++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index 8a0c357f0..22193e249 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,7 +4,7 @@ ## Bug fixes * Add compatibility with macOS to `script/configure_bundler` [#7830](https://github.com/diaspora/diaspora/pull/7830) -* Fix comment notifications for comments on posts without text [#7857](https://github.com/diaspora/diaspora/pull/7857) +* Fix comment and like notifications on posts without text [#7857](https://github.com/diaspora/diaspora/pull/7857) [#7853](https://github.com/diaspora/diaspora/pull/7853) ## Features * Add `web+diaspora://` link handler [#7826](https://github.com/diaspora/diaspora/pull/7826) diff --git a/app/helpers/notifier_helper.rb b/app/helpers/notifier_helper.rb index 70e780709..e7a05af5f 100644 --- a/app/helpers/notifier_helper.rb +++ b/app/helpers/notifier_helper.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module NotifierHelper + include PostsHelper # @param post [Post] The post object. # @param opts [Hash] Optional hash. Accepts :length parameters. @@ -9,7 +10,7 @@ module NotifierHelper if post.respond_to? :message post.message.try(:plain_text_without_markdown).presence || post_page_title(post) else - I18n.translate 'notifier.a_post_you_shared' + I18n.translate "notifier.a_post_you_shared" end end @@ -19,7 +20,7 @@ module NotifierHelper if comment.post.public? comment.message.plain_text_without_markdown else - I18n.translate 'notifier.a_limited_post_comment' + I18n.translate "notifier.a_limited_post_comment" end end end diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 002014b05..d86d7ef79 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -214,6 +214,14 @@ describe Notifier, type: :mailer do like = reshare.likes.create!(author: bob.person) Notifier.send_notification("liked", alice.id, like.author.id, like.id) end + + it "can handle status_messages without text" do + photo = FactoryGirl.create(:photo, public: true) + status = FactoryGirl.create(:status_message, author: alice.person, text: nil, photos: [photo], public: true) + like = status.likes.create!(author: bob.person) + mail = Notifier.send_notification("liked", alice.id, like.author.id, like.id) + expect(mail.body.encoded).to include(I18n.t("posts.show.photos_by", count: 1, author: alice.name)) + end end describe ".reshared" do