roadie-rails 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a3ebc3aff7c53caa14674f15dc37ab6150554f8
4
- data.tar.gz: 8f6b87cd08b8f2e2d1760204c94838281d000f2f
3
+ metadata.gz: 2a4b35fded61973ac9cbda12c4cbf1796becd78f
4
+ data.tar.gz: 6b0b437288261047b9b81693bbb0deed2807a2d4
5
5
  SHA512:
6
- metadata.gz: 6840bb17f8c116882bbc654a39a1073315a8f11c13eff80020ab6fb024ed4801b482112d14352299243ce7b8aa81ecc0ca971e950593b2593182361551c6fab0
7
- data.tar.gz: c87ba9352200a9f49392da40f05d919be762a3787d9fc48ac8d8c0e9f3a8189fdf6775a74ae089b66292db58ddee4bc9d1796ac6e71eb4af812460ab42790bc4
6
+ metadata.gz: 4b8a7542c61077ac912f2bf2d94eb5a35896d318c7e1c6e016ccb866a9db0e6785b22a58ab2e983216c64d9c33306bb736feb2bbe5afd741faf547aff06c242c
7
+ data.tar.gz: da357a8a917fee88860c6583acd0dbc9000778953d1bd4b3824bcd78143cc799469fb21d3f6b401acdd761f5288d201464c11c2b3c61a437d8119edc90e6219d
@@ -1,8 +1,13 @@
1
1
  ### development version
2
2
 
3
- [full changelog](https://github.com/Mange/roadie/compare/v1.0.1...master)
3
+ [full changelog](https://github.com/Mange/roadie/compare/v1.0.2...master)
4
4
 
5
- * Nothing yet
5
+ ### 1.0.2
6
+
7
+ [full changelog](https://github.com/Mange/roadie/compare/v1.0.1...v1.0.2)
8
+
9
+ * Bug fixes
10
+ * Don't crash on `nil` `roadie_options`
6
11
 
7
12
  ### 1.0.1
8
13
 
@@ -49,7 +49,7 @@ end
49
49
  ```
50
50
 
51
51
 
52
- ** After:**
52
+ **After:**
53
53
 
54
54
  ```erb
55
55
  <head>
@@ -4,7 +4,7 @@ module Roadie
4
4
  def mail(*args, &block)
5
5
  super.tap do |email|
6
6
  email.extend InlineOnDelivery
7
- email.roadie_options = roadie_options.dup
7
+ email.roadie_options = roadie_options.try(:dup)
8
8
  end
9
9
  end
10
10
 
@@ -1,14 +1,7 @@
1
1
  module Roadie
2
2
  module Rails
3
3
  class DocumentBuilder
4
- class << self
5
- def build(html, options)
6
- new.build(html, options)
7
- end
8
- private :new
9
- end
10
-
11
- def build(html, options)
4
+ def self.build(html, options)
12
5
  document = Document.new(html)
13
6
  options.apply_to document
14
7
  document
@@ -9,8 +9,10 @@ module Roadie
9
9
  end
10
10
 
11
11
  def execute
12
- improve_body if email.content_type =~ /^text\/html/
13
- improve_html_part(email.html_part) if email.html_part
12
+ if options
13
+ improve_body if email.content_type =~ /^text\/html/
14
+ improve_html_part(email.html_part) if email.html_part
15
+ end
14
16
  email
15
17
  end
16
18
 
@@ -1,5 +1,5 @@
1
1
  module Roadie
2
2
  module Rails
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
@@ -75,6 +75,21 @@ describe "Integrations" do
75
75
  email.deliver
76
76
  end
77
77
 
78
+ it "inlines no styles when roadie_options are nil" do
79
+ email = app.read_delivered_email(:disabled_email)
80
+
81
+ expect(email.to).to eq(['example@example.org'])
82
+ expect(email.from).to eq(['john@example.com'])
83
+ expect(email).to have(2).parts
84
+
85
+ document = parse_html_in_email(email)
86
+ expect(document).to have_no_styling.at_selector('.image')
87
+
88
+ # If we deliver mails we can catch weird problems with headers being invalid
89
+ email.delivery_method :test
90
+ email.deliver
91
+ end
92
+
78
93
  if app.using_asset_pipeline?
79
94
  it "has a AssetPipelineProvider together with a FilesystemProvider" do
80
95
  expect(app.read_providers).to eq(%w[Roadie::FilesystemProvider Roadie::Rails::AssetPipelineProvider])
@@ -27,16 +27,26 @@ module Roadie
27
27
 
28
28
  describe "#mail" do
29
29
  let(:email) { Mail.new(to: "foo@example.com", from: "me@example.com") }
30
- let(:roadie_options) { Options.new(url_options: {host: "somehost.com"}) }
31
30
  let(:instance) { some_mailer.new(email) }
32
31
 
33
- before { allow(instance).to receive(:roadie_options).and_return roadie_options }
34
-
35
32
  it "extends the email with InlineOnDelivery and assigns roadie options" do
33
+ options = Options.new(url_options: {host: "somehost.com"})
34
+ allow(instance).to receive(:roadie_options).and_return options
35
+
36
36
  email = instance.mail
37
+
37
38
  expect(email).to be_kind_of(InlineOnDelivery)
38
39
  expect(email.roadie_options).not_to be_nil
39
- expect(email.roadie_options.url_options).to eq roadie_options.url_options
40
+ expect(email.roadie_options.url_options).to eq options.url_options
41
+ end
42
+
43
+ it "assigns nil roadie options if no options are present" do
44
+ allow(instance).to receive(:roadie_options).and_return nil
45
+
46
+ email = instance.mail
47
+
48
+ expect(email).to be_kind_of(InlineOnDelivery)
49
+ expect(email.roadie_options).to be_nil
40
50
  end
41
51
  end
42
52
  end
@@ -27,6 +27,11 @@ module Roadie
27
27
  expect(email.html_part).to be_nil
28
28
  expect(email.body.decoded).to eq("Hello world")
29
29
  end
30
+
31
+ it "does nothing when given nil options" do
32
+ inliner = MailInliner.new(email, nil)
33
+ expect { inliner.execute }.to_not raise_error
34
+ end
30
35
  end
31
36
 
32
37
  context "with an HTML email" do
@@ -47,6 +52,11 @@ module Roadie
47
52
 
48
53
  expect(email.body.decoded).to eq("transformed HTML")
49
54
  end
55
+
56
+ it "does nothing when given nil options" do
57
+ inliner = MailInliner.new(email, nil)
58
+ expect { inliner.execute }.to_not raise_error
59
+ end
50
60
  end
51
61
 
52
62
  context "with an multipart email" do
@@ -71,6 +81,11 @@ module Roadie
71
81
 
72
82
  expect(email.html_part.body.decoded).to eq("transformed HTML")
73
83
  end
84
+
85
+ it "does nothing when given nil options" do
86
+ inliner = MailInliner.new(email, nil)
87
+ expect { inliner.execute }.to_not raise_error
88
+ end
74
89
  end
75
90
  end
76
91
  end
@@ -4,14 +4,24 @@ class AutoMailer < ActionMailer::Base
4
4
  default from: 'john@example.com'
5
5
 
6
6
  def normal_email
7
- mail(to: 'example@example.org', subject: "Notification for you") do |format|
8
- format.html
9
- format.text
10
- end
7
+ generate_email
8
+ end
9
+
10
+ def disabled_email
11
+ generate_email
11
12
  end
12
13
 
13
14
  private
14
15
  def roadie_options
15
- super.combine(url_options: {protocol: "https"})
16
+ unless action_name =~ /disabled/
17
+ super.combine(url_options: {protocol: "https"})
18
+ end
19
+ end
20
+
21
+ def generate_email
22
+ mail(to: 'example@example.org', subject: "Notification for you") do |format|
23
+ format.html { render :normal_email }
24
+ format.text { render :normal_email }
25
+ end
16
26
  end
17
27
  end
@@ -4,14 +4,24 @@ class AutoMailer < ActionMailer::Base
4
4
  default from: 'john@example.com'
5
5
 
6
6
  def normal_email
7
- mail(to: 'example@example.org', subject: "Notification for you") do |format|
8
- format.html
9
- format.text
10
- end
7
+ generate_email
8
+ end
9
+
10
+ def disabled_email
11
+ generate_email
11
12
  end
12
13
 
13
14
  private
14
15
  def roadie_options
15
- super.combine(url_options: {protocol: "https"})
16
+ unless action_name =~ /disabled/
17
+ super.combine(url_options: {protocol: "https"})
18
+ end
19
+ end
20
+
21
+ def generate_email
22
+ mail(to: 'example@example.org', subject: "Notification for you") do |format|
23
+ format.html { render :normal_email }
24
+ format.text { render :normal_email }
25
+ end
16
26
  end
17
27
  end
@@ -4,14 +4,24 @@ class AutoMailer < ActionMailer::Base
4
4
  default from: 'john@example.com'
5
5
 
6
6
  def normal_email
7
- mail(to: 'example@example.org', subject: "Notification for you") do |format|
8
- format.html
9
- format.text
10
- end
7
+ generate_email
8
+ end
9
+
10
+ def disabled_email
11
+ generate_email
11
12
  end
12
13
 
13
14
  private
14
15
  def roadie_options
15
- super.combine(url_options: {protocol: "https"})
16
+ unless action_name =~ /disabled/
17
+ super.combine(url_options: {protocol: "https"})
18
+ end
19
+ end
20
+
21
+ def generate_email
22
+ mail(to: 'example@example.org', subject: "Notification for you") do |format|
23
+ format.html { render :normal_email }
24
+ format.text { render :normal_email }
25
+ end
16
26
  end
17
27
  end
@@ -4,14 +4,24 @@ class AutoMailer < ActionMailer::Base
4
4
  default from: 'john@example.com'
5
5
 
6
6
  def normal_email
7
- mail(to: 'example@example.org', subject: "Notification for you") do |format|
8
- format.html
9
- format.text
10
- end
7
+ generate_email
8
+ end
9
+
10
+ def disabled_email
11
+ generate_email
11
12
  end
12
13
 
13
14
  private
14
15
  def roadie_options
15
- super.combine(url_options: {protocol: "https"})
16
+ unless action_name =~ /disabled/
17
+ super.combine(url_options: {protocol: "https"})
18
+ end
19
+ end
20
+
21
+ def generate_email
22
+ mail(to: 'example@example.org', subject: "Notification for you") do |format|
23
+ format.html { render :normal_email }
24
+ format.text { render :normal_email }
25
+ end
16
26
  end
17
27
  end
@@ -4,14 +4,24 @@ class AutoMailer < ActionMailer::Base
4
4
  default from: 'john@example.com'
5
5
 
6
6
  def normal_email
7
- mail(to: 'example@example.org', subject: "Notification for you") do |format|
8
- format.html
9
- format.text
10
- end
7
+ generate_email
8
+ end
9
+
10
+ def disabled_email
11
+ generate_email
11
12
  end
12
13
 
13
14
  private
14
15
  def roadie_options
15
- super.combine(url_options: {protocol: "https"})
16
+ unless action_name =~ /disabled/
17
+ super.combine(url_options: {protocol: "https"})
18
+ end
19
+ end
20
+
21
+ def generate_email
22
+ mail(to: 'example@example.org', subject: "Notification for you") do |format|
23
+ format.html { render :normal_email }
24
+ format.text { render :normal_email }
25
+ end
16
26
  end
17
27
  end
@@ -4,14 +4,24 @@ class AutoMailer < ActionMailer::Base
4
4
  default from: 'john@example.com'
5
5
 
6
6
  def normal_email
7
- mail(to: 'example@example.org', subject: "Notification for you") do |format|
8
- format.html
9
- format.text
10
- end
7
+ generate_email
8
+ end
9
+
10
+ def disabled_email
11
+ generate_email
11
12
  end
12
13
 
13
14
  private
14
15
  def roadie_options
15
- super.combine(url_options: {protocol: "https"})
16
+ unless action_name =~ /disabled/
17
+ super.combine(url_options: {protocol: "https"})
18
+ end
19
+ end
20
+
21
+ def generate_email
22
+ mail(to: 'example@example.org', subject: "Notification for you") do |format|
23
+ format.html { render :normal_email }
24
+ format.text { render :normal_email }
25
+ end
16
26
  end
17
27
  end
@@ -0,0 +1,25 @@
1
+ RSpec::Matchers.define :have_no_styling do
2
+ chain(:at_selector) { |selector| @selector = selector }
3
+
4
+ match { |document|
5
+ @selector ||= 'body > *:first'
6
+ styles_at_selector(document).empty?
7
+ }
8
+
9
+ description {
10
+ "have no styles at selector #{@selector.inspect}"
11
+ }
12
+
13
+ failure_message { |document|
14
+ "expected no styles at #{@selector.inspect} but had:\n#{styles_at_selector(document)}"
15
+ }
16
+
17
+ failure_message_when_negated {
18
+ "expected #{@selector.inspect} to have styles"
19
+ }
20
+
21
+ def styles_at_selector(document)
22
+ expect(document).to have_selector(@selector)
23
+ document.at_css(@selector)['style'] || ""
24
+ end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roadie-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus Bergmark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-28 00:00:00.000000000 Z
11
+ date: 2014-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roadie
@@ -271,6 +271,7 @@ files:
271
271
  - spec/railsapps/rails_41/config/initializers/session_store.rb
272
272
  - spec/railsapps/rails_41/config/routes.rb
273
273
  - spec/spec_helper.rb
274
+ - spec/support/have_no_styling_matcher.rb
274
275
  - spec/support/have_selector_matcher.rb
275
276
  - spec/support/have_styling_matcher.rb
276
277
  - spec/support/rails_app.rb
@@ -438,6 +439,7 @@ test_files:
438
439
  - spec/railsapps/rails_41/config/initializers/session_store.rb
439
440
  - spec/railsapps/rails_41/config/routes.rb
440
441
  - spec/spec_helper.rb
442
+ - spec/support/have_no_styling_matcher.rb
441
443
  - spec/support/have_selector_matcher.rb
442
444
  - spec/support/have_styling_matcher.rb
443
445
  - spec/support/rails_app.rb