forked from mailboxer/mailboxer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad06bb7
commit 1dc688b
Showing
8 changed files
with
58 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'active_support/inflections' | ||
|
||
module Concerns | ||
module ConfigurableMailer | ||
|
||
def get_mailer | ||
return @mailer if @mailer | ||
method = "#{self.class.to_s.downcase}_mailer".to_sym | ||
@mailer = Mailboxer.send(method) || "#{self.class}Mailer".constantize | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'spec_helper' | ||
describe Concerns::ConfigurableMailer do | ||
|
||
describe "Notification instance#get_mailer" do | ||
before { @obj = Notification.new } | ||
it "returns default_mailer" do | ||
@obj.get_mailer.should eq NotificationMailer | ||
end | ||
it "returns 'foo' from Mailerbox.notification_mailer" do | ||
Mailboxer.notification_mailer = 'foo' | ||
@obj.get_mailer.should eq 'foo' | ||
end | ||
after { Mailboxer.notification_mailer = nil } | ||
end | ||
|
||
describe "Message instance#get_mailer" do | ||
before { @obj = Message.new } | ||
it "returns default_mailer" do | ||
@obj.get_mailer.should eq MessageMailer | ||
end | ||
it "returns 'foo' from Mailerbox.message_mailer" do | ||
Mailboxer.message_mailer = 'foo' | ||
@obj.get_mailer.should eq 'foo' | ||
end | ||
after { Mailboxer.message_mailer = nil } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters