recipient_interceptor 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/recipient_interceptor.rb +5 -11
- data/spec/recipient_interceptor_spec.rb +31 -18
- metadata +13 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9f74cc3d2d3870b44de76ddd8a972a7b4d004e6accb48e59f678913964fc34e7
|
4
|
+
data.tar.gz: 693e37753d4dfd1decf906bdc4f5130eef84d5d42c5042425f2e952421cd4262
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df47fd1c7e1637c8ebad24f7199f979796b6c94cfc305b76cd5f10e2fd1c2e3691136ae97098f1d918ee31e9574d43eb721624babfea363619c7bc91303ace70
|
7
|
+
data.tar.gz: 74bda5ffcdb7027fed64065ebee0a9013ad3c4fa0c2b796689069a5c2228400adbc8cdcdd8abc2f41a68150a53423139e3ee60d169ce9056b54436207cf601e2
|
@@ -10,8 +10,8 @@ class RecipientInterceptor
|
|
10
10
|
add_custom_headers message
|
11
11
|
add_subject_prefix message
|
12
12
|
message.to = @recipients
|
13
|
-
message.cc =
|
14
|
-
message.bcc =
|
13
|
+
message.cc = nil if message.cc
|
14
|
+
message.bcc = nil if message.bcc
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
@@ -31,14 +31,8 @@ class RecipientInterceptor
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def add_custom_headers(message)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
'X-Intercepted-Bcc' => message.bcc || []
|
38
|
-
}.each do |header, addresses|
|
39
|
-
addresses.each do |address|
|
40
|
-
message.header = "#{message.header}#{header}: #{address}"
|
41
|
-
end
|
42
|
-
end
|
34
|
+
message.header['X-Intercepted-To'] = message.to || []
|
35
|
+
message.header['X-Intercepted-Cc' ] = message.cc || []
|
36
|
+
message.header['X-Intercepted-Bcc' ] = message.bcc || []
|
43
37
|
end
|
44
38
|
end
|
@@ -1,14 +1,37 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'recipient_interceptor')
|
2
2
|
|
3
3
|
describe RecipientInterceptor do
|
4
|
+
before do
|
5
|
+
Mail.defaults do
|
6
|
+
delivery_method :test
|
7
|
+
end
|
8
|
+
|
9
|
+
module Mail
|
10
|
+
@@delivery_interceptors = []
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
4
14
|
it 'overrides to/cc/bcc fields' do
|
5
15
|
Mail.register_interceptor RecipientInterceptor.new(recipient_string)
|
6
16
|
|
7
17
|
response = deliver_mail
|
8
18
|
|
9
19
|
expect(response.to).to eq [recipient_string]
|
10
|
-
expect(response.cc).to eq
|
11
|
-
expect(response.bcc).to eq
|
20
|
+
expect(response.cc).to eq nil
|
21
|
+
expect(response.bcc).to eq nil
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'overrides to/cc/bcc correctly even if they were already missing' do
|
25
|
+
Mail.register_interceptor RecipientInterceptor.new(recipient_string)
|
26
|
+
|
27
|
+
response = Mail.deliver do
|
28
|
+
from 'original.from@example.com'
|
29
|
+
to 'original.to@example.com'
|
30
|
+
end
|
31
|
+
|
32
|
+
expect(response.to).to eq [recipient_string]
|
33
|
+
expect(response.cc).to eq nil
|
34
|
+
expect(response.bcc).to eq nil
|
12
35
|
end
|
13
36
|
|
14
37
|
it 'copies original to/cc/bcc fields to custom headers' do
|
@@ -16,12 +39,12 @@ describe RecipientInterceptor do
|
|
16
39
|
|
17
40
|
response = deliver_mail
|
18
41
|
|
19
|
-
expect(custom_header(response, 'X-Intercepted-To'))
|
20
|
-
to eq 'original.to@example.com'
|
21
|
-
expect(custom_header(response, 'X-Intercepted-Cc'))
|
22
|
-
to eq 'original.cc@example.com'
|
23
|
-
expect(custom_header(response, 'X-Intercepted-Bcc'))
|
24
|
-
to eq 'original.bcc@example.com'
|
42
|
+
expect(custom_header(response, 'X-Intercepted-To'))
|
43
|
+
.to eq 'original.to@example.com'
|
44
|
+
expect(custom_header(response, 'X-Intercepted-Cc'))
|
45
|
+
.to eq 'original.cc@example.com'
|
46
|
+
expect(custom_header(response, 'X-Intercepted-Bcc'))
|
47
|
+
.to eq 'original.bcc@example.com'
|
25
48
|
end
|
26
49
|
|
27
50
|
it 'accepts an array of recipients' do
|
@@ -68,10 +91,6 @@ describe RecipientInterceptor do
|
|
68
91
|
end
|
69
92
|
|
70
93
|
def deliver_mail
|
71
|
-
Mail.defaults do
|
72
|
-
delivery_method :test
|
73
|
-
end
|
74
|
-
|
75
94
|
Mail.deliver do
|
76
95
|
from 'original.from@example.com'
|
77
96
|
to 'original.to@example.com'
|
@@ -90,10 +109,4 @@ describe RecipientInterceptor do
|
|
90
109
|
header.to_s
|
91
110
|
end
|
92
111
|
end
|
93
|
-
|
94
|
-
after do
|
95
|
-
module Mail
|
96
|
-
@@delivery_interceptors = []
|
97
|
-
end
|
98
|
-
end
|
99
112
|
end
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recipient_interceptor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Croak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '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
54
|
version: '0'
|
55
55
|
description: |2
|
@@ -57,7 +57,7 @@ description: |2
|
|
57
57
|
accidentally send emails to addresses other than those on a whitelist
|
58
58
|
which you configure. For example, you could use it in your web app's
|
59
59
|
staging environment.
|
60
|
-
email: dan@
|
60
|
+
email: dan@statusok.com
|
61
61
|
executables: []
|
62
62
|
extensions: []
|
63
63
|
extra_rdoc_files: []
|
@@ -65,8 +65,7 @@ files:
|
|
65
65
|
- lib/recipient_interceptor.rb
|
66
66
|
- spec/recipient_interceptor_spec.rb
|
67
67
|
homepage: http://github.com/croaky/recipient_interceptor
|
68
|
-
licenses:
|
69
|
-
- MIT
|
68
|
+
licenses: []
|
70
69
|
metadata: {}
|
71
70
|
post_install_message:
|
72
71
|
rdoc_options: []
|
@@ -74,17 +73,17 @@ require_paths:
|
|
74
73
|
- lib
|
75
74
|
required_ruby_version: !ruby/object:Gem::Requirement
|
76
75
|
requirements:
|
77
|
-
- -
|
76
|
+
- - ">="
|
78
77
|
- !ruby/object:Gem::Version
|
79
78
|
version: '0'
|
80
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
80
|
requirements:
|
82
|
-
- -
|
81
|
+
- - ">="
|
83
82
|
- !ruby/object:Gem::Version
|
84
83
|
version: '0'
|
85
84
|
requirements: []
|
86
85
|
rubyforge_project:
|
87
|
-
rubygems_version: 2.
|
86
|
+
rubygems_version: 2.7.6
|
88
87
|
signing_key:
|
89
88
|
specification_version: 4
|
90
89
|
summary: Intercept recipients when delivering email with the Mail gem.
|