-
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.
Implement support for Campaign ID on an individual message
- Loading branch information
Showing
3 changed files
with
77 additions
and
22 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,64 @@ | ||
require 'spec_helper' | ||
|
||
describe SparkPostRails::DeliveryMethod do | ||
|
||
before(:each) do | ||
SparkPostRails.configuration.set_defaults | ||
@delivery_method = SparkPostRails::DeliveryMethod.new | ||
end | ||
|
||
context "Campaign ID" do | ||
it "handles campaign id in the configuration" do | ||
SparkPostRails.configure do |c| | ||
c.campaign_id = "ABCD1234" | ||
end | ||
|
||
test_email = Mailer.test_email | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:campaign_id]).to eq("ABCD1234") | ||
end | ||
|
||
it "handles campaign id on an individual message" do | ||
test_email = Mailer.test_email sparkpost_data: {campaign_id: "My Campaign"} | ||
|
||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:campaign_id]).to eq("My Campaign") | ||
end | ||
|
||
it "handles the value on an individual message overriding configuration" do | ||
SparkPostRails.configure do |c| | ||
c.campaign_id = "ABCD1234" | ||
end | ||
|
||
test_email = Mailer.test_email sparkpost_data: {campaign_id: "My Campaign"} | ||
|
||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:campaign_id]).to eq("My Campaign") | ||
end | ||
|
||
it "handles the value on an individual message of nil overriding configuration" do | ||
SparkPostRails.configure do |c| | ||
c.campaign_id = "ABCD1234" | ||
end | ||
|
||
test_email = Mailer.test_email sparkpost_data: {campaign_id: nil} | ||
|
||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data.has_key?(:campaign_id)).to eq(false) | ||
end | ||
|
||
it "handles a default setting of none" do | ||
test_email = Mailer.test_email | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data.has_key?(:campaign_id)).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