Guest User

Untitled

a guest
May 28th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. def test_create
  2.  
  3. num_deliveries = ActionMailer::Base.deliveries.size
  4. @user = User.new(:firstName=>'foo', :lastName=>'bar', :mail=>'a@b.com')
  5. assert @user.save!, @user.errors.full_messages.join("; ")
  6. assert_equal num_deliveries+1, ActionMailer::Base.deliveries.size
  7. end
  8.  
  9.  
  10. class User < ActiveRecord::Base
  11. before_create :sendMail
  12.  
  13. def sendMail
  14. email=RegistrationMailer.create_confirm(self)
  15. email.set_content_type("text/html")
  16. RegistrationMailer.deliver(email)
  17. end
  18.  
  19. end
  20.  
  21. class RegistrationMailer < ActionMailer::Base
  22.  
  23. def confirm(user, sent_at = Time.now)
  24. @subject = 'registration'
  25. @body["mail"] = user.mail
  26. @body["userid"] = user.id
  27. @body["password"] = user.password
  28. @from = 'noreply@xxx'
  29. @sent_on = sent_at
  30. @recipients = user.mail
  31. end
  32. end
Add Comment
Please, Sign In to add comment