letter_opener 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.rdoc +1 -0
- data/lib/letter_opener.rb +1 -1
- data/lib/letter_opener/configuration.rb +1 -1
- data/lib/letter_opener/delivery_method.rb +2 -2
- data/lib/letter_opener/message.rb +8 -3
- data/spec/letter_opener/delivery_method_spec.rb +14 -1
- data/spec/letter_opener/message_spec.rb +18 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ef387f446fe58d7fbe039333d493cc644dbb388323e098f2b4a0a48dfad93ac
|
4
|
+
data.tar.gz: 3d6da1bcc7fa1d575e00d361677e36a73dfd26ea331416cfbb31c14cdd8f87ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62fc742943f4904086cfdddcd0908c7bb67fd602530e340852eb213644bce32e664e6da00058767fd80cfc8f13735e757e2d4fa32cb4459be74df8bdf7348030
|
7
|
+
data.tar.gz: 827cb033ed7805de3399f2c32427e69190a15420314d2f4ad6b4f3856a8209d6cbf0b0d5701ea6e47dd996fd919ef5e9185389df3b151ce24b3ad67a693492a6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## master ##
|
2
|
+
* Use default configuration in `Message::rendered_messages` (thanks [Krystan HuffMenne
|
3
|
+
](https://github.com/gitKrystan))
|
4
|
+
* Do not use `Rails.root` path if LetterOpener is used outside of Rails (thanks [centrevillage](https://github.com/centrevillage))
|
5
|
+
* Allow to set only `Mail#cc`/`Mail#bcc` without `Mail#to`.
|
6
|
+
|
1
7
|
## 1.6.0 ##
|
2
8
|
* Do not depend on Mail gem to check delivery params.
|
3
9
|
* Do not parse and escape url before passing it to Launchy.
|
data/README.rdoc
CHANGED
@@ -12,6 +12,7 @@ First add the gem to your development environment and run the +bundle+ command t
|
|
12
12
|
Then set the delivery method in <tt>config/environments/development.rb</tt>
|
13
13
|
|
14
14
|
config.action_mailer.delivery_method = :letter_opener
|
15
|
+
config.action_mailer.perform_deliveries = true
|
15
16
|
|
16
17
|
Now any email will pop up in your browser instead of being sent. The messages are stored in <tt>tmp/letter_opener</tt>.
|
17
18
|
If you want to change application that will be used to open your emails you should override <tt>LAUNCHY_APPLICATION</tt> environment variable or set <tt>Launchy.application</tt> in the initializer.
|
data/lib/letter_opener.rb
CHANGED
@@ -3,7 +3,7 @@ module LetterOpener
|
|
3
3
|
attr_accessor :location, :message_template
|
4
4
|
|
5
5
|
def initialize
|
6
|
-
@location = Rails.root.join('tmp', 'letter_opener') if defined?(Rails)
|
6
|
+
@location = Rails.root.join('tmp', 'letter_opener') if defined?(Rails) && Rails.respond_to?(:root)
|
7
7
|
@message_template = 'default'
|
8
8
|
end
|
9
9
|
end
|
@@ -27,11 +27,11 @@ module LetterOpener
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def validate_mail!(mail)
|
30
|
-
if !mail.
|
30
|
+
if !mail.smtp_envelope_from || mail.smtp_envelope_from.empty?
|
31
31
|
raise ArgumentError, "SMTP From address may not be blank"
|
32
32
|
end
|
33
33
|
|
34
|
-
if !mail.
|
34
|
+
if !mail.smtp_envelope_to || mail.smtp_envelope_to.empty?
|
35
35
|
raise ArgumentError, "SMTP To address may not be blank"
|
36
36
|
end
|
37
37
|
end
|
@@ -16,12 +16,17 @@ module LetterOpener
|
|
16
16
|
messages.sort
|
17
17
|
end
|
18
18
|
|
19
|
+
ERROR_MSG = '%s or default configuration must be given'.freeze
|
20
|
+
|
19
21
|
def initialize(mail, options = {})
|
20
22
|
@mail = mail
|
21
|
-
@location = options[:location]
|
23
|
+
@location = options[:location] || LetterOpener.configuration.location
|
22
24
|
@part = options[:part]
|
23
|
-
@template = options[:message_template]
|
25
|
+
@template = options[:message_template] || LetterOpener.configuration.message_template
|
24
26
|
@attachments = []
|
27
|
+
|
28
|
+
raise ArgumentError, ERROR_MSG % 'options[:location]' unless @location
|
29
|
+
raise ArgumentError, ERROR_MSG % 'options[:message_template]' unless @template
|
25
30
|
end
|
26
31
|
|
27
32
|
def render
|
@@ -114,7 +119,7 @@ module LetterOpener
|
|
114
119
|
end
|
115
120
|
|
116
121
|
def attachment_filename(attachment)
|
117
|
-
attachment.filename.gsub(/[^\w
|
122
|
+
attachment.filename.gsub(/[^\w\-.]/, '_')
|
118
123
|
end
|
119
124
|
|
120
125
|
def <=>(other)
|
@@ -316,7 +316,7 @@ describe LetterOpener::DeliveryMethod do
|
|
316
316
|
end
|
317
317
|
|
318
318
|
context 'delivery params' do
|
319
|
-
it 'raises an exception if
|
319
|
+
it 'raises an exception if there is no SMTP Envelope To value' do
|
320
320
|
expect(Launchy).not_to receive(:open)
|
321
321
|
|
322
322
|
expect {
|
@@ -327,6 +327,19 @@ describe LetterOpener::DeliveryMethod do
|
|
327
327
|
end
|
328
328
|
}.to raise_exception(ArgumentError)
|
329
329
|
end
|
330
|
+
|
331
|
+
it 'does not raise an exception if there is at least one SMTP Envelope To value' do
|
332
|
+
expect(Launchy).to receive(:open)
|
333
|
+
|
334
|
+
expect {
|
335
|
+
Mail.deliver do
|
336
|
+
from 'Foo foo@example.com'
|
337
|
+
cc 'Bar bar@example.com'
|
338
|
+
reply_to 'No Reply no-reply@example.com'
|
339
|
+
body 'World! http://example.com'
|
340
|
+
end
|
341
|
+
}.not_to raise_exception
|
342
|
+
end
|
330
343
|
end
|
331
344
|
|
332
345
|
context 'light template' do
|
@@ -201,4 +201,22 @@ describe LetterOpener::Message do
|
|
201
201
|
expect(message.body.encoding.name).to eq('UTF-8')
|
202
202
|
end
|
203
203
|
end
|
204
|
+
|
205
|
+
describe '.rendered_messages' do
|
206
|
+
it 'uses configured default template if options not given' do
|
207
|
+
allow(LetterOpener.configuration).to receive(:location) { location }
|
208
|
+
messages = described_class.rendered_messages(mail)
|
209
|
+
expect(messages.first.template).not_to be_nil
|
210
|
+
end
|
211
|
+
|
212
|
+
it 'fails if necessary defaults are not provided' do
|
213
|
+
allow(LetterOpener.configuration).to receive(:location) { nil }
|
214
|
+
expect { described_class.rendered_messages(mail) }.to raise_error(ArgumentError)
|
215
|
+
end
|
216
|
+
|
217
|
+
it 'fails if necessary defaults are not provided' do
|
218
|
+
allow(LetterOpener.configuration).to receive(:message_template) { nil }
|
219
|
+
expect { described_class.rendered_messages(mail) }.to raise_error(ArgumentError)
|
220
|
+
end
|
221
|
+
end
|
204
222
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: letter_opener
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: launchy
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: 1.3.4
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project: letter_opener
|
97
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.7.8
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: Preview mail in browser instead of sending.
|