1 require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
2 require File.join( File.dirname(__FILE__), "..", "user_spec_helper")
3 require File.join( File.dirname(__FILE__), "..", "authenticated_system_spec_helper")
7 def deliver(action, mail_opts= {}, opts = {})
8 UserMailer.dispatch_and_deliver(action, mail_opts, opts)
9 @delivery = Merb::Mailer.deliveries.last
13 @u = User.new(:email => "homer@simpsons.com", :login => "homer", :activation_code => "12345")
14 @mailer_params = { :from => "info@mysite.com",
16 :subject => "Welcome to MySite.com" }
20 Merb::Mailer.deliveries.clear
23 it "should send mail to homer@simpsons.com for the signup email" do
24 deliver(:signup_notification, @mailer_params, :user => @u)
25 @delivery.assigns(:headers).should include("to: homer@simpsons.com")
28 it "should send the mail from 'info@mysite.com' for the signup email" do
29 deliver(:signup_notification, @mailer_params, :user => @u)
30 @delivery.assigns(:headers).should include("from: info@mysite.com")
33 it "should mention the users login in the text signup mail" do
34 deliver(:signup_notification, @mailer_params, :user => @u)
35 @delivery.text.should include(@u.login)
38 it "should mention the users login in the HTML signup mail" do
39 deliver(:signup_notification, @mailer_params, :user => @u)
40 @delivery.html.should include(@u.login)
43 it "should mention the activation link in the signup emails" do
44 deliver(:signup_notification, @mailer_params, :user => @u)
45 the_url = UserMailer.new.url(:user_activation, :activation_code => @u.activation_code)
46 the_url.should_not be_nil
47 @delivery.text.should include( the_url )
48 @delivery.html.should include( the_url )
51 it "should send mail to homer@simpson.com for the activation email" do
52 deliver(:activation_notification, @mailer_params, :user => @u)
53 @delivery.assigns(:headers).should include("to: homer@simpsons.com")
56 it "should send the mail from 'info@mysite.com' for the activation email" do
57 deliver(:activation_notification, @mailer_params, :user => @u)
58 @delivery.assigns(:headers).should include("from: info@mysite.com")
61 it "should mention ther users login in the text activation mail" do
62 deliver(:activation_notification, @mailer_params, :user => @u)
63 @delivery.text.should include(@u.login)
66 it "should mention the users login in the html activation mail" do
67 deliver(:activation_notification, @mailer_params, :user => @u)
68 @delivery.html.should include(@u.login)