-
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.
- Loading branch information
Showing
4 changed files
with
66 additions
and
23 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 |
---|---|---|
|
@@ -30,15 +30,15 @@ | |
it "handles email only" do | ||
test_email = Mailer.test_email bcc: "[email protected], [email protected]" | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:recipients]).to eq([{address: {email: "[email protected]"}}, {address: {email: "[email protected]", header_to: "[email protected]"}}, {address: {email: "[email protected]", header_to: "[email protected]"}}]) | ||
expect(@delivery_method.data[:content]).not_to include(:headers) | ||
end | ||
|
||
it "handles name and email" do | ||
test_email = Mailer.test_email to: "Joe Test <[email protected]>", bcc: "Brock Test <[email protected]>, Brack Test <[email protected]>" | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:recipients]).to eq([{address: {email: "[email protected]", name: "Joe Test"}}, {address: {email: "[email protected]", name: "Brock Test", header_to: "[email protected]"}}, {address: {email: "[email protected]", name: "Brack Test", header_to: "[email protected]"}}]) | ||
expect(@delivery_method.data[:content]).not_to include(:headers) | ||
end | ||
|
@@ -56,23 +56,23 @@ | |
it "handles email only" do | ||
test_email = Mailer.test_email to: "[email protected], [email protected]", cc: "[email protected]", bcc: "[email protected]" | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:recipients]).to eq([{address: {email: "[email protected]"}}, {address: {email: "[email protected]"}}, {address: {email: "[email protected]", header_to: "[email protected]"}}, {address: {email: "[email protected]", header_to: "[email protected]"}}]) | ||
expect(@delivery_method.data[:content][:headers]).to eq({cc: ["[email protected]"]}) | ||
end | ||
|
||
it "handles name and email" do | ||
test_email = Mailer.test_email to: "Joe Test <[email protected]>, Sam Test <[email protected]>", cc: "Carl Test <[email protected]>", bcc: "Brock Test <[email protected]>" | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:recipients]).to eq([{address: {email: "[email protected]", name: "Joe Test"}}, {address: {email: "[email protected]", name: "Sam Test"}}, {address: {email: "[email protected]", name: "Carl Test", header_to: "[email protected]"}}, {address: {email: "[email protected]", name: "Brock Test", header_to: "[email protected]"}}]) | ||
expect(@delivery_method.data[:content][:headers]).to eq({cc: ["[email protected]"]}) | ||
end | ||
|
||
it "handles mix of email only and name/email" do | ||
test_email = Mailer.test_email to: "Joe Test <[email protected]>, [email protected]", cc: "[email protected], Chris Test <[email protected]>", bcc: "Brock Test <[email protected]>, [email protected]" | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:recipients]).to eq([{address: {email: "[email protected]", name: "Joe Test"}}, {address: {email: "[email protected]"}}, {address: {email: "[email protected]", header_to: "[email protected]"}}, {address: {email: "[email protected]", name: "Chris Test", header_to: "[email protected]"}}, {address: {email: "[email protected]", name: "Brock Test", header_to: "[email protected]"}}, {address: {email: "[email protected]", header_to: "[email protected]"}}]) | ||
expect(@delivery_method.data[:content][:headers]).to eq({cc: ["[email protected]", "[email protected]"]}) | ||
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 |
---|---|---|
|
@@ -29,15 +29,15 @@ | |
it "handles email only" do | ||
test_email = Mailer.test_email cc: "[email protected], [email protected]" | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:recipients]).to eq([{address: {email: "[email protected]"}}, {address: {email: "[email protected]", header_to: "[email protected]"}}, {address: {email: "[email protected]", header_to: "[email protected]"}}]) | ||
expect(@delivery_method.data[:content][:headers]).to eq({cc: ["[email protected]", "[email protected]"]}) | ||
end | ||
|
||
it "handles name and email" do | ||
test_email = Mailer.test_email to: "Joe Test <[email protected]>", cc: "Carl Test <[email protected]>, Chris Test <[email protected]>" | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:recipients]).to eq([{address: {email: "[email protected]", name: "Joe Test"}}, {address: {email: "[email protected]", name: "Carl Test", header_to: "[email protected]"}}, {address: {email: "[email protected]", name: "Chris Test", header_to: "[email protected]"}}]) | ||
expect(@delivery_method.data[:content][:headers]).to eq({cc: ["[email protected]", "[email protected]"]}) | ||
end | ||
|
@@ -55,15 +55,15 @@ | |
it "handles email only" do | ||
test_email = Mailer.test_email to: "[email protected], [email protected]", cc: "[email protected]" | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:recipients]).to eq([{address: {email: "[email protected]"}}, {address: {email: "[email protected]"}}, {address: {email: "[email protected]", header_to: "[email protected]"}}]) | ||
expect(@delivery_method.data[:content][:headers]).to eq({cc: ["[email protected]"]}) | ||
end | ||
|
||
it "handles name and email" do | ||
test_email = Mailer.test_email to: "Joe Test <[email protected]>, Sam Test <[email protected]>", cc: "Carl Test <[email protected]>" | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:recipients]).to eq([{address: {email: "[email protected]", name: "Joe Test"}}, {address: {email: "[email protected]", name: "Sam Test"}}, {address: {email: "[email protected]", name: "Carl Test", header_to: "[email protected]"}}]) | ||
expect(@delivery_method.data[:content][:headers]).to eq({cc: ["[email protected]"]}) | ||
end | ||
|
@@ -73,23 +73,23 @@ | |
it "handles email only" do | ||
test_email = Mailer.test_email to: "[email protected], [email protected]", cc: "[email protected], [email protected]" | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:recipients]).to eq([{address: {email: "[email protected]"}}, {address: {email: "[email protected]"}}, {address: {email: "[email protected]", header_to: "[email protected]"}}, {address: {email: "[email protected]", header_to: "[email protected]"}}]) | ||
expect(@delivery_method.data[:content][:headers]).to eq({cc: ["[email protected]", "[email protected]"]}) | ||
end | ||
|
||
it "handles name and email" do | ||
test_email = Mailer.test_email to: "Joe Test <[email protected]>, Sam Test <[email protected]>", cc: "Carl Test <[email protected]>, Chris Test <[email protected]>" | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:recipients]).to eq([{address: {email: "[email protected]", name: "Joe Test"}}, {address: {email: "[email protected]", name: "Sam Test"}}, {address: {email: "[email protected]", name: "Carl Test", header_to: "[email protected]"}}, {address: {email: "[email protected]", name: "Chris Test", header_to: "[email protected]"}}]) | ||
expect(@delivery_method.data[:content][:headers]).to eq({cc: ["[email protected]", "[email protected]"]}) | ||
end | ||
|
||
it "handles mix of email only and name/email for to recipients" do | ||
test_email = Mailer.test_email to: "Joe Test <[email protected]>, [email protected]", cc: "[email protected], Chris Test <[email protected]>" | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:recipients]).to eq([{address: {email: "[email protected]", name: "Joe Test"}}, {address: {email: "[email protected]"}}, {address: {email: "[email protected]", header_to: "[email protected]"}}, {address: {email: "[email protected]", name: "Chris Test", header_to: "[email protected]"}}]) | ||
expect(@delivery_method.data[:content][:headers]).to eq({cc: ["[email protected]", "[email protected]"]}) | ||
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,34 @@ | ||
require 'spec_helper' | ||
|
||
describe SparkPostRails::DeliveryMethod do | ||
|
||
before(:each) do | ||
@delivery_method = SparkPostRails::DeliveryMethod.new | ||
end | ||
|
||
context "Recipients List" do | ||
|
||
it "handles a list_id" do | ||
test_email = Mailer.test_email sparkpost_data: {recipient_list_id: "List1"} | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:recipients]).to eq({list_id: "List1"}) | ||
end | ||
|
||
it "ignores any CC addresses" do | ||
test_email = Mailer.test_email cc: "[email protected]", sparkpost_data: {recipient_list_id: "List1"} | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:recipients]).to eq({list_id: "List1"}) | ||
expect(@delivery_method.data[:content].has_key?(:headers)).to eq(false) | ||
end | ||
|
||
it "ignores any BCC addresses" do | ||
test_email = Mailer.test_email bcc: "[email protected]", sparkpost_data: {recipient_list_id: "List1"} | ||
@delivery_method.deliver!(test_email) | ||
|
||
expect(@delivery_method.data[:recipients]).to eq({list_id: "List1"}) | ||
end | ||
end | ||
|
||
end |