Created
December 5, 2008 17:03
-
-
Save paulca/32404 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= t("emails.#{message}.body") %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <[email protected]>' | |
@sent_on = Time.now | |
@body[:user] = user | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | |
describe Mailer do | |
before(:each) do | |
@user = mock_model(User, :email => '[email protected]', :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