Commit 2020d549dc9bad1221925e76f8fb20df3953da0d
1 parent
6cee467c
Exists in
staging
and in
6 other branches
Fix resend activation code for users
Showing
4 changed files
with
18 additions
and
2 deletions
Show diff stats
app/models/user.rb
lib/noosfero/api/session.rb
test/unit/api/session_test.rb
... | ... | @@ -218,7 +218,22 @@ class SessionTest < ActiveSupport::TestCase |
218 | 218 | post "/api/v1/resend_activation_code?#{params.to_query}" |
219 | 219 | process_delayed_job_queue |
220 | 220 | end |
221 | + json = JSON.parse(last_response.body) | |
222 | + assert !json['users'].first['activated'] | |
221 | 223 | assert_equal user.email, ActionMailer::Base.deliveries.last['to'].to_s |
222 | 224 | end |
223 | 225 | |
226 | + should 'not resend activation code for an active user' do | |
227 | + user = create_user | |
228 | + params = {:value => user.login} | |
229 | + user.activate | |
230 | + Delayed::Job.destroy_all | |
231 | + assert_no_difference 'ActionMailer::Base.deliveries.size' do | |
232 | + post "/api/v1/resend_activation_code?#{params.to_query}" | |
233 | + process_delayed_job_queue | |
234 | + end | |
235 | + json = JSON.parse(last_response.body) | |
236 | + assert json['users'].first['activated'] | |
237 | + end | |
238 | + | |
224 | 239 | end | ... | ... |
test/unit/user_test.rb
... | ... | @@ -764,7 +764,7 @@ class UserTest < ActiveSupport::TestCase |
764 | 764 | user.resend_activation_code |
765 | 765 | process_delayed_job_queue |
766 | 766 | end |
767 | - assert_not_equal activation_code, user.activation_code | |
767 | + assert_not_equal activation_code, user.reload.activation_code | |
768 | 768 | assert_equal 'pending@activation.com', ActionMailer::Base.deliveries.last['to'].to_s |
769 | 769 | end |
770 | 770 | ... | ... |