Permalink
Browse files

Correct the Rails configuration calls

I misunderstood how config.action_mailer worked
in Rails. I though those configs were accessible
from ActionMailer::Base.config. I was horribly
wrong.
  • Loading branch information...
1 parent 487d574 commit f1a03f86b2eac32b1661cf9d13b21a10d0f06413 @Mange Mange committed Oct 27, 2010
View
@@ -55,7 +55,7 @@ If you have _default_url_options[:host]_ set in your mailer, then MailStyle will
In @application.rb@:
<pre><code>class Application
- config.default_url_options = {:host => 'example.com'}
+ config.action_mailer.default_url_options = {:host => 'example.com'}
end</code></pre>
h3. Ignoring stylesheets
@@ -29,7 +29,7 @@ def collect_responses_and_parts_order_with_inline_styles(headers, &block)
private
def inline_style_response(response)
if response[:content_type] == 'text/html'
- response.merge :body => MailStyle.inline_css(css_rules, response[:body], config.default_url_options)
+ response.merge :body => MailStyle.inline_css(css_rules, response[:body], Rails.application.config.action_mailer.default_url_options)
else
response
end
View
@@ -1,12 +1,14 @@
require 'spec_helper'
describe "mail_style integration" do
+ class TestApplication
+ def config
+ OpenStruct.new(:action_mailer => OpenStruct.new(:default_url_options => {:host => "example.app.org"}))
+ end
+ end
+
class IntegrationMailer < ActionMailer::Base
default :css => :integration, :from => 'john@example.com'
-
- configure do |config|
- config.default_url_options = {:host => "example.app.org"}
- end
append_view_path Pathname.new(__FILE__).dirname.join('fixtures').join('views')
def notification(to, reason)
@@ -16,7 +18,7 @@ def notification(to, reason)
end
before(:each) do
- Rails.stub!(:root => Pathname.new(__FILE__).dirname.join('fixtures'))
+ Rails.stub!(:root => Pathname.new(__FILE__).dirname.join('fixtures'), :application => TestApplication.new)
end
it "should inline styles for an email" do
@@ -5,10 +5,6 @@
class InliningMailer < ActionMailer::Base
default :css => :simple
- configure do
- default_url_options = {:host => "example.org"}
- end
-
def multipart
mail(:subject => "Multipart email") do |format|
format.html { render :text => 'Hello HTML' }
View
@@ -1,5 +1,6 @@
$: << File.dirname(__FILE__) + '/../lib'
+require 'ostruct'
require 'rubygems'
require 'bundler'
@@ -15,19 +16,21 @@
require 'action_mailer'
require 'mail_style'
+class TestApplication
+ def config
+ OpenStruct.new(:action_mailer => OpenStruct.new(:default_url_options => {:host => "example.com"}))
+ end
+end
+
if defined?(Rails)
- Rails.stub!(:root => Pathname.new('/path/to'))
+ Rails.stub!(:root => Pathname.new('/path/to'), :application => TestApplication.new)
else
class Rails
def self.root; Pathname.new('/path/to'); end
+ def self.application; TestApplication.new; end
end
end
-ActionMailer::Base.configure do |config|
- config.perform_deliveries = false
- config.default_url_options = {:host => "example.com"}
-end
-
RSpec::Matchers.define :have_styling do |rules|
chain :at_selector do |selector|
@selector = selector

0 comments on commit f1a03f8

Please sign in to comment.