letter_opener 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 1.1.2 ##
|
2
|
+
|
3
|
+
* Show formatted display names in html template (thanks [ClaireMcGinty](https://github.com/ClaireMcGinty))
|
4
|
+
* Use `file:///` uri scheme to fix Launchy on Windows.
|
5
|
+
|
1
6
|
## 1.1.1 ##
|
2
7
|
|
3
8
|
* Handle cc and bcc as array of emails. (thanks [jordandcarter](https://github.com/jordandcarter))
|
@@ -12,7 +12,7 @@ module LetterOpener
|
|
12
12
|
def deliver!(mail)
|
13
13
|
location = File.join(settings[:location], "#{Time.now.to_i}_#{Digest::SHA1.hexdigest(mail.encoded)[0..6]}")
|
14
14
|
messages = Message.rendered_messages(location, mail)
|
15
|
-
Launchy.open("file
|
15
|
+
Launchy.open("file:///#{URI.parse(URI.escape(messages.first.filepath))}")
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -68,27 +68,27 @@ module LetterOpener
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def from
|
71
|
-
@from ||= Array(@mail
|
71
|
+
@from ||= Array(@mail['from']).join(", ")
|
72
72
|
end
|
73
73
|
|
74
74
|
def sender
|
75
|
-
@sender ||= Array(@mail
|
75
|
+
@sender ||= Array(@mail['sender']).join(", ")
|
76
76
|
end
|
77
77
|
|
78
78
|
def to
|
79
|
-
@to ||= Array(@mail
|
79
|
+
@to ||= Array(@mail['to']).join(", ")
|
80
80
|
end
|
81
81
|
|
82
82
|
def cc
|
83
|
-
@cc ||= Array(@mail
|
83
|
+
@cc ||= Array(@mail['cc']).join(", ")
|
84
84
|
end
|
85
85
|
|
86
86
|
def bcc
|
87
|
-
@bcc ||= Array(@mail
|
87
|
+
@bcc ||= Array(@mail['bcc']).join(", ")
|
88
88
|
end
|
89
89
|
|
90
90
|
def reply_to
|
91
|
-
@reply_to ||= Array(@mail
|
91
|
+
@reply_to ||= Array(@mail['reply-to']).join(", ")
|
92
92
|
end
|
93
93
|
|
94
94
|
def type
|
@@ -4,7 +4,7 @@ describe LetterOpener::DeliveryMethod do
|
|
4
4
|
let(:location) { File.expand_path('../../../tmp/letter_opener', __FILE__) }
|
5
5
|
|
6
6
|
let(:plain_file) { Dir["#{location}/*/plain.html"].first }
|
7
|
-
let(:plain) { File.read(plain_file) }
|
7
|
+
let(:plain) { CGI.unescape_html(File.read(plain_file)) }
|
8
8
|
|
9
9
|
before do
|
10
10
|
Launchy.stub(:open)
|
@@ -58,12 +58,12 @@ describe LetterOpener::DeliveryMethod do
|
|
58
58
|
Launchy.should_receive(:open)
|
59
59
|
|
60
60
|
Mail.deliver do
|
61
|
-
from 'Foo foo@example.com'
|
62
|
-
sender 'Baz baz@example.com'
|
63
|
-
reply_to 'No Reply no-reply@example.com'
|
64
|
-
to 'Bar bar@example.com'
|
65
|
-
cc 'Qux qux@example.com'
|
66
|
-
bcc 'Qux qux@example.com'
|
61
|
+
from 'Foo <foo@example.com>'
|
62
|
+
sender 'Baz <baz@example.com>'
|
63
|
+
reply_to 'No Reply <no-reply@example.com>'
|
64
|
+
to 'Bar <bar@example.com>'
|
65
|
+
cc 'Qux <qux@example.com>'
|
66
|
+
bcc 'Qux <qux@example.com>'
|
67
67
|
subject 'Hello'
|
68
68
|
body 'World! http://example.com'
|
69
69
|
end
|
@@ -74,19 +74,19 @@ describe LetterOpener::DeliveryMethod do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'saves From field' do
|
77
|
-
plain.should include("Foo foo@example.com")
|
77
|
+
plain.should include("Foo <foo@example.com>")
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'saves Sender field' do
|
81
|
-
plain.should include("Baz baz@example.com")
|
81
|
+
plain.should include("Baz <baz@example.com>")
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'saves Reply-to field' do
|
85
|
-
plain.should include("No Reply no-reply@example.com")
|
85
|
+
plain.should include("No Reply <no-reply@example.com>")
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'saves To field' do
|
89
|
-
plain.should include("Bar bar@example.com")
|
89
|
+
plain.should include("Bar <bar@example.com>")
|
90
90
|
end
|
91
91
|
|
92
92
|
it 'saves Subject field' do
|
@@ -100,7 +100,7 @@ describe LetterOpener::DeliveryMethod do
|
|
100
100
|
|
101
101
|
context 'multipart' do
|
102
102
|
let(:rich_file) { Dir["#{location}/*/rich.html"].first }
|
103
|
-
let(:rich) { File.read(rich_file) }
|
103
|
+
let(:rich) { CGI.unescape_html(File.read(rich_file)) }
|
104
104
|
|
105
105
|
before do
|
106
106
|
Launchy.should_receive(:open)
|
@@ -132,7 +132,7 @@ describe LetterOpener::DeliveryMethod do
|
|
132
132
|
end
|
133
133
|
|
134
134
|
it 'saves text part' do
|
135
|
-
plain.should include("This is
|
135
|
+
plain.should include("This is <plain> text")
|
136
136
|
end
|
137
137
|
|
138
138
|
it 'saves html part' do
|
@@ -140,11 +140,11 @@ describe LetterOpener::DeliveryMethod do
|
|
140
140
|
end
|
141
141
|
|
142
142
|
it 'saves escaped Subject field' do
|
143
|
-
plain.should include("Many parts with
|
143
|
+
plain.should include("Many parts with <html>")
|
144
144
|
end
|
145
145
|
|
146
146
|
it 'shows subject as title' do
|
147
|
-
rich.should include("<title>Many parts with
|
147
|
+
rich.should include("<title>Many parts with <html></title>")
|
148
148
|
end
|
149
149
|
end
|
150
150
|
end
|
@@ -156,7 +156,7 @@ describe LetterOpener::DeliveryMethod do
|
|
156
156
|
Launchy.should_receive(:open)
|
157
157
|
|
158
158
|
Mail.deliver do
|
159
|
-
from 'Foo foo@example.com'
|
159
|
+
from 'Foo <foo@example.com>'
|
160
160
|
to 'bar@example.com'
|
161
161
|
subject 'Hello'
|
162
162
|
body 'World!'
|
@@ -168,7 +168,7 @@ describe LetterOpener::DeliveryMethod do
|
|
168
168
|
end
|
169
169
|
|
170
170
|
it 'saves From filed' do
|
171
|
-
plain.should include("Foo foo@example.com")
|
171
|
+
plain.should include("Foo <foo@example.com>")
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
@@ -3,70 +3,149 @@ require 'spec_helper'
|
|
3
3
|
describe LetterOpener::Message do
|
4
4
|
let(:location) { File.expand_path('../../../tmp/letter_opener', __FILE__) }
|
5
5
|
|
6
|
+
def mail(options)
|
7
|
+
Mail.new(options)
|
8
|
+
end
|
9
|
+
|
6
10
|
describe '#reply_to' do
|
7
11
|
it 'handles one email as a string' do
|
8
|
-
|
12
|
+
mail = mail(:reply_to => 'test@example.com')
|
13
|
+
message = described_class.new(location, mail)
|
9
14
|
message.reply_to.should eq('test@example.com')
|
10
15
|
end
|
11
16
|
|
17
|
+
it 'handles one email with display names' do
|
18
|
+
mail = mail(:reply_to => 'test <test@example.com>')
|
19
|
+
message = described_class.new(location, mail)
|
20
|
+
message.reply_to.should eq('test <test@example.com>')
|
21
|
+
end
|
22
|
+
|
12
23
|
it 'handles array of emails' do
|
13
|
-
|
24
|
+
mail = mail(:reply_to => ['test1@example.com', 'test2@example.com'])
|
25
|
+
message = described_class.new(location, mail)
|
14
26
|
message.reply_to.should eq('test1@example.com, test2@example.com')
|
15
27
|
end
|
28
|
+
|
29
|
+
it 'handles array of emails with display names' do
|
30
|
+
mail = mail(:reply_to => ['test1 <test1@example.com>', 'test2 <test2@example.com>'])
|
31
|
+
message = described_class.new(location, mail)
|
32
|
+
message.reply_to.should eq('test1 <test1@example.com>, test2 <test2@example.com>')
|
33
|
+
end
|
34
|
+
|
16
35
|
end
|
17
36
|
|
18
37
|
describe '#to' do
|
19
38
|
it 'handles one email as a string' do
|
20
|
-
|
39
|
+
mail = mail(:to => 'test@example.com')
|
40
|
+
message = described_class.new(location, mail)
|
21
41
|
message.to.should eq('test@example.com')
|
22
42
|
end
|
23
43
|
|
44
|
+
it 'handles one email with display names' do
|
45
|
+
mail = mail(:to => 'test <test@example.com>')
|
46
|
+
message = described_class.new(location, mail)
|
47
|
+
message.to.should eq('test <test@example.com>')
|
48
|
+
end
|
49
|
+
|
24
50
|
it 'handles array of emails' do
|
25
|
-
|
51
|
+
mail = mail(:to => ['test1@example.com', 'test2@example.com'])
|
52
|
+
message = described_class.new(location, mail)
|
26
53
|
message.to.should eq('test1@example.com, test2@example.com')
|
27
54
|
end
|
55
|
+
|
56
|
+
it 'handles array of emails with display names' do
|
57
|
+
mail = mail(:to => ['test1 <test1@example.com>', 'test2 <test2@example.com>'])
|
58
|
+
message = described_class.new(location, mail)
|
59
|
+
message.to.should eq('test1 <test1@example.com>, test2 <test2@example.com>')
|
60
|
+
end
|
61
|
+
|
28
62
|
end
|
29
63
|
|
30
64
|
describe '#cc' do
|
31
65
|
it 'handles one cc email as a string' do
|
32
|
-
|
66
|
+
mail = mail(:cc => 'test@example.com')
|
67
|
+
message = described_class.new(location, mail)
|
33
68
|
message.cc.should eq('test@example.com')
|
34
69
|
end
|
35
70
|
|
71
|
+
it 'handles one cc email with display name' do
|
72
|
+
mail = mail(:cc => ['test <test1@example.com>', 'test2 <test2@example.com>'])
|
73
|
+
message = described_class.new(location, mail)
|
74
|
+
message.cc.should eq('test <test1@example.com>, test2 <test2@example.com>')
|
75
|
+
end
|
76
|
+
|
36
77
|
it 'handles array of cc emails' do
|
37
|
-
|
78
|
+
mail = mail(:cc => ['test1@example.com', 'test2@example.com'])
|
79
|
+
message = described_class.new(location, mail)
|
38
80
|
message.cc.should eq('test1@example.com, test2@example.com')
|
39
81
|
end
|
82
|
+
|
83
|
+
it 'handles array of cc emails with display names' do
|
84
|
+
mail = mail(:cc => ['test <test1@example.com>', 'test2 <test2@example.com>'])
|
85
|
+
message = described_class.new(location, mail)
|
86
|
+
message.cc.should eq('test <test1@example.com>, test2 <test2@example.com>')
|
87
|
+
end
|
88
|
+
|
40
89
|
end
|
41
90
|
|
42
91
|
describe '#bcc' do
|
43
92
|
it 'handles one bcc email as a string' do
|
44
|
-
|
93
|
+
mail = mail(:bcc => 'test@example.com')
|
94
|
+
message = described_class.new(location, mail)
|
45
95
|
message.bcc.should eq('test@example.com')
|
46
96
|
end
|
47
97
|
|
98
|
+
it 'handles one bcc email with display name' do
|
99
|
+
mail = mail(:bcc => ['test <test1@example.com>', 'test2 <test2@example.com>'])
|
100
|
+
message = described_class.new(location, mail)
|
101
|
+
message.bcc.should eq('test <test1@example.com>, test2 <test2@example.com>')
|
102
|
+
end
|
103
|
+
|
48
104
|
it 'handles array of bcc emails' do
|
49
|
-
|
105
|
+
mail = mail(:bcc => ['test1@example.com', 'test2@example.com'])
|
106
|
+
message = described_class.new(location, mail)
|
50
107
|
message.bcc.should eq('test1@example.com, test2@example.com')
|
51
108
|
end
|
109
|
+
|
110
|
+
it 'handles array of bcc emails with display names' do
|
111
|
+
mail = mail(:bcc => ['test <test1@example.com>', 'test2 <test2@example.com>'])
|
112
|
+
message = described_class.new(location, mail)
|
113
|
+
message.bcc.should eq('test <test1@example.com>, test2 <test2@example.com>')
|
114
|
+
end
|
115
|
+
|
52
116
|
end
|
53
117
|
|
54
118
|
describe '#sender' do
|
55
119
|
it 'handles one email as a string' do
|
56
|
-
|
120
|
+
mail = mail(:sender => 'sender@example.com')
|
121
|
+
message = described_class.new(location, mail)
|
57
122
|
message.sender.should eq('sender@example.com')
|
58
123
|
end
|
59
124
|
|
125
|
+
it 'handles one email as a string with display name' do
|
126
|
+
mail = mail(:sender => 'test <test@example.com>')
|
127
|
+
message = described_class.new(location, mail)
|
128
|
+
message.sender.should eq('test <test@example.com>')
|
129
|
+
end
|
130
|
+
|
60
131
|
it 'handles array of emails' do
|
61
|
-
|
132
|
+
mail = mail(:sender => ['sender1@example.com', 'sender2@example.com'])
|
133
|
+
message = described_class.new(location, mail)
|
62
134
|
message.sender.should eq('sender1@example.com, sender2@example.com')
|
63
135
|
end
|
136
|
+
|
137
|
+
it 'handles array of emails with display names' do
|
138
|
+
mail = mail(:sender => ['test <test1@example.com>', 'test2 <test2@example.com>'])
|
139
|
+
message = described_class.new(location, mail)
|
140
|
+
message.sender.should eq('test <test1@example.com>, test2 <test2@example.com>')
|
141
|
+
end
|
142
|
+
|
64
143
|
end
|
65
144
|
|
66
145
|
describe '#<=>' do
|
67
146
|
it 'sorts rich type before plain type' do
|
68
147
|
plain = described_class.new(location, mock(content_type: 'text/plain'))
|
69
|
-
rich
|
148
|
+
rich = described_class.new(location, mock(content_type: 'text/html'))
|
70
149
|
[plain, rich].sort.should eq([rich, plain])
|
71
150
|
end
|
72
151
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: letter_opener
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: launchy
|
@@ -93,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
93
|
version: '0'
|
94
94
|
segments:
|
95
95
|
- 0
|
96
|
-
hash:
|
96
|
+
hash: -3398976380396960324
|
97
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
98
|
none: false
|
99
99
|
requirements:
|