roadie 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog.md CHANGED
@@ -1,9 +1,23 @@
1
1
  ### dev
2
2
 
3
- [full changelog](https://github.com/Mange/roadie/compare/v2.1.0.pre2...master)
3
+ [full changelog](https://github.com/Mange/roadie/compare/v2.2.0...master)
4
4
 
5
5
  * Nothing yet
6
6
 
7
+ ### 2.2.0
8
+
9
+ [full changelog](https://github.com/Mange/roadie/compare/v2.1.0...v2.2.0)
10
+
11
+ * Enhancements:
12
+ * Support for the `url_options` method inside mailer instances
13
+ * You can now dynamically alter the URL options on a per-email basis
14
+
15
+ ### 2.1.0
16
+
17
+ [full changelog](https://github.com/Mange/roadie/compare/v2.1.0.pre2...v2.1.0)
18
+
19
+ * Full release!
20
+
7
21
  ### 2.1.0.pre2
8
22
 
9
23
  [full changelog](https://github.com/Mange/roadie/compare/v2.1.0.pre1...v2.1.0.pre2)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roadie (2.1.0)
4
+ roadie (2.2.0)
5
5
  actionmailer (~> 3.1.0)
6
6
  css_parser
7
7
  nokogiri (>= 1.4.4)
@@ -38,7 +38,6 @@ module Roadie
38
38
  end
39
39
 
40
40
  def inline_style_response(response)
41
- url_options = Rails.application.config.action_mailer.default_url_options
42
41
  if response[:content_type] == 'text/html'
43
42
  response.merge :body => Roadie.inline_css(Roadie.current_provider, css_targets, response[:body], url_options)
44
43
  else
@@ -1,4 +1,5 @@
1
1
  require 'action_mailer'
2
+ require 'roadie'
2
3
  require 'roadie/action_mailer_extensions'
3
4
 
4
5
  module Roadie
@@ -16,7 +17,9 @@ module Roadie
16
17
  config.roadie.provider = nil
17
18
 
18
19
  initializer "roadie.extend_action_mailer" do
19
- ActionMailer::Base.send :include, Roadie::ActionMailerExtensions
20
+ ActiveSupport.on_load(:action_mailer) do
21
+ include Roadie::ActionMailerExtensions
22
+ end
20
23
  end
21
24
  end
22
25
  end
@@ -1,3 +1,3 @@
1
1
  module Roadie
2
- VERSION = '2.1.0'
2
+ VERSION = '2.2.0'
3
3
  end
@@ -17,12 +17,15 @@ module Roadie
17
17
  headers('X-Spam' => 'No way! Trust us!')
18
18
  mail(:subject => 'Buy cheap v1agra', :to => to)
19
19
  end
20
+
21
+ def url_options
22
+ # This allows apps to calculate any options on a per-email basis
23
+ super.merge(:protocol => 'https')
24
+ end
20
25
  end
21
26
 
22
27
  before(:each) do
23
- Rails.application.config.action_mailer.default_url_options = {:host => "example.app.org"}
24
-
25
- Rails.stub(:root => FIXTURES_PATH)
28
+ change_default_url_options(:host => 'example.app.org')
26
29
  mailer.delivery_method = :test
27
30
  end
28
31
 
@@ -37,7 +40,7 @@ module Roadie
37
40
  document = Nokogiri::HTML.parse(html_part.body.decoded)
38
41
  document.should have_selector('html > head + body')
39
42
  document.should have_selector('body #message h1')
40
- document.should have_styling('background' => 'url(http://example.app.org/images/dots.png) repeat-x').at_selector('body')
43
+ document.should have_styling('background' => 'url(https://example.app.org/images/dots.png) repeat-x').at_selector('body')
41
44
  document.should have_selector('strong[contains("quota")]')
42
45
  end
43
46
 
@@ -23,7 +23,7 @@ describe Roadie do
23
23
  end
24
24
 
25
25
  describe ".current_provider" do
26
- let(:provider) { Object.new }
26
+ let(:provider) { double("provider instance") }
27
27
 
28
28
  context "with a set provider in the config" do
29
29
  it "uses the set provider" do
data/spec/spec_helper.rb CHANGED
@@ -15,18 +15,15 @@ end
15
15
  require 'rspec'
16
16
  require 'rails'
17
17
  require 'sprockets'
18
- require 'roadie'
18
+
19
+ require 'roadie/railtie'
20
+ require 'action_mailer/railtie'
19
21
 
20
22
  FIXTURES_PATH = Pathname.new(File.dirname(__FILE__)).join('fixtures')
21
- Roadie::Railtie.run_initializers
22
23
 
23
- class TestApplication
24
+ class TestApplication < Rails::Application
24
25
  def config
25
- @config ||= OpenStruct.new({
26
- :action_mailer => OpenStruct.new(:default_url_options => {:host => "example.com"}),
27
- :assets => OpenStruct.new(:enabled => false),
28
- :roadie => OpenStruct.new(:provider => nil),
29
- })
26
+ @config
30
27
  end
31
28
 
32
29
  def assets
@@ -38,11 +35,23 @@ class TestApplication
38
35
  def root
39
36
  FIXTURES_PATH
40
37
  end
38
+
39
+ def reset_test_config
40
+ @config = OpenStruct.new({
41
+ :action_mailer => OpenStruct.new(:default_url_options => {}),
42
+ :assets => OpenStruct.new(:enabled => false),
43
+ :roadie => OpenStruct.new(:provider => nil),
44
+ })
45
+ change_default_url_options(:host => "example.com")
46
+ end
41
47
  end
42
48
 
49
+ ActionMailer::Railtie.run_initializers(:default, Rails.application)
50
+ Roadie::Railtie.run_initializers(:default, Rails.application)
51
+
43
52
  RSpec.configure do |c|
44
53
  c.before(:each) do
45
- Rails.stub(:application => TestApplication.new)
54
+ Rails.application.reset_test_config
46
55
  end
47
56
  end
48
57
 
@@ -0,0 +1,5 @@
1
+ # ActionMailer::Base loads the default_url_options on startup via its Railtie
2
+ def change_default_url_options(new_options)
3
+ Rails.application.config.action_mailer.default_url_options = new_options
4
+ ActionMailer::Base.default_url_options = new_options
5
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: roadie
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.1.0
5
+ version: 2.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Magnus Bergmark
@@ -183,6 +183,7 @@ files:
183
183
  - spec/lib/roadie_spec.rb
184
184
  - spec/shared_examples/asset_provider_examples.rb
185
185
  - spec/spec_helper.rb
186
+ - spec/support/change_url_options.rb
186
187
  - spec/support/have_attribute_matcher.rb
187
188
  - spec/support/have_selector_matcher.rb
188
189
  - spec/support/have_styling_matcher.rb
@@ -231,6 +232,7 @@ test_files:
231
232
  - spec/lib/roadie_spec.rb
232
233
  - spec/shared_examples/asset_provider_examples.rb
233
234
  - spec/spec_helper.rb
235
+ - spec/support/change_url_options.rb
234
236
  - spec/support/have_attribute_matcher.rb
235
237
  - spec/support/have_selector_matcher.rb
236
238
  - spec/support/have_styling_matcher.rb