-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break out substitution data into it's own spec, and support its usage…
… with inline content
- Loading branch information
Showing
3 changed files
with
52 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'spec_helper' | ||
|
||
describe SparkPostRails::DeliveryMethod do | ||
|
||
before(:each) do | ||
@delivery_method = SparkPostRails::DeliveryMethod.new | ||
end | ||
|
||
context "Substitution Data" do | ||
|
||
it "accepts substitution data with template-based message" do | ||
sub_data = {item_1: "test data 1", item_2: "test data 2"} | ||
|
||
test_email = Mailer.test_email sparkpost_data: {template_id: "test_template", substitution_data: sub_data} | ||
|
||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:substitution_data]).to eq(sub_data) | ||
end | ||
|
||
it "accepts substitution data with inline-content message" do | ||
sub_data = {item_1: "test data 1", item_2: "test data 2"} | ||
|
||
test_email = Mailer.test_email sparkpost_data: {substitution_data: sub_data} | ||
|
||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:substitution_data]).to eq(sub_data) | ||
end | ||
|
||
it "does not include substitution data element if none is passed" do | ||
test_email = Mailer.test_email sparkpost_data: {template_id: "test_template"} | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data.has_key?(:substitution_data)).to eq(false) | ||
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