letter_opener 1.1.0 → 1.1.1
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 1.1.1 ##
|
|
2
|
+
|
|
3
|
+
* Handle cc and bcc as array of emails. (thanks [jordandcarter](https://github.com/jordandcarter))
|
|
4
|
+
* Use `file://` uri scheme since Launcy can't open escaped URL without it. (thanks [Adrian2112](https://github.com/Adrian2112))
|
|
5
|
+
* Update Launchy dependency to `~> 2.2` (thanks [JeanMertz](https://github.com/JeanMertz))
|
|
6
|
+
* Change all nonword chars in filename of attachment to underscore so
|
|
7
|
+
it can be saved on all platforms. (thanks [phallstrom](https://github.com/phallstrom))
|
|
8
|
+
|
|
1
9
|
## 1.1.0 ##
|
|
2
10
|
|
|
3
11
|
* Update Launchy dependency to `~> 2.2.0` (thanks [webdevotion](https://github.com/webdevotion))
|
|
@@ -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(URI.escape(messages.first.filepath))
|
|
15
|
+
Launchy.open("file://#{URI.parse(URI.escape(messages.first.filepath))}")
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
end
|
|
@@ -79,14 +79,14 @@
|
|
|
79
79
|
<dd><%= h to %></dd>
|
|
80
80
|
<% end %>
|
|
81
81
|
|
|
82
|
-
<%
|
|
82
|
+
<% unless cc.empty? %>
|
|
83
83
|
<dt>CC:</dt>
|
|
84
|
-
<dd><%= h
|
|
84
|
+
<dd><%= h cc %></dd>
|
|
85
85
|
<% end %>
|
|
86
86
|
|
|
87
|
-
<%
|
|
87
|
+
<% unless bcc.empty? %>
|
|
88
88
|
<dt>BCC:</dt>
|
|
89
|
-
<dd><%= h
|
|
89
|
+
<dd><%= h bcc %></dd>
|
|
90
90
|
<% end %>
|
|
91
91
|
|
|
92
92
|
<% if @attachments.any? %>
|
|
@@ -27,13 +27,14 @@ module LetterOpener
|
|
|
27
27
|
attachments_dir = File.join(@location, 'attachments')
|
|
28
28
|
FileUtils.mkdir_p(attachments_dir)
|
|
29
29
|
mail.attachments.each do |attachment|
|
|
30
|
-
|
|
30
|
+
filename = attachment.filename.gsub(/[^\w.]/, '_')
|
|
31
|
+
path = File.join(attachments_dir, filename)
|
|
31
32
|
|
|
32
33
|
unless File.exists?(path) # true if other parts have already been rendered
|
|
33
34
|
File.open(path, 'wb') { |f| f.write(attachment.body.raw_source) }
|
|
34
35
|
end
|
|
35
36
|
|
|
36
|
-
@attachments << [attachment.filename, "attachments/#{URI.escape(
|
|
37
|
+
@attachments << [attachment.filename, "attachments/#{URI.escape(filename)}"]
|
|
37
38
|
end
|
|
38
39
|
end
|
|
39
40
|
|
|
@@ -78,6 +79,14 @@ module LetterOpener
|
|
|
78
79
|
@to ||= Array(@mail.to).join(", ")
|
|
79
80
|
end
|
|
80
81
|
|
|
82
|
+
def cc
|
|
83
|
+
@cc ||= Array(@mail.cc).join(", ")
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def bcc
|
|
87
|
+
@bcc ||= Array(@mail.bcc).join(", ")
|
|
88
|
+
end
|
|
89
|
+
|
|
81
90
|
def reply_to
|
|
82
91
|
@reply_to ||= Array(@mail.reply_to).join(", ")
|
|
83
92
|
end
|
|
@@ -21,6 +21,37 @@ describe LetterOpener::DeliveryMethod do
|
|
|
21
21
|
lambda { LetterOpener::DeliveryMethod.new(location: "foo") }.should_not raise_exception
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
context 'integration' do
|
|
25
|
+
before do
|
|
26
|
+
Launchy.unstub(:open)
|
|
27
|
+
ENV['LAUNCHY_DRY_RUN'] = 'true'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context 'normal location path' do
|
|
31
|
+
it 'opens email' do
|
|
32
|
+
expect {
|
|
33
|
+
Mail.deliver do
|
|
34
|
+
from 'Foo foo@example.com'
|
|
35
|
+
body 'World! http://example.com'
|
|
36
|
+
end
|
|
37
|
+
}.not_to raise_error(Launchy::ApplicationNotFoundError)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
context 'with spaces in location path' do
|
|
42
|
+
let(:location) { File.expand_path('../../../tmp/letter_opener with space', __FILE__) }
|
|
43
|
+
|
|
44
|
+
it 'opens email' do
|
|
45
|
+
expect {
|
|
46
|
+
Mail.deliver do
|
|
47
|
+
from 'Foo foo@example.com'
|
|
48
|
+
body 'World! http://example.com'
|
|
49
|
+
end
|
|
50
|
+
}.not_to raise_error(Launchy::ApplicationNotFoundError)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
24
55
|
context 'content' do
|
|
25
56
|
context 'plain' do
|
|
26
57
|
before do
|
|
@@ -31,6 +62,8 @@ describe LetterOpener::DeliveryMethod do
|
|
|
31
62
|
sender 'Baz baz@example.com'
|
|
32
63
|
reply_to 'No Reply no-reply@example.com'
|
|
33
64
|
to 'Bar bar@example.com'
|
|
65
|
+
cc 'Qux qux@example.com'
|
|
66
|
+
bcc 'Qux qux@example.com'
|
|
34
67
|
subject 'Hello'
|
|
35
68
|
body 'World! http://example.com'
|
|
36
69
|
end
|
|
@@ -225,6 +258,31 @@ describe LetterOpener::DeliveryMethod do
|
|
|
225
258
|
end
|
|
226
259
|
end
|
|
227
260
|
|
|
261
|
+
context 'attachments with non-word characters in the filename' do
|
|
262
|
+
before do
|
|
263
|
+
Mail.deliver do
|
|
264
|
+
from 'foo@example.com'
|
|
265
|
+
to 'bar@example.com'
|
|
266
|
+
subject 'With attachments'
|
|
267
|
+
text_part do
|
|
268
|
+
body 'This is <plain> text'
|
|
269
|
+
end
|
|
270
|
+
attachments['non word:chars/used,01.txt'] = File.read(__FILE__)
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
it 'creates attachments dir with attachment' do
|
|
275
|
+
attachment = Dir["#{location}/*/attachments/non_word_chars_used_01.txt"].first
|
|
276
|
+
File.exists?(attachment).should be_true
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
it 'saves attachment name' do
|
|
280
|
+
plain = File.read(Dir["#{location}/*/plain.html"].first)
|
|
281
|
+
plain.should include('non_word_chars_used_01.txt')
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
|
|
228
286
|
context 'subjectless mail' do
|
|
229
287
|
before do
|
|
230
288
|
Launchy.should_receive(:open)
|
|
@@ -27,6 +27,30 @@ describe LetterOpener::Message do
|
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
describe '#cc' do
|
|
31
|
+
it 'handles one cc email as a string' do
|
|
32
|
+
message = described_class.new(location, mock(cc: 'test@example.com'))
|
|
33
|
+
message.cc.should eq('test@example.com')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'handles array of cc emails' do
|
|
37
|
+
message = described_class.new(location, mock(cc: ['test1@example.com', 'test2@example.com']))
|
|
38
|
+
message.cc.should eq('test1@example.com, test2@example.com')
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe '#bcc' do
|
|
43
|
+
it 'handles one bcc email as a string' do
|
|
44
|
+
message = described_class.new(location, mock(bcc: 'test@example.com'))
|
|
45
|
+
message.bcc.should eq('test@example.com')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'handles array of bcc emails' do
|
|
49
|
+
message = described_class.new(location, mock(bcc: ['test1@example.com', 'test2@example.com']))
|
|
50
|
+
message.bcc.should eq('test1@example.com, test2@example.com')
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
30
54
|
describe '#sender' do
|
|
31
55
|
it 'handles one email as a string' do
|
|
32
56
|
message = described_class.new(location, mock(sender: 'sender@example.com'))
|
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.1
|
|
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-05-10 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: launchy
|
|
@@ -18,7 +18,7 @@ dependencies:
|
|
|
18
18
|
requirements:
|
|
19
19
|
- - ~>
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: 2.2
|
|
21
|
+
version: '2.2'
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -26,7 +26,7 @@ dependencies:
|
|
|
26
26
|
requirements:
|
|
27
27
|
- - ~>
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: 2.2
|
|
29
|
+
version: '2.2'
|
|
30
30
|
- !ruby/object:Gem::Dependency
|
|
31
31
|
name: rspec
|
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -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: 4228764792714323138
|
|
97
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
none: false
|
|
99
99
|
requirements:
|