Commit 5772f72c12deed6946cb1d75f632229ea97000a0
1 parent
bfdb9750
Exists in
master
and in
29 other branches
Add test for subdir to create mail and pass the right url
Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing
1 changed file
with
31 additions
and
1 deletions
Show diff stats
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) | ... | ... |