diff --git a/app/models/scrap.rb b/app/models/scrap.rb index 065de4d..ea1acc2 100644 --- a/app/models/scrap.rb +++ b/app/models/scrap.rb @@ -30,6 +30,10 @@ class Scrap < ActiveRecord::Base self.receiver.is_a?(Community) ? self.receiver : self end + def scrap_wall_url + self.root.nil? ? self.receiver.wall_url : self.root.receiver.wall_url + end + class Notifier < ActionMailer::Base def mail(scrap) sender, receiver = scrap.sender, scrap.receiver @@ -41,7 +45,7 @@ class Scrap < ActiveRecord::Base :sender => sender.name, :sender_link => sender.url, :scrap_content => scrap.content, - :wall_url => receiver.wall_url, + :wall_url => scrap.scrap_wall_url, :environment => sender.environment.name, :url => sender.environment.top_url end diff --git a/app/views/scrap/notifier/mail.rhtml b/app/views/scrap/notifier/mail.rhtml index e7efff8..0c00eba 100644 --- a/app/views/scrap/notifier/mail.rhtml +++ b/app/views/scrap/notifier/mail.rhtml @@ -6,7 +6,7 @@ <%= word_wrap(@scrap_content) %> ------------------------------------------------------------------------------- -<%= _('View this scrap on your wall:') %> +<%= _('View this scrap on the wall'): %> <%= url_for @wall_url %> <%= _("Greetings,") %> diff --git a/test/unit/scrap_test.rb b/test/unit/scrap_test.rb index f4253b0..b0173d1 100644 --- a/test/unit/scrap_test.rb +++ b/test/unit/scrap_test.rb @@ -258,4 +258,18 @@ class ScrapTest < ActiveSupport::TestCase assert_equal community, scrap.action_tracker_target end + should 'scrap wall url be the root scrap receiver url if it is a reply' do + p1, p2 = fast_create(Person), fast_create(Person) + r = Scrap.create! :sender => p1, :receiver => p2, :content => "Hello!" + s = Scrap.new :sender => p2, :receiver => p1, :content => "Hi!" + r.replies << s; s.reload + assert_equal s.scrap_wall_url, s.root.receiver.wall_url + end + + should 'scrap wall url be the scrap receiver url if it is not a reply' do + p1, p2 = fast_create(Person), fast_create(Person) + s = Scrap.create! :sender => p1, :receiver => p2, :content => "Hello!" + assert_equal s.scrap_wall_url, s.receiver.wall_url + end + end -- libgit2 0.21.2