From 66c28c4caf3f9cdd2fbce9cdebe870bb91ac24d7 Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Sun, 22 May 2011 14:35:35 -0700 Subject: [PATCH] notification page now has links for likes --- app/helpers/notifications_helper.rb | 5 +++- spec/helpers/notifications_helper_spec.rb | 35 +++++++++++++++++------ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index dbe6098ac..b617c47ef 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -22,7 +22,10 @@ module NotificationsHelper else t('notifications.also_commented_deleted') end - else #Notifications:StartedSharing, Notifications::Liked, etc. + 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 + else #Notifications:StartedSharing, etc. translation(target_type) end end diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 70bfc2e58..b69b45b5a 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -2,20 +2,37 @@ require 'spec_helper' describe NotificationsHelper do + before do + @user = Factory(:user) + @person = Factory(:person) + @post = Factory(:status_message, :author => @user.person) + @person2 = Factory(:person) + @notification = Notification.notify(@user, Factory(:like, :author => @person, :post => @post), @person) + @notification = Notification.notify(@user, Factory(:like, :author => @person2, :post => @post), @person2) + + end describe '#notification_people_link' do describe 'for a like' do it 'displays #{list of actors}' do - @user = Factory(:user) - @person = Factory(:person) - p = Factory(:status_message, :author => @user.person) - person2 = Factory(:person) - notification = Notification.notify(@user, Factory(:like, :author => @person, :post => p), @person) - notification2 = Notification.notify(@user, Factory(:like, :author => person2, :post => p), person2) - - output = notification_people_link(notification2) - output.should include person2.name + output = notification_people_link(@notification) + output.should include @person2.name output.should include @person.name end end end + + + describe '#object_link' do + describe 'for a like' do + it 'should include a link to the post' do + output = object_link(@notification) + output.should include status_message_path(@post) + end + + it 'includes the boilerplate translation' do + output = object_link(@notification) + output.should include t("#{@notification.popup_translation_key}") + end + end + end end