From 08e108d3d87c8415bc2ffa081b6b391dac503115 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Wed, 5 Sep 2018 01:32:36 +0200 Subject: [PATCH] Fix comment notification subject for posts without text Fixes #7854 --- Changelog.md | 1 + app/models/status_message.rb | 6 +++++- spec/models/status_message_spec.rb | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 1f39b07af..8a0c357f0 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +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) ## Features * Add `web+diaspora://` link handler [#7826](https://github.com/diaspora/diaspora/pull/7826) diff --git a/app/models/status_message.rb b/app/models/status_message.rb index 0c68286ae..4f8e192d7 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -62,7 +62,11 @@ class StatusMessage < Post end def comment_email_subject - message.title + if message.present? + message.title + elsif photos.present? + I18n.t("posts.show.photos_by", count: photos.size, author: author_name) + end end def first_photo_url(*args) diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index 0fcab057f..05520de32 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -170,6 +170,18 @@ describe StatusMessage, type: :model do end end + describe "#comment_email_subject" do + it "delegates to message.title if the post have a text" do + expect(status.comment_email_subject).to eq(status.message.title) + end + + it "includes the photos count if there are photos without text" do + photo = FactoryGirl.build(:photo, public: true) + status = FactoryGirl.build(:status_message, author: photo.author, text: nil, photos: [photo], public: true) + expect(status.comment_email_subject).to eq(I18n.t("posts.show.photos_by", count: 1, author: status.author_name)) + end + end + describe "tags" do it_should_behave_like "it is taggable" do let(:object) { build(:status_message) } -- GitLab