Skip to content

Commit

Permalink
Added specs for inherit_views with ActionMailer::Base
Browse files Browse the repository at this point in the history
(cherry-pick of 623a79a)
  • Loading branch information
ianwhite committed Feb 9, 2009
1 parent 7c3cdb3 commit 64bd746
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
15 changes: 15 additions & 0 deletions spec/app.rb
Expand Up @@ -30,3 +30,18 @@ class DController < AController
# used to test normal rails behaviour
class NormalController < InheritViewsTestController
end

# used to test ActionMailer's use of views is not affected
class NormalMailer < ActionMailer::Base
self.template_root = File.join(File.dirname(__FILE__), 'views_for_specs')

def email
recipients 'test@test.com'
subject 'An email'
end
end

# inherits views form normal mailer
class InheritingMailer < NormalMailer
#inherit_views 'normal_mailer'
end
38 changes: 38 additions & 0 deletions spec/mailers/mailer_spec.rb
@@ -0,0 +1,38 @@
require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper'))

describe 'Mailer specs' do
before :all do
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
end

describe NormalMailer do
before :each do
NormalMailer.deliver_email
@deliveries = ActionMailer::Base.deliveries
end

it "should deliver email" do
@deliveries.size.should == 1
end

it "should render email with partial" do
@deliveries.first.body.should == "normal_mailer:email\nnormal_mailer:_partial"
end
end

describe InheritingMailer do
before :each do
InheritingMailer.deliver_email
@deliveries = ActionMailer::Base.deliveries
end

it "should deliver email" do
@deliveries.size.should == 1
end

it "should render email with inherited partial" do
@deliveries.first.body.should == "inheriting_mailer:email\nnormal_mailer:_partial"
end
end
end
2 changes: 2 additions & 0 deletions spec/views_for_specs/inheriting_mailer/email.erb
@@ -0,0 +1,2 @@
inheriting_mailer:email
<%= render 'partial' %>
1 change: 1 addition & 0 deletions spec/views_for_specs/normal_mailer/_partial.erb
@@ -0,0 +1 @@
normal_mailer:_partial
2 changes: 2 additions & 0 deletions spec/views_for_specs/normal_mailer/email.erb
@@ -0,0 +1,2 @@
normal_mailer:email
<%= render 'partial' %>

0 comments on commit 64bd746

Please sign in to comment.