mandrill_batch_mailer 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62eb5a8ab276e549611894a5e53967bc8ac6bf86
|
4
|
+
data.tar.gz: 32d2bd5d65060185e34e078fbdd10a84a66ed57f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17f92ea6f9071ea26a2a4c23e3bc49d8fbc0364a29f0cc7e1208d67a00fb1ce2d26e4acf2c67c9b63ac48c5086aa0e9eb3166febc507bea639c71edc7cc226fb
|
7
|
+
data.tar.gz: 8dfb5eb9852a1bbaa9d27f926ffe8d70c69f9158832d342067b9cb82861248f24f535048da73cb17494cb22fded20525d783e28ba45aa91ddb77564c8d746d2d
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'active_support'
|
2
2
|
require 'active_support/inflector'
|
3
3
|
require 'active_support/core_ext/object/try'
|
4
|
+
require 'active_support/core_ext/hash/deep_merge.rb'
|
4
5
|
|
5
6
|
module MandrillBatchMailer
|
6
7
|
class BaseMailer
|
@@ -154,7 +155,23 @@ module MandrillBatchMailer
|
|
154
155
|
end
|
155
156
|
|
156
157
|
def translations
|
157
|
-
I18n.
|
158
|
+
if I18n.methods.include? :fallbacks
|
159
|
+
fallback_translations scope
|
160
|
+
else
|
161
|
+
I18n.t scope
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def fallback_translations(scope)
|
166
|
+
I18n.fallbacks[I18n.locale].map do |fallback_locale|
|
167
|
+
I18n.t scope, locale: fallback_locale
|
168
|
+
end.reduce do |orig_translations, fallback_translations|
|
169
|
+
if fallback_translations.is_a? Hash
|
170
|
+
fallback_translations.deep_merge orig_translations
|
171
|
+
else
|
172
|
+
orig_translations
|
173
|
+
end
|
174
|
+
end
|
158
175
|
end
|
159
176
|
|
160
177
|
def class_name
|
@@ -162,9 +179,13 @@ module MandrillBatchMailer
|
|
162
179
|
end
|
163
180
|
|
164
181
|
def shared_translations
|
165
|
-
|
166
|
-
"#{class_name.deconstantize.underscore}.shared_translations"
|
167
|
-
|
182
|
+
shared_scope =
|
183
|
+
"#{class_name.deconstantize.underscore}.shared_translations"
|
184
|
+
if I18n.methods.include? :fallbacks
|
185
|
+
fallback_translations shared_scope
|
186
|
+
else
|
187
|
+
I18n.t shared_scope
|
188
|
+
end
|
168
189
|
end
|
169
190
|
|
170
191
|
def merge_vars_from(translations)
|
@@ -219,10 +219,27 @@ describe MandrillBatchMailer::BaseMailer do
|
|
219
219
|
end
|
220
220
|
|
221
221
|
describe '#translations' do
|
222
|
-
subject { test_mailer.send :translations }
|
222
|
+
subject(:translated) { test_mailer.send :translations }
|
223
223
|
it do
|
224
224
|
should eq translations[:test_mailer][:testing]
|
225
225
|
end
|
226
|
+
|
227
|
+
context 'with de translations and fallbacks on' do
|
228
|
+
let(:de_translations) do
|
229
|
+
{ test_mailer: { testing: { subject: 'Ein Test Betreff' } } }
|
230
|
+
end
|
231
|
+
before do
|
232
|
+
I18n::Backend::Simple.include I18n::Backend::Fallbacks
|
233
|
+
I18n.backend.store_translations :de, de_translations
|
234
|
+
I18n.locale = :de
|
235
|
+
end
|
236
|
+
after { I18n.locale = :en }
|
237
|
+
|
238
|
+
it 'uses fallbacks' do
|
239
|
+
expect(translated[:subject]).to eq 'Ein Test Betreff'
|
240
|
+
expect(translated[:just_a_test]).to eq 'This is just a test'
|
241
|
+
end
|
242
|
+
end
|
226
243
|
end
|
227
244
|
|
228
245
|
describe '#shared_translations' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mandrill_batch_mailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- schasse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -190,5 +190,5 @@ signing_key:
|
|
190
190
|
specification_version: 4
|
191
191
|
summary: Send batched Mails via Mandrill API
|
192
192
|
test_files:
|
193
|
-
- spec/spec_helper.rb
|
194
193
|
- spec/mandrill_batch_mailer/base_mailer_spec.rb
|
194
|
+
- spec/spec_helper.rb
|