mailhopper 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +4 -0
- data/lib/generators/mailhopper/templates/migrations/create_emails.rb +12 -4
- data/lib/mailhopper/queue.rb +13 -7
- data/lib/mailhopper/version.rb +1 -1
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/{20110801151741_create_emails.rb → 20110916191655_create_emails.rb} +11 -4
- data/test/dummy/db/schema.rb +4 -4
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +13 -0
- data/test/dummy/log/test.log +1584 -0
- data/test/unit/email_test.rb +66 -19
- metadata +6 -6
data/test/unit/email_test.rb
CHANGED
@@ -12,33 +12,80 @@ class EmailTest < ActiveSupport::TestCase
|
|
12
12
|
assert @email.valid?
|
13
13
|
end
|
14
14
|
|
15
|
-
should "be generated when mail is sent" do
|
15
|
+
should "be generated when mail is sent to individual addresses" do
|
16
16
|
headers = {
|
17
|
-
:from
|
18
|
-
:to
|
19
|
-
:cc
|
20
|
-
:bcc
|
17
|
+
:from => 'from@example.com',
|
18
|
+
:to => 'to@example.com',
|
19
|
+
:cc => 'cc@example.com',
|
20
|
+
:bcc => 'bcc@example.com',
|
21
21
|
:reply_to => 'reply_to@example.com',
|
22
|
-
:subject
|
22
|
+
:subject => 'Hiya!'
|
23
23
|
}
|
24
24
|
content = 'Papaya'
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
generate_and_verify_email(headers, content)
|
27
|
+
end
|
28
|
+
|
29
|
+
should "be generated when mail is sent to multiple addresses" do
|
30
|
+
headers = {
|
31
|
+
:from => 'from1@example.com',
|
32
|
+
:to => ['to1@example.com', 'to2@example.com'],
|
33
|
+
:cc => ['cc1@example.com', 'cc2@example.com'],
|
34
|
+
:bcc => ['bcc1@example.com', 'bcc2@example.com'],
|
35
|
+
:reply_to => 'reply_to@example.com',
|
36
|
+
:subject => 'Hiya!'
|
37
|
+
}
|
38
|
+
content = 'Papaya'
|
39
|
+
|
40
|
+
generate_and_verify_email(headers, content)
|
41
|
+
end
|
42
|
+
|
43
|
+
should "be generated when mail is sent to blank addresses" do
|
44
|
+
headers = {
|
45
|
+
:from => 'from@example.com',
|
46
|
+
:to => 'to@example.com',
|
47
|
+
:cc => nil,
|
48
|
+
:bcc => nil,
|
49
|
+
:reply_to => nil,
|
50
|
+
:subject => 'Hiya!'
|
51
|
+
}
|
52
|
+
content = 'Papaya'
|
53
|
+
|
54
|
+
generate_and_verify_email(headers, content)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def generate_and_verify_email(headers, content)
|
61
|
+
assert_equal Mailhopper::Email.count, 0
|
62
|
+
SampleMailer.hello(headers, content).deliver
|
63
|
+
assert_equal Mailhopper::Email.count, 1
|
29
64
|
|
30
|
-
|
31
|
-
assert_equal email.from_address, headers[:from]
|
32
|
-
assert_equal email.to_address, headers[:to]
|
33
|
-
assert_equal email.cc_address, headers[:cc]
|
34
|
-
assert_equal email.bcc_address, headers[:bcc]
|
35
|
-
assert_equal email.reply_to_address, headers[:reply_to]
|
36
|
-
assert_equal email.subject, headers[:subject]
|
65
|
+
email = Mailhopper::Email.first
|
37
66
|
|
38
|
-
|
39
|
-
|
67
|
+
assert_email_matches_headers(headers, email)
|
68
|
+
|
69
|
+
# Email content will include headers as well as content
|
70
|
+
assert email.content.include?(content)
|
71
|
+
|
72
|
+
assert email.sent_at.nil?
|
73
|
+
end
|
74
|
+
|
75
|
+
def assert_email_matches_headers(headers, email)
|
76
|
+
assert_address_matches_header headers[:from], email.from_address
|
77
|
+
assert_address_matches_header headers[:to], email.to_address
|
78
|
+
assert_address_matches_header headers[:cc], email.cc_address
|
79
|
+
assert_address_matches_header headers[:bcc], email.bcc_address
|
80
|
+
assert_equal headers[:reply_to], email.reply_to_address
|
81
|
+
assert_equal headers[:subject], email.subject
|
82
|
+
end
|
40
83
|
|
41
|
-
|
84
|
+
def assert_address_matches_header(header, address)
|
85
|
+
if header.kind_of? Array
|
86
|
+
assert_equal header.join(','), address
|
87
|
+
else
|
88
|
+
assert_equal header, address
|
42
89
|
end
|
43
90
|
end
|
44
91
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailhopper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dan Gebhardt
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-09-
|
18
|
+
date: 2011-09-16 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -113,7 +113,7 @@ files:
|
|
113
113
|
- test/dummy/config/routes.rb
|
114
114
|
- test/dummy/config.ru
|
115
115
|
- test/dummy/db/development.sqlite3
|
116
|
-
- test/dummy/db/migrate/
|
116
|
+
- test/dummy/db/migrate/20110916191655_create_emails.rb
|
117
117
|
- test/dummy/db/schema.rb
|
118
118
|
- test/dummy/db/test.sqlite3
|
119
119
|
- test/dummy/log/development.log
|
@@ -188,7 +188,7 @@ test_files:
|
|
188
188
|
- test/dummy/config/routes.rb
|
189
189
|
- test/dummy/config.ru
|
190
190
|
- test/dummy/db/development.sqlite3
|
191
|
-
- test/dummy/db/migrate/
|
191
|
+
- test/dummy/db/migrate/20110916191655_create_emails.rb
|
192
192
|
- test/dummy/db/schema.rb
|
193
193
|
- test/dummy/db/test.sqlite3
|
194
194
|
- test/dummy/log/development.log
|