Commit 3e72f54e3e3e41e139faf39914ad141309a23f13
Exists in
master
and in
29 other branches
Merge branch 'bug_subdir_tasks' into 'master'
Fix subdir link when creating a new task. E-mails sent by the tasks of noosfero do not include the subdirectory in links correctly See merge request !516
Showing
2 changed files
with
33 additions
and
3 deletions
Show diff stats
app/mailers/task_mailer.rb
... | ... | @@ -5,7 +5,7 @@ class TaskMailer < ActionMailer::Base |
5 | 5 | @target = task.target.name |
6 | 6 | @environment = task.environment.name |
7 | 7 | @url = generate_environment_url(task, :controller => 'home') |
8 | - url_for_tasks_list = task.target.kind_of?(Environment) ? '' : url_for(task.target.tasks_url) | |
8 | + url_for_tasks_list = task.target.kind_of?(Environment) ? '' : url_for(task.target.tasks_url.merge(:script_name => Noosfero.root('/'))) | |
9 | 9 | @tasks_url = url_for_tasks_list |
10 | 10 | |
11 | 11 | mail( |
... | ... | @@ -56,7 +56,7 @@ class TaskMailer < ActionMailer::Base |
56 | 56 | end |
57 | 57 | |
58 | 58 | def generate_environment_url(task, url = {}) |
59 | - url_for(Noosfero.url_options.merge(:host => task.environment.default_hostname).merge(url)) | |
59 | + url_for(Noosfero.url_options.merge(:host => task.environment.default_hostname).merge(url).merge(:script_name => Noosfero.root('/'))) | |
60 | 60 | end |
61 | 61 | |
62 | 62 | end | ... | ... |
test/unit/task_mailer_test.rb
... | ... | @@ -119,7 +119,7 @@ class TaskMailerTest < ActiveSupport::TestCase |
119 | 119 | assert_match(/#{task.target_notification_description}/, mail.subject) |
120 | 120 | |
121 | 121 | assert_equal "Hello friend name, my name invite you, please follow this link: http://example.com/account/signup?invitation_code=123456", mail.body.to_s |
122 | - | |
122 | + | |
123 | 123 | mail.deliver |
124 | 124 | assert !ActionMailer::Base.deliveries.empty? |
125 | 125 | end |
... | ... | @@ -135,6 +135,36 @@ class TaskMailerTest < ActiveSupport::TestCase |
135 | 135 | assert_equal 'My name <email@example.com>', TaskMailer.generate_from(task) |
136 | 136 | end |
137 | 137 | |
138 | + should 'return the email with the subdirectory defined' do | |
139 | + Noosfero.stubs(:root).returns('/subdir') | |
140 | + | |
141 | + task = InviteFriend.new | |
142 | + task.expects(:code).returns('123456') | |
143 | + | |
144 | + task.stubs(:message).returns('Hello <friend>, <user> invite you, please follow this link: <url>') | |
145 | + task.expects(:friend_email).returns('friend@exemple.com') | |
146 | + task.expects(:friend_name).returns('friend name').at_least_once | |
147 | + | |
148 | + requestor = mock() | |
149 | + requestor.stubs(:name).returns('my name') | |
150 | + requestor.stubs(:public_profile_url).returns('requestor_path') | |
151 | + | |
152 | + environment = mock() | |
153 | + environment.expects(:noreply_email).returns('sender@example.com') | |
154 | + environment.expects(:default_hostname).returns('example.com') | |
155 | + environment.expects(:name).returns('example').at_least_once | |
156 | + | |
157 | + task.expects(:requestor).returns(requestor).at_least_once | |
158 | + task.expects(:person).returns(requestor).at_least_once | |
159 | + requestor.expects(:environment).returns(environment).at_least_once | |
160 | + task.expects(:environment).returns(environment).at_least_once | |
161 | + | |
162 | + mail = TaskMailer.invitation_notification(task) | |
163 | + | |
164 | + url_to_compare = "/subdir/account/signup" | |
165 | + | |
166 | + assert_match(/#{url_to_compare}/, mail.body.to_s) | |
167 | + end | |
138 | 168 | |
139 | 169 | private |
140 | 170 | def read_fixture(action) | ... | ... |