letter_opener 1.3.0 → 1.4.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 +4 -0
- data/README.rdoc +1 -1
- data/letter_opener.gemspec +19 -0
- data/lib/letter_opener/delivery_method.rb +9 -0
- data/lib/letter_opener/message.rb +6 -1
- data/spec/letter_opener/delivery_method_spec.rb +16 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c17edf454562b845730e2bc785489ab61cc5d2a9
|
4
|
+
data.tar.gz: 9103feb34675d63486efea05fbb3cb0bcdc12ec0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0de0bce58674322df7867f93fdf3b01795c399bdec2dc68fc027ce299f656936159f6091a2063cc90cd1b0baf64ba0d1cd3e4e89d983ddb766265b10baf4f8b8
|
7
|
+
data.tar.gz: 1627f2a90df1e62f402cf015dd5ca8cb75049008f5afbea38bb96855408236e9abf2d0d91c364e3d35ff2f4c6090b2356893bcc5b838beab24589bd1fc2bde5a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 1.4.0 ##
|
2
|
+
* Add base tag to the iframe so links work with X-Frame-Options set to SAMEORIGIN. (thanks [Jason Tokoph](https://github.com/jtokoph))
|
3
|
+
* Check delivery params before rendering an email to match SMTP behaviour.
|
4
|
+
|
1
5
|
## 1.3.0 ##
|
2
6
|
|
3
7
|
* Fix message body encoding is observed correctly in QP CTE. (thanks [Mark Dodwell](https://github.com/mkdynamic))
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Letter Opener {<img src="https://secure.travis-ci.org/ryanb/letter_opener.png" />}[http://travis-ci.org/ryanb/letter_opener]
|
2
2
|
|
3
|
-
Preview email in the browser instead of sending it. This means you do not need to set up email delivery in your development environment, and you no longer need to worry about accidentally sending a test email to someone else's address.
|
3
|
+
Preview email in the default browser instead of sending it. This means you do not need to set up email delivery in your development environment, and you no longer need to worry about accidentally sending a test email to someone else's address.
|
4
4
|
|
5
5
|
|
6
6
|
== Rails Setup
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "letter_opener"
|
3
|
+
s.version = "1.4.0"
|
4
|
+
s.author = "Ryan Bates"
|
5
|
+
s.email = "ryan@railscasts.com"
|
6
|
+
s.homepage = "http://github.com/ryanb/letter_opener"
|
7
|
+
s.summary = "Preview mail in browser instead of sending."
|
8
|
+
s.description = "When mail is sent from your application, Letter Opener will open a preview in the browser instead of sending."
|
9
|
+
|
10
|
+
s.files = Dir["{lib,spec}/**/*", "[A-Z]*"] - ["Gemfile.lock"]
|
11
|
+
s.require_path = "lib"
|
12
|
+
|
13
|
+
s.add_dependency 'launchy', '~> 2.2'
|
14
|
+
s.add_development_dependency 'rspec', '~> 2.14.0'
|
15
|
+
s.add_development_dependency 'mail', '~> 2.6.0'
|
16
|
+
|
17
|
+
s.rubyforge_project = s.name
|
18
|
+
s.required_rubygems_version = ">= 1.3.4"
|
19
|
+
end
|
@@ -1,5 +1,12 @@
|
|
1
|
+
begin
|
2
|
+
require 'mail/check_delivery_params'
|
3
|
+
rescue LoadError => e
|
4
|
+
end
|
5
|
+
|
1
6
|
module LetterOpener
|
2
7
|
class DeliveryMethod
|
8
|
+
include Mail::CheckDeliveryParams if defined?(Mail::CheckDeliveryParams)
|
9
|
+
|
3
10
|
class InvalidOption < StandardError; end
|
4
11
|
|
5
12
|
attr_accessor :settings
|
@@ -10,6 +17,8 @@ module LetterOpener
|
|
10
17
|
end
|
11
18
|
|
12
19
|
def deliver!(mail)
|
20
|
+
check_delivery_params(mail) if respond_to?(:check_delivery_params)
|
21
|
+
|
13
22
|
location = File.join(settings[:location], "#{Time.now.to_i}_#{Digest::SHA1.hexdigest(mail.encoded)[0..6]}")
|
14
23
|
messages = Message.rendered_messages(location, mail)
|
15
24
|
Launchy.open("file:///#{URI.parse(URI.escape(messages.first.filepath))}")
|
@@ -63,7 +63,7 @@ module LetterOpener
|
|
63
63
|
body.gsub!(attachment.url, "attachments/#{attachment.filename}")
|
64
64
|
end
|
65
65
|
|
66
|
-
body
|
66
|
+
base_tag + body
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -99,6 +99,11 @@ module LetterOpener
|
|
99
99
|
body.respond_to?(:encoding) ? body.encoding : "utf-8"
|
100
100
|
end
|
101
101
|
|
102
|
+
# To make links work in iframe with X-Frame-Options set to SAMEORIGIN
|
103
|
+
def base_tag
|
104
|
+
'<base target="_top">'
|
105
|
+
end
|
106
|
+
|
102
107
|
def auto_link(text)
|
103
108
|
text.gsub(URI.regexp(%W[https http])) do |link|
|
104
109
|
"<a href=\"#{ link }\">#{ link }</a>"
|
@@ -32,6 +32,7 @@ describe LetterOpener::DeliveryMethod do
|
|
32
32
|
expect($stdout).to receive(:puts)
|
33
33
|
expect {
|
34
34
|
Mail.deliver do
|
35
|
+
to 'Bar bar@example.com'
|
35
36
|
from 'Foo foo@example.com'
|
36
37
|
body 'World! http://example.com'
|
37
38
|
end
|
@@ -46,6 +47,7 @@ describe LetterOpener::DeliveryMethod do
|
|
46
47
|
expect($stdout).to receive(:puts)
|
47
48
|
expect {
|
48
49
|
Mail.deliver do
|
50
|
+
to 'Bar bar@example.com'
|
49
51
|
from 'Foo foo@example.com'
|
50
52
|
body 'World! http://example.com'
|
51
53
|
end
|
@@ -284,7 +286,6 @@ describe LetterOpener::DeliveryMethod do
|
|
284
286
|
end
|
285
287
|
end
|
286
288
|
|
287
|
-
|
288
289
|
context 'subjectless mail' do
|
289
290
|
before do
|
290
291
|
expect(Launchy).to receive(:open)
|
@@ -301,4 +302,18 @@ describe LetterOpener::DeliveryMethod do
|
|
301
302
|
expect(File.exist?(plain_file)).to be_true
|
302
303
|
end
|
303
304
|
end
|
305
|
+
|
306
|
+
context 'delivery params' do
|
307
|
+
it 'raises an exception if delivery params are not valid' do
|
308
|
+
expect(Launchy).not_to receive(:open)
|
309
|
+
|
310
|
+
expect {
|
311
|
+
Mail.deliver do
|
312
|
+
from 'Foo foo@example.com'
|
313
|
+
reply_to 'No Reply no-reply@example.com'
|
314
|
+
body 'World! http://example.com'
|
315
|
+
end
|
316
|
+
}.to raise_exception(ArgumentError)
|
317
|
+
end
|
318
|
+
end
|
304
319
|
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.4.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:
|
11
|
+
date: 2015-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: launchy
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
47
|
+
version: 2.6.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
54
|
+
version: 2.6.0
|
55
55
|
description: When mail is sent from your application, Letter Opener will open a preview
|
56
56
|
in the browser instead of sending.
|
57
57
|
email: ryan@railscasts.com
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- LICENSE
|
65
65
|
- README.rdoc
|
66
66
|
- Rakefile
|
67
|
+
- letter_opener.gemspec
|
67
68
|
- lib/letter_opener.rb
|
68
69
|
- lib/letter_opener/delivery_method.rb
|
69
70
|
- lib/letter_opener/message.html.erb
|
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
92
|
version: 1.3.4
|
92
93
|
requirements: []
|
93
94
|
rubyforge_project: letter_opener
|
94
|
-
rubygems_version: 2.
|
95
|
+
rubygems_version: 2.4.6
|
95
96
|
signing_key:
|
96
97
|
specification_version: 4
|
97
98
|
summary: Preview mail in browser instead of sending.
|