Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def test_create
- num_deliveries = ActionMailer::Base.deliveries.size
- @user = User.new(:firstName=>'foo', :lastName=>'bar', :mail=>'a@b.com')
- assert @user.save!, @user.errors.full_messages.join("; ")
- assert_equal num_deliveries+1, ActionMailer::Base.deliveries.size
- end
- class User < ActiveRecord::Base
- before_create :sendMail
- def sendMail
- email=RegistrationMailer.create_confirm(self)
- email.set_content_type("text/html")
- RegistrationMailer.deliver(email)
- end
- end
- class RegistrationMailer < ActionMailer::Base
- def confirm(user, sent_at = Time.now)
- @subject = 'registration'
- @body["mail"] = user.mail
- @body["userid"] = user.id
- @body["password"] = user.password
- @from = 'noreply@xxx'
- @sent_on = sent_at
- @recipients = user.mail
- end
- end
Add Comment
Please, Sign In to add comment