effective_email_templates 0.3.1 → 0.3.3

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.
@@ -2,43 +2,72 @@ require 'spec_helper'
2
2
  require 'effective_email_templates/template_importer'
3
3
 
4
4
  describe EffectiveEmailTemplates::TemplateImporter do
5
- before :each do
6
- Effective::EmailTemplate.delete_all
7
- end
5
+ before { Effective::EmailTemplate.delete_all }
8
6
 
9
- describe 'well formatted template files' do
10
- it 'imports templates from view files' do
11
- expect{ EffectiveEmailTemplates::TemplateImporter.invoke }.to change { Effective::EmailTemplate.count }
12
- end
7
+ describe '.invoke' do
8
+ context 'without overwriting' do
9
+ context 'when well formatted template files' do
10
+ it 'should import templates from view files' do
11
+ expect { EffectiveEmailTemplates::TemplateImporter.invoke }.to change { Effective::EmailTemplate.count }
12
+ end
13
13
 
14
- it 'does not import templates if a template already exists in the database' do
15
- expect{ EffectiveEmailTemplates::TemplateImporter.invoke }.to change { Effective::EmailTemplate.count }
16
- expect{ EffectiveEmailTemplates::TemplateImporter.invoke }.to_not change { Effective::EmailTemplate.count }
17
- end
14
+ it 'should not import templates if a template already exists in the database' do
15
+ expect { EffectiveEmailTemplates::TemplateImporter.invoke }.to change { Effective::EmailTemplate.count }
16
+ expect { EffectiveEmailTemplates::TemplateImporter.invoke }.to_not change { Effective::EmailTemplate.count }
17
+ end
18
18
 
19
- it 'does not print errors' do
20
- importer = EffectiveEmailTemplates::TemplateImporter.new
21
- expect(importer).to_not receive(:print_errors)
22
- EffectiveEmailTemplates::TemplateImporter.invoke(importer)
23
- end
24
- end
19
+ it 'should not print errors' do
20
+ importer = EffectiveEmailTemplates::TemplateImporter.new
21
+ expect(importer).to_not receive(:print_errors)
22
+ EffectiveEmailTemplates::TemplateImporter.invoke(importer)
23
+ end
24
+ end
25
+
26
+ context 'when poorly formatted template files' do
27
+ let(:filepath) { Rails.root.join('app', 'views', 'user_liquid', 'some_template.liquid') }
28
+
29
+ before { File.open(filepath, 'w') { |f| f.write("--\n---\nbody") } }
30
+ after { File.delete(filepath) }
25
31
 
26
- describe 'poorly formatted template files' do
27
- let(:filepath) { Rails.root.join('app', 'views', 'user_liquid', 'some_template.liquid') }
28
- before do
29
- File.open(filepath, 'w') do |f|
30
- f.write("--\n---\nbody")
32
+ it 'should print errors if there is a problem with a template' do
33
+ importer = EffectiveEmailTemplates::TemplateImporter.new
34
+ expect(importer).to receive(:print_errors)
35
+ EffectiveEmailTemplates::TemplateImporter.invoke(importer)
36
+ end
31
37
  end
32
38
  end
33
39
 
34
- after do
35
- File.delete(filepath)
36
- end
40
+ context 'with overwriting' do
41
+ let!(:existing_template) { FactoryGirl.create(:email_template, body: 'test', slug: 'after_create_user') }
42
+
43
+ context 'when well formatted template files' do
44
+ it 'should update templates from view files' do
45
+ expect { EffectiveEmailTemplates::TemplateImporter.invoke(overwrite: true) }.to change { existing_template.reload.body }.from('test').to('Hello {{ user_name }}')
46
+ end
47
+
48
+ it 'should not create duplicate templates if a template already exists in the database' do
49
+ expect { EffectiveEmailTemplates::TemplateImporter.invoke(overwrite: true) }.not_to change { Effective::EmailTemplate.count }
50
+ end
51
+
52
+ it 'should not print errors' do
53
+ importer = EffectiveEmailTemplates::TemplateImporter.new
54
+ expect(importer).to_not receive(:print_errors)
55
+ EffectiveEmailTemplates::TemplateImporter.invoke(importer, overwrite: true)
56
+ end
57
+ end
58
+
59
+ context 'when poorly formatted template files' do
60
+ let(:filepath) { Rails.root.join('app', 'views', 'user_liquid', 'some_template.liquid') }
37
61
 
38
- it 'prints errors if there is a problem with a template' do
39
- importer = EffectiveEmailTemplates::TemplateImporter.new
40
- expect(importer).to receive(:print_errors)
41
- EffectiveEmailTemplates::TemplateImporter.invoke(importer)
62
+ before { File.open(filepath, 'w') { |f| f.write("--\n---\nbody") } }
63
+ after { File.delete(filepath) }
64
+
65
+ it 'should print errors if there is a problem with a template' do
66
+ importer = EffectiveEmailTemplates::TemplateImporter.new
67
+ expect(importer).to receive(:print_errors)
68
+ EffectiveEmailTemplates::TemplateImporter.invoke(importer, overwrite: true)
69
+ end
70
+ end
42
71
  end
43
72
  end
44
73
  end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+ require 'effective_email_templates/template_importer'
3
+
4
+ describe EffectiveEmailTemplates::TemplateImporter do
5
+
6
+ describe 'well formatted template files' do
7
+ it 'imports templates from view files' do
8
+ Effective::EmailTemplate.delete_all
9
+ expect{ EffectiveEmailTemplates::TemplateImporter.invoke }.to change { Effective::EmailTemplate.count }
10
+ end
11
+
12
+ it 'does not import templates if a template already exists in the database' do
13
+ Effective::EmailTemplate.delete_all
14
+ expect{ EffectiveEmailTemplates::TemplateImporter.invoke }.to change { Effective::EmailTemplate.count }
15
+ expect{ EffectiveEmailTemplates::TemplateImporter.invoke }.to_not change { Effective::EmailTemplate.count }
16
+ end
17
+
18
+ it 'does not print errors' do
19
+ importer = EffectiveEmailTemplates::TemplateImporter.new
20
+ expect(importer).to_not receive(:print_errors)
21
+ EffectiveEmailTemplates::TemplateImporter.invoke(importer)
22
+ end
23
+ end
24
+
25
+ describe 'poorly formatted template files' do
26
+ let(:filepath) { Rails.root.join('app', 'views', 'user_liquid', 'some_template.liquid') }
27
+ before do
28
+ File.open(filepath, 'w') do |f|
29
+ f.write("--\n---\nbody")
30
+ end
31
+ end
32
+
33
+ after do
34
+ File.delete(filepath)
35
+ end
36
+
37
+ it 'prints errors if there is a problem with a template' do
38
+ importer = EffectiveEmailTemplates::TemplateImporter.new
39
+ expect(importer).to receive(:print_errors)
40
+ EffectiveEmailTemplates::TemplateImporter.invoke(importer)
41
+ end
42
+ end
43
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_email_templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-24 00:00:00.000000000 Z
11
+ date: 2015-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -209,7 +209,9 @@ files:
209
209
  - lib/effective_email_templates/engine.rb
210
210
  - lib/effective_email_templates/liquid_resolver.rb
211
211
  - lib/effective_email_templates/template_importer.rb
212
+ - lib/effective_email_templates/template_importer.rb~
212
213
  - lib/effective_email_templates/version.rb
214
+ - lib/effective_email_templates/version.rb~
213
215
  - lib/generators/effective_email_templates/install_generator.rb
214
216
  - lib/generators/templates/README
215
217
  - lib/generators/templates/effective_email_templates.rb
@@ -253,18 +255,29 @@ files:
253
255
  - spec/dummy/config/locales/en.yml
254
256
  - spec/dummy/config/routes.rb
255
257
  - spec/dummy/config/secrets.yml
258
+ - spec/dummy/db/development.sqlite3
256
259
  - spec/dummy/db/migrate/20141126222940_devise_create_users.rb
257
260
  - spec/dummy/db/migrate/20141126222941_create_effective_email_templates.rb
258
261
  - spec/dummy/db/schema.rb
262
+ - spec/dummy/db/test.sqlite3
263
+ - spec/dummy/log/development.log
264
+ - spec/dummy/log/test.log
259
265
  - spec/dummy/public/404.html
260
266
  - spec/dummy/public/422.html
261
267
  - spec/dummy/public/500.html
262
268
  - spec/dummy/public/favicon.ico
269
+ - spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705
270
+ - spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af
271
+ - spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953
272
+ - spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994
273
+ - spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6
274
+ - spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655
263
275
  - spec/effective_email_templates_spec.rb
264
276
  - spec/factories/email_template.rb
265
277
  - spec/factories/user.rb
266
278
  - spec/factory_spec.rb
267
279
  - spec/lib/effective_email_templates/template_importer_spec.rb
280
+ - spec/lib/effective_email_templates/template_importer_spec.rb~
268
281
  - spec/mailers/liquid_resolved_mailer_spec.rb
269
282
  - spec/models/email_template_spec.rb
270
283
  - spec/models/user_spec.rb
@@ -290,7 +303,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
303
  version: '0'
291
304
  requirements: []
292
305
  rubyforge_project:
293
- rubygems_version: 2.4.3
306
+ rubygems_version: 2.2.2
294
307
  signing_key:
295
308
  specification_version: 4
296
309
  summary: Effective Email Templates provides an admin access to modify email templates
@@ -332,20 +345,31 @@ test_files:
332
345
  - spec/dummy/config/routes.rb
333
346
  - spec/dummy/config/secrets.yml
334
347
  - spec/dummy/config.ru
348
+ - spec/dummy/db/development.sqlite3
335
349
  - spec/dummy/db/migrate/20141126222940_devise_create_users.rb
336
350
  - spec/dummy/db/migrate/20141126222941_create_effective_email_templates.rb
337
351
  - spec/dummy/db/schema.rb
352
+ - spec/dummy/db/test.sqlite3
353
+ - spec/dummy/log/development.log
354
+ - spec/dummy/log/test.log
338
355
  - spec/dummy/public/404.html
339
356
  - spec/dummy/public/422.html
340
357
  - spec/dummy/public/500.html
341
358
  - spec/dummy/public/favicon.ico
342
359
  - spec/dummy/Rakefile
343
360
  - spec/dummy/README.rdoc
361
+ - spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705
362
+ - spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af
363
+ - spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953
364
+ - spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994
365
+ - spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6
366
+ - spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655
344
367
  - spec/effective_email_templates_spec.rb
345
368
  - spec/factories/email_template.rb
346
369
  - spec/factories/user.rb
347
370
  - spec/factory_spec.rb
348
371
  - spec/lib/effective_email_templates/template_importer_spec.rb
372
+ - spec/lib/effective_email_templates/template_importer_spec.rb~
349
373
  - spec/mailers/liquid_resolved_mailer_spec.rb
350
374
  - spec/models/email_template_spec.rb
351
375
  - spec/models/user_spec.rb