outbox-rails 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 57294d890576209761af55f8add69fbe000ecb4a
4
+ data.tar.gz: 48ea5264966ae0e32d2a4d1748270e6784c70848
5
+ SHA512:
6
+ metadata.gz: 417e24b5a13534a2ccdfdb3a446d6f65e90db9d0f6ee1aaa0ba8df0998811643318c2ed8793374df05355c8bb70ffa2640418e7cd1d8a6236d13338dc76f0fc8
7
+ data.tar.gz: b4bfb5c923352b9746101a22be60e2c91b87dc7078309c8ab97c8996547d90050eb7856ceef2653664d4eb211dc750bc7645005af0cb0e057a5b60ad036b9de3
@@ -4,7 +4,6 @@ module Outbox
4
4
  class Notifier < ActionMailer::Base
5
5
  abstract!
6
6
 
7
- delegate :attachments, :headers, to: :email
8
7
  alias_method :_render_email, :mail
9
8
  undef :mail
10
9
 
@@ -75,6 +74,22 @@ module Outbox
75
74
  @_message
76
75
  end
77
76
 
77
+ def headers(args = nil) # :nodoc:
78
+ # Make sure the email message instance exists
79
+ email({}) if email.nil?
80
+ if args
81
+ email.headers(args)
82
+ else
83
+ email
84
+ end
85
+ end
86
+
87
+ def attachments
88
+ # Make sure the email message instance exists
89
+ email({}) if email.nil?
90
+ email.attachments
91
+ end
92
+
78
93
  protected
79
94
 
80
95
  def assign_body_from_email(email)
@@ -1,5 +1,5 @@
1
1
  module Outbox
2
2
  module Rails
3
- VERSION = '0.1.2'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -1,6 +1,4 @@
1
1
  class BaseNotifier < Outbox::Notifier
2
- defaults email: { from: 'noreply@myapp.com' }
3
-
4
2
  def welcome(hash = {})
5
3
  render_message(hash)
6
4
  end
@@ -15,4 +13,9 @@ class BaseNotifier < Outbox::Notifier
15
13
  subject 'Composed Message'
16
14
  end
17
15
  end
16
+
17
+ def custom_headers
18
+ headers 'X-Custom-1' => 'foo'
19
+ headers['X-Custom-2'] = 'bar'
20
+ end
18
21
  end
@@ -0,0 +1,6 @@
1
+ class CustomizedNotifier < Outbox::Notifier
2
+ defaults email: { from: 'noreply@myapp.com' }
3
+
4
+ def with_defaults
5
+ end
6
+ end
@@ -0,0 +1 @@
1
+ Custom Headers
@@ -0,0 +1 @@
1
+ Customized Notifier with Defaults
@@ -19,7 +19,7 @@ describe Outbox::Notifier do
19
19
 
20
20
  describe '.defaults' do
21
21
  it 'sets the default values' do
22
- message = BaseNotifier.welcome
22
+ message = CustomizedNotifier.with_defaults
23
23
  expect(message.email.from).to eq(['noreply@myapp.com'])
24
24
  end
25
25
  end
@@ -46,7 +46,6 @@ describe Outbox::Notifier do
46
46
  describe '#email' do
47
47
  it 'composes an email using Outbox interface' do
48
48
  message = BaseNotifier.composed_message_with_implicit_render
49
- expect(message.email.from).to eq(['noreply@myapp.com'])
50
49
  expect(message.email.subject).to eq('Composed Message')
51
50
  end
52
51
  end
@@ -67,5 +66,18 @@ describe Outbox::Notifier do
67
66
  expect(part_2.mime_type).to eq('text/html')
68
67
  expect(part_2.body.encoded.strip).to eq('HTML Implicit Multipart')
69
68
  end
69
+
70
+ it 'handles attachments' do
71
+ message = BaseNotifier.implicit_multipart(attachments: true)
72
+ attachment = message.email.attachments.first
73
+ expect(attachment.mime_type).to eq('application/pdf')
74
+ expect(attachment.decoded.strip).to eq('This is test File content')
75
+ end
76
+
77
+ it 'handles custom headers' do
78
+ message = BaseNotifier.custom_headers
79
+ expect(message.email.header['X-Custom-1'].value).to eql('foo')
80
+ expect(message.email.header['X-Custom-2'].value).to eql('bar')
81
+ end
70
82
  end
71
83
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: outbox-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Pete Browne
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-02 00:00:00.000000000 Z
11
+ date: 2014-06-22 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: outbox
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rails
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: bundler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,97 +55,85 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rspec-rails
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rspec_junit_formatter
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - '>='
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - '>='
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: sqlite3
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - '>='
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - '>='
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: combustion
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - '>='
148
130
  - !ruby/object:Gem::Version
149
131
  version: '0'
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - '>='
156
137
  - !ruby/object:Gem::Version
157
138
  version: '0'
158
139
  description: Rails Railtie for sending email, SMS, and push notifications using the
@@ -187,10 +168,13 @@ files:
187
168
  - outbox-rails.gemspec
188
169
  - spec/internal/.gitignore
189
170
  - spec/internal/app/notifiers/base_notifier.rb
171
+ - spec/internal/app/notifiers/customized_notifier.rb
190
172
  - spec/internal/app/views/base_notifier/composed_message_with_implicit_render.erb
173
+ - spec/internal/app/views/base_notifier/custom_headers.erb
191
174
  - spec/internal/app/views/base_notifier/implicit_multipart.html.erb
192
175
  - spec/internal/app/views/base_notifier/implicit_multipart.text.erb
193
176
  - spec/internal/app/views/base_notifier/welcome.erb
177
+ - spec/internal/app/views/customized_notifier/with_defaults.erb
194
178
  - spec/internal/config/database.yml
195
179
  - spec/internal/config/routes.rb
196
180
  - spec/internal/db/schema.rb
@@ -203,42 +187,38 @@ files:
203
187
  homepage: https://github.com/localmed/outbox-rails
204
188
  licenses:
205
189
  - MIT
190
+ metadata: {}
206
191
  post_install_message:
207
192
  rdoc_options: []
208
193
  require_paths:
209
194
  - lib
210
195
  required_ruby_version: !ruby/object:Gem::Requirement
211
- none: false
212
196
  requirements:
213
- - - ! '>='
197
+ - - '>='
214
198
  - !ruby/object:Gem::Version
215
199
  version: '0'
216
- segments:
217
- - 0
218
- hash: -4207356014425354258
219
200
  required_rubygems_version: !ruby/object:Gem::Requirement
220
- none: false
221
201
  requirements:
222
- - - ! '>='
202
+ - - '>='
223
203
  - !ruby/object:Gem::Version
224
204
  version: '0'
225
- segments:
226
- - 0
227
- hash: -4207356014425354258
228
205
  requirements: []
229
206
  rubyforge_project:
230
- rubygems_version: 1.8.23
207
+ rubygems_version: 2.2.2
231
208
  signing_key:
232
- specification_version: 3
209
+ specification_version: 4
233
210
  summary: Rails Railtie for sending email, SMS, and push notifications using the Outbox
234
211
  gem.
235
212
  test_files:
236
213
  - spec/internal/.gitignore
237
214
  - spec/internal/app/notifiers/base_notifier.rb
215
+ - spec/internal/app/notifiers/customized_notifier.rb
238
216
  - spec/internal/app/views/base_notifier/composed_message_with_implicit_render.erb
217
+ - spec/internal/app/views/base_notifier/custom_headers.erb
239
218
  - spec/internal/app/views/base_notifier/implicit_multipart.html.erb
240
219
  - spec/internal/app/views/base_notifier/implicit_multipart.text.erb
241
220
  - spec/internal/app/views/base_notifier/welcome.erb
221
+ - spec/internal/app/views/customized_notifier/with_defaults.erb
242
222
  - spec/internal/config/database.yml
243
223
  - spec/internal/config/routes.rb
244
224
  - spec/internal/db/schema.rb