Skip to content

Instantly share code, notes, and snippets.

@paulca
Created December 5, 2008 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulca/32404 to your computer and use it in GitHub Desktop.
Save paulca/32404 to your computer and use it in GitHub Desktop.
en:
emails:
signup_notification:
subject: "Your account on WEBSITE has been set up"
body: "Hi {{username}},
A new account has been set up for you on WEBSITE.
Here is your link to get started:
{{url}}
Regards,
WEBSITE
"
<%= t("emails.#{message}.body") %>
class Mailer < ActionMailer::Base
def email(message,user,params = {})
subject I18n.t("emails.#{message}.subject")
body params.merge({:message => message, :params => params})
end
protected
def setup_email(user)
recipients "#{user.email}"
from 'WEBSITE <admin@website.net>'
@sent_on = Time.now
@body[:user] = user
end
end
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Mailer do
before(:each) do
@user = mock_model(User, :email => 'test@test.com', :login => 'test')
@mailer = Mailer.create_email('signup_notification', @user, {:username => @user.login, :url => 'test.com'})
end
it "should load up the translation" do
@mailer.subject.should match(/WEBSITE/)
end
it "should have a body" do
@mailer.body.should match(/test.com/)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment