Merge pull request #7857 from SuperTux88/fix-comment-title-without-text

Fix comment notification subject for posts without text
This commit is contained in:
Dennis Schubert 2018-09-05 03:13:45 +02:00 committed by GitHub
commit 60b5443850
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -62,7 +62,11 @@ class StatusMessage < Post
end end
def comment_email_subject def comment_email_subject
if message.present?
message.title message.title
elsif photos.present?
I18n.t("posts.show.photos_by", count: photos.size, author: author_name)
end
end end
def first_photo_url(*args) def first_photo_url(*args)

View file

@ -170,6 +170,18 @@ describe StatusMessage, type: :model do
end end
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 describe "tags" do
it_should_behave_like "it is taggable" do it_should_behave_like "it is taggable" do
let(:object) { build(:status_message) } let(:object) { build(:status_message) }