/
fixtures.rb
90 lines (68 loc) · 1.32 KB
/
fixtures.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
class InvoiceMailer
include Lotus::Mailer
template 'invoice'
end
class RenderMailer
include Lotus::Mailer
end
class TemplateEngineMailer
include Lotus::Mailer
end
class CharsetMailer
include Lotus::Mailer
from 'noreply@example.com'
to 'user@example.com'
subject 'こんにちは'
end
class MissingFromMailer
include Lotus::Mailer
template 'missing'
to "recipient@example.com"
subject "Hello"
end
class MissingToMailer
include Lotus::Mailer
template 'missing'
from "sender@example.com"
subject "Hello"
end
class User < Struct.new(:name, :email); end
class LazyMailer
include Lotus::Mailer
end
class MethodMailer
include Lotus::Mailer
from :sender
to :recipient
subject :greeting
def greeting
"Hello, #{ user.name }"
end
private
def sender
"hello-#{ user.name.downcase }@example.com"
end
def recipient
user.email
end
end
class WelcomeMailer
include Lotus::Mailer
from "noreply@sender.com"
to ["noreply@recipient.com", "cc@recipient.com"]
subject "Welcome"
def greeting
"Ahoy"
end
def prepare
mail.attachments['invoice.pdf'] = '/path/to/invoice.pdf'
end
end
class MandrillDeliveryMethod
def initialize(options)
@options = options
end
def deliver!(mail)
@options.fetch(:deliveries).push(mail)
end
end