diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index b617c47ef..f7d43f196 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -24,7 +24,11 @@ module NotificationsHelper end elsif note.instance_of?(Notifications::Liked) post = note.target - "#{translation(target_type, post.author.name)} #{link_to t('notifications.post'), status_message_path(post), 'data-ref' => post.id, :class => 'hard_object_link'}".html_safe + if post + "#{translation(target_type, post.author.name)} #{link_to t('notifications.post'), status_message_path(post), 'data-ref' => post.id, :class => 'hard_object_link'}".html_safe + else + t('notifications.liked_post_deleted') + end else #Notifications:StartedSharing, etc. translation(target_type) end diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index dc3b552d7..d4aef7d9e 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -299,6 +299,7 @@ en: post: "post." deleted: "deleted" also_commented_deleted: "commented on a deleted post." + liked_post_deleted: "liked your deleted post." index: notifications: "Notifications" mark_all_as_read: "Mark All as Read" diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index b69b45b5a..3f33915dd 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -33,6 +33,18 @@ describe NotificationsHelper do output = object_link(@notification) output.should include t("#{@notification.popup_translation_key}") end + + context 'when post is deleted' do + it 'works' do + @post.destroy + expect{ object_link(@notification)}.should_not raise_error + end + + it 'displays that the post was deleted' do + @post.destroy + object_link(@notification).should == t('notifications.liked_post_deleted') + end + end end end end