Adding a signup confirmation email

This commit is contained in:
Will Marshall
2014-04-04 12:36:33 +13:00
parent 330b2100cc
commit b6c746f5b8
5 changed files with 55 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
Spree::UserMailer.class_eval do
def signup_confirmation(user)
@user = user
mail(:to => user.email, :from => from_address,
:subject => 'Welcome to ' + Spree::Config[:site_name])
end
end

View File

@@ -6,6 +6,7 @@ Spree.user_class.class_eval do
accepts_nested_attributes_for :enterprise_roles, :allow_destroy => true
attr_accessible :enterprise_ids, :enterprise_roles_attributes
after_create :send_signup_confirmation
def build_enterprise_roles
Enterprise.all.each do |enterprise|
@@ -14,4 +15,8 @@ Spree.user_class.class_eval do
end
end
end
def send_signup_confirmation
Spree::UserMailer.signup_confirmation(self).deliver
end
end

View File

@@ -0,0 +1,13 @@
Hello,
Welcome to Australia's Open Food Network! Your login email is <%= @user.email %>
You can go online and start shopping through food hubs and local producers you like at vic.openfoodnetwork.org.au
We welcome all your questions and feedback; you can use the Send Feedback button on the site or email us at hello@openfoodnetwork.org
Thanks for getting on board and we look forward to introducing you to many more great farmers, food hubs and food!
Cheers,
Kirsten Larsen and the OFN Team

View File

@@ -0,0 +1,20 @@
require 'spec_helper'
describe Spree::UserMailer do
let(:user) { build(:user) }
after do
ActionMailer::Base.deliveries.clear
end
before do
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.deliveries = []
end
it "sends an email when given a user" do
Spree::UserMailer.signup_confirmation(user).deliver
ActionMailer::Base.deliveries.count.should == 1
end
end

View File

@@ -0,0 +1,9 @@
describe Spree.user_class do
context "#create" do
it "should send a signup email" do
Spree::UserMailer.should_receive(:signup_confirmation).and_return(double(:deliver => true))
create(:user)
end
end
end