mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Adding a signup confirmation email
This commit is contained in:
8
app/mailers/spree/user_mailer_decorator.rb
Normal file
8
app/mailers/spree/user_mailer_decorator.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
13
app/views/spree/user_mailer/signup_confirmation.text.erb
Normal file
13
app/views/spree/user_mailer/signup_confirmation.text.erb
Normal 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
|
||||
|
||||
20
spec/mailers/user_mailer_spec.rb
Normal file
20
spec/mailers/user_mailer_spec.rb
Normal 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
|
||||
9
spec/models/spree/user_spec.rb
Normal file
9
spec/models/spree/user_spec.rb
Normal 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
|
||||
Reference in New Issue
Block a user