Commit bd06936c161872b3a8f784f52daeb700881baeb9

Authored by Victor Costa
1 parent 2bdb49ac

Set the asset host for person notifier mailing

app/helpers/person_notifier_helper.rb
@@ -1,15 +0,0 @@ @@ -1,15 +0,0 @@
1 -module PersonNotifierHelper  
2 -  
3 - include ApplicationHelper  
4 -  
5 - private  
6 -  
7 - def path_to_image(source)  
8 - top_url + source  
9 - end  
10 -  
11 - def top_url  
12 - top_url = @profile.environment ? @profile.environment.top_url : ''  
13 - end  
14 -  
15 -end  
app/models/person_notifier.rb
@@ -67,13 +67,15 @@ class PersonNotifier @@ -67,13 +67,15 @@ class PersonNotifier
67 67
68 class Mailer < ActionMailer::Base 68 class Mailer < ActionMailer::Base
69 69
70 - add_template_helper(PersonNotifierHelper) 70 + add_template_helper(ApplicationHelper)
71 71
72 def session 72 def session
73 {:theme => nil} 73 {:theme => nil}
74 end 74 end
75 75
76 def content_summary(person, notifications) 76 def content_summary(person, notifications)
  77 + ActionMailer::Base.asset_host = person.environment.top_url if person.environment
  78 +
77 @current_theme = 'default' 79 @current_theme = 'default'
78 @profile = person 80 @profile = person
79 @recipient = @profile.nickname || @profile.name 81 @recipient = @profile.nickname || @profile.name
test/unit/person_notifier_helper_test.rb
@@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
1 -require File.dirname(__FILE__) + '/../test_helper'  
2 -  
3 -class PersonNotifierHelperTest < ActionView::TestCase  
4 -  
5 - include PersonNotifierHelper  
6 -  
7 - def setup  
8 - @profile = mock  
9 - @env = Environment.new  
10 - end  
11 - attr_reader :profile, :env  
12 -  
13 - should 'append top url of environment at image path' do  
14 - profile.expects(:environment).returns(env).at_least_once  
15 - assert_match /src="http:\/\/localhost\/image.png"/, image_tag("/image.png")  
16 - end  
17 -  
18 - should 'return original path if do not have an environment' do  
19 - profile.expects(:environment).returns(nil).at_least_once  
20 - assert_match /src="\/image.png"/, image_tag("/image.png")  
21 - end  
22 -  
23 -end