Commit d5ee444b8706624aa88fa621d58b5fe14d2cce3f
Committed by
Antonio Terceiro
1 parent
28545c9f
Exists in
master
and in
29 other branches
Show the correct url in scrap mail notification
(ActionItem1719)
Showing
3 changed files
with
20 additions
and
2 deletions
Show diff stats
app/models/scrap.rb
@@ -30,6 +30,10 @@ class Scrap < ActiveRecord::Base | @@ -30,6 +30,10 @@ class Scrap < ActiveRecord::Base | ||
30 | self.receiver.is_a?(Community) ? self.receiver : self | 30 | self.receiver.is_a?(Community) ? self.receiver : self |
31 | end | 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 | class Notifier < ActionMailer::Base | 37 | class Notifier < ActionMailer::Base |
34 | def mail(scrap) | 38 | def mail(scrap) |
35 | sender, receiver = scrap.sender, scrap.receiver | 39 | sender, receiver = scrap.sender, scrap.receiver |
@@ -41,7 +45,7 @@ class Scrap < ActiveRecord::Base | @@ -41,7 +45,7 @@ class Scrap < ActiveRecord::Base | ||
41 | :sender => sender.name, | 45 | :sender => sender.name, |
42 | :sender_link => sender.url, | 46 | :sender_link => sender.url, |
43 | :scrap_content => scrap.content, | 47 | :scrap_content => scrap.content, |
44 | - :wall_url => receiver.wall_url, | 48 | + :wall_url => scrap.scrap_wall_url, |
45 | :environment => sender.environment.name, | 49 | :environment => sender.environment.name, |
46 | :url => sender.environment.top_url | 50 | :url => sender.environment.top_url |
47 | end | 51 | end |
app/views/scrap/notifier/mail.rhtml
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | <%= word_wrap(@scrap_content) %> | 6 | <%= word_wrap(@scrap_content) %> |
7 | ------------------------------------------------------------------------------- | 7 | ------------------------------------------------------------------------------- |
8 | 8 | ||
9 | -<%= _('View this scrap on your wall:') %> | 9 | +<%= _('View this scrap on the wall'): %> |
10 | <%= url_for @wall_url %> | 10 | <%= url_for @wall_url %> |
11 | 11 | ||
12 | <%= _("Greetings,") %> | 12 | <%= _("Greetings,") %> |
test/unit/scrap_test.rb
@@ -258,4 +258,18 @@ class ScrapTest < ActiveSupport::TestCase | @@ -258,4 +258,18 @@ class ScrapTest < ActiveSupport::TestCase | ||
258 | assert_equal community, scrap.action_tracker_target | 258 | assert_equal community, scrap.action_tracker_target |
259 | end | 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 | end | 275 | end |