Commit d5ee444b8706624aa88fa621d58b5fe14d2cce3f

Authored by Caio SBA
Committed by Antonio Terceiro
1 parent 28545c9f

Show the correct url in scrap mail notification

(ActionItem1719)
app/models/scrap.rb
... ... @@ -30,6 +30,10 @@ class Scrap < ActiveRecord::Base
30 30 self.receiver.is_a?(Community) ? self.receiver : self
31 31 end
32 32  
  33 + def scrap_wall_url
  34 + self.root.nil? ? self.receiver.wall_url : self.root.receiver.wall_url
  35 + end
  36 +
33 37 class Notifier < ActionMailer::Base
34 38 def mail(scrap)
35 39 sender, receiver = scrap.sender, scrap.receiver
... ... @@ -41,7 +45,7 @@ class Scrap &lt; ActiveRecord::Base
41 45 :sender => sender.name,
42 46 :sender_link => sender.url,
43 47 :scrap_content => scrap.content,
44   - :wall_url => receiver.wall_url,
  48 + :wall_url => scrap.scrap_wall_url,
45 49 :environment => sender.environment.name,
46 50 :url => sender.environment.top_url
47 51 end
... ...
app/views/scrap/notifier/mail.rhtml
... ... @@ -6,7 +6,7 @@
6 6 <%= word_wrap(@scrap_content) %>
7 7 -------------------------------------------------------------------------------
8 8  
9   -<%= _('View this scrap on your wall:') %>
  9 +<%= _('View this scrap on the wall'): %>
10 10 <%= url_for @wall_url %>
11 11  
12 12 <%= _("Greetings,") %>
... ...
test/unit/scrap_test.rb
... ... @@ -258,4 +258,18 @@ class ScrapTest &lt; ActiveSupport::TestCase
258 258 assert_equal community, scrap.action_tracker_target
259 259 end
260 260  
  261 + should 'scrap wall url be the root scrap receiver url if it is a reply' do
  262 + p1, p2 = fast_create(Person), fast_create(Person)
  263 + r = Scrap.create! :sender => p1, :receiver => p2, :content => "Hello!"
  264 + s = Scrap.new :sender => p2, :receiver => p1, :content => "Hi!"
  265 + r.replies << s; s.reload
  266 + assert_equal s.scrap_wall_url, s.root.receiver.wall_url
  267 + end
  268 +
  269 + should 'scrap wall url be the scrap receiver url if it is not a reply' do
  270 + p1, p2 = fast_create(Person), fast_create(Person)
  271 + s = Scrap.create! :sender => p1, :receiver => p2, :content => "Hello!"
  272 + assert_equal s.scrap_wall_url, s.receiver.wall_url
  273 + end
  274 +
261 275 end
... ...