-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from EvgeniyShelest/inherit_defaults
Inherit defaults
- Loading branch information
Showing
2 changed files
with
28 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,13 +47,22 @@ def example_email | |
|
||
describe "using default to set a parameter" do | ||
class MailerWithDefault < SendWithUsMailer::Base | ||
default email_id: 'def-4bBEddKbhKBu5xsU2p58KX' | ||
default email_id: 'def-4bBEddKbhKBu5xsU2p58KX', | ||
from_address: 'from@mailer_with_default.com', | ||
reply_to: 'reply_to@mailer_with_default.com' | ||
|
||
def send_an_email | ||
mail recipient_address: '[email protected]' | ||
end | ||
end | ||
|
||
class InheritDefaultsMailer < MailerWithDefault | ||
end | ||
|
||
class ReplacedDefaultsMailer < MailerWithDefault | ||
default from_address: 'from@replaced_defaults_mailer.com' | ||
end | ||
|
||
it "sets the email_id" do | ||
mail = MailerWithDefault.send_an_email | ||
mail.email_id.must_equal 'def-4bBEddKbhKBu5xsU2p58KX' | ||
|
@@ -63,6 +72,19 @@ def send_an_email | |
mail = MailerWithDefault.send_an_email | ||
mail.to[:address].must_equal '[email protected]' | ||
end | ||
|
||
it "inherits defaults from ancestor" do | ||
InheritDefaultsMailer.defaults[:from_address].must_equal 'from@mailer_with_default.com' | ||
InheritDefaultsMailer.defaults[:reply_to].must_equal 'reply_to@mailer_with_default.com' | ||
end | ||
|
||
it "replaces ancestor defaults by own" do | ||
ReplacedDefaultsMailer.defaults[:from_address].must_equal 'from@replaced_defaults_mailer.com' | ||
end | ||
|
||
it "uses ancestors defaults that has not been replaced by own" do | ||
ReplacedDefaultsMailer.defaults[:reply_to].must_equal 'reply_to@mailer_with_default.com' | ||
end | ||
end | ||
|
||
describe "all parameters can be set by default" do | ||
|