[noosfero/noosfero][master] 3 commits: Fix subdir link when creating a new task.
Rodrigo Souto
gitlab at gitlab.com
Wed May 13 17:35:40 BRT 2015
Rodrigo Souto pushed to branch master at Noosfero / noosfero
Commits:
bfdb9750 by Gabriela Navarro at 2015-03-23T16:40:30Z
Fix subdir link when creating a new task.
Signed-off-by: Arthur Del Esposte <arthurmde at gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703 at gmail.com>
- - - - -
5772f72c by Gabriela Navarro at 2015-05-12T14:56:58Z
Add test for subdir to create mail and pass the right url
Signed-off-by: Arthur Del Esposte <arthurmde at gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703 at gmail.com>
- - - - -
3e72f54e by Rodrigo Souto at 2015-05-13T20:35:28Z
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
- - - - -
2 changed files:
- app/mailers/task_mailer.rb
- test/unit/task_mailer_test.rb
Changes:
=====================================
app/mailers/task_mailer.rb
=====================================
--- a/app/mailers/task_mailer.rb
+++ b/app/mailers/task_mailer.rb
@@ -5,7 +5,7 @@ class TaskMailer < ActionMailer::Base
@target = task.target.name
@environment = task.environment.name
@url = generate_environment_url(task, :controller => 'home')
- url_for_tasks_list = task.target.kind_of?(Environment) ? '' : url_for(task.target.tasks_url)
+ url_for_tasks_list = task.target.kind_of?(Environment) ? '' : url_for(task.target.tasks_url.merge(:script_name => Noosfero.root('/')))
@tasks_url = url_for_tasks_list
mail(
@@ -56,7 +56,7 @@ class TaskMailer < ActionMailer::Base
end
def generate_environment_url(task, url = {})
- url_for(Noosfero.url_options.merge(:host => task.environment.default_hostname).merge(url))
+ url_for(Noosfero.url_options.merge(:host => task.environment.default_hostname).merge(url).merge(:script_name => Noosfero.root('/')))
end
end
=====================================
test/unit/task_mailer_test.rb
=====================================
--- a/test/unit/task_mailer_test.rb
+++ b/test/unit/task_mailer_test.rb
@@ -119,7 +119,7 @@ class TaskMailerTest < ActiveSupport::TestCase
assert_match(/#{task.target_notification_description}/, mail.subject)
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
-
+
mail.deliver
assert !ActionMailer::Base.deliveries.empty?
end
@@ -135,6 +135,36 @@ class TaskMailerTest < ActiveSupport::TestCase
assert_equal 'My name <email at example.com>', TaskMailer.generate_from(task)
end
+ should 'return the email with the subdirectory defined' do
+ Noosfero.stubs(:root).returns('/subdir')
+
+ task = InviteFriend.new
+ task.expects(:code).returns('123456')
+
+ task.stubs(:message).returns('Hello <friend>, <user> invite you, please follow this link: <url>')
+ task.expects(:friend_email).returns('friend at exemple.com')
+ task.expects(:friend_name).returns('friend name').at_least_once
+
+ requestor = mock()
+ requestor.stubs(:name).returns('my name')
+ requestor.stubs(:public_profile_url).returns('requestor_path')
+
+ environment = mock()
+ environment.expects(:noreply_email).returns('sender at example.com')
+ environment.expects(:default_hostname).returns('example.com')
+ environment.expects(:name).returns('example').at_least_once
+
+ task.expects(:requestor).returns(requestor).at_least_once
+ task.expects(:person).returns(requestor).at_least_once
+ requestor.expects(:environment).returns(environment).at_least_once
+ task.expects(:environment).returns(environment).at_least_once
+
+ mail = TaskMailer.invitation_notification(task)
+
+ url_to_compare = "/subdir/account/signup"
+
+ assert_match(/#{url_to_compare}/, mail.body.to_s)
+ end
private
def read_fixture(action)
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/920a3d7348c02e2bfed57b646101c06ae166b7ff...3e72f54e3e3e41e139faf39914ad141309a23f13
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150513/d24bf976/attachment-0001.html>
More information about the Noosfero-dev
mailing list