outbox-rails 0.4.0 → 0.4.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.
- checksums.yaml +4 -4
- data/lib/outbox/notifier.rb +5 -2
- data/lib/outbox/rails/version.rb +1 -1
- data/spec/internal/app/notifiers/base_notifier.rb +10 -1
- data/spec/internal/app/views/layouts/notification.text+email.erb +1 -0
- data/spec/internal/app/views/layouts/notification.text+sms.erb +1 -0
- data/spec/outbox/notifier_spec.rb +6 -0
- metadata +5 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 525a3a52879108983b9c2afc5353808de7b5caf1
|
|
4
|
+
data.tar.gz: 10b21890104eb4695e7f89d69955833fa57d3e38
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e83c7badbd9b68e11587732816c191589645a7593d74cce5a98209abbbf2eedc04ef2900b1a17b3cbfabb5fc740281c12ad7acdde31e2015fe2f17bf781b628a
|
|
7
|
+
data.tar.gz: 944abb48fee1557ea0e5e7dabfedd61d50ab25e2eeb0696251cd47e0df8db7d61460f010a19c0c57069b5c3d36dca65152cf48ae8f648fe74d2ac831d82d9b0b
|
data/lib/outbox/notifier.rb
CHANGED
|
@@ -124,8 +124,11 @@ module Outbox
|
|
|
124
124
|
templates = find_message_type_templates(options)
|
|
125
125
|
templates.each do |template|
|
|
126
126
|
variants = (template.try(:variants) || []).compact
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
if variants.empty?
|
|
128
|
+
assign_body(render(template: template))
|
|
129
|
+
else
|
|
130
|
+
assign_body(render(template: template, variants: variants), variants)
|
|
131
|
+
end
|
|
129
132
|
end
|
|
130
133
|
end
|
|
131
134
|
|
data/lib/outbox/rails/version.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
class BaseNotifier < Outbox::Notifier
|
|
2
|
+
layout :set_layout
|
|
3
|
+
|
|
2
4
|
def welcome(hash = {})
|
|
3
5
|
render_message(hash)
|
|
4
6
|
end
|
|
@@ -29,6 +31,13 @@ class BaseNotifier < Outbox::Notifier
|
|
|
29
31
|
end
|
|
30
32
|
end
|
|
31
33
|
|
|
32
|
-
def implicit_variants
|
|
34
|
+
def implicit_variants(layout = false)
|
|
35
|
+
@layout = layout
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
protected
|
|
39
|
+
|
|
40
|
+
def set_layout
|
|
41
|
+
@layout
|
|
33
42
|
end
|
|
34
43
|
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Email Layout: <%= yield %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
SMS Layout: <%= yield %>
|
|
@@ -104,6 +104,12 @@ describe Outbox::Notifier do
|
|
|
104
104
|
expect(message.email.body.encoded.strip).to eql('Email Variant')
|
|
105
105
|
expect(message.sms.body.strip).to eql('SMS Variant')
|
|
106
106
|
end
|
|
107
|
+
|
|
108
|
+
it 'supports layout variants' do
|
|
109
|
+
message = BaseNotifier.implicit_variants('notification')
|
|
110
|
+
expect(message.email.body.encoded.strip).to eql('Email Layout: Email Variant')
|
|
111
|
+
expect(message.sms.body.strip).to eql('SMS Layout: SMS Variant')
|
|
112
|
+
end
|
|
107
113
|
end
|
|
108
114
|
end
|
|
109
115
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: outbox-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pete Browne
|
|
@@ -184,6 +184,8 @@ files:
|
|
|
184
184
|
- spec/internal/app/views/base_notifier/implicit_variants.text+sms.erb
|
|
185
185
|
- spec/internal/app/views/base_notifier/welcome.erb
|
|
186
186
|
- spec/internal/app/views/customized_notifier/with_defaults.erb
|
|
187
|
+
- spec/internal/app/views/layouts/notification.text+email.erb
|
|
188
|
+
- spec/internal/app/views/layouts/notification.text+sms.erb
|
|
187
189
|
- spec/internal/config/database.yml
|
|
188
190
|
- spec/internal/config/routes.rb
|
|
189
191
|
- spec/internal/db/schema.rb
|
|
@@ -230,6 +232,8 @@ test_files:
|
|
|
230
232
|
- spec/internal/app/views/base_notifier/implicit_variants.text+sms.erb
|
|
231
233
|
- spec/internal/app/views/base_notifier/welcome.erb
|
|
232
234
|
- spec/internal/app/views/customized_notifier/with_defaults.erb
|
|
235
|
+
- spec/internal/app/views/layouts/notification.text+email.erb
|
|
236
|
+
- spec/internal/app/views/layouts/notification.text+sms.erb
|
|
233
237
|
- spec/internal/config/database.yml
|
|
234
238
|
- spec/internal/config/routes.rb
|
|
235
239
|
- spec/internal/db/schema.rb
|