-
Notifications
You must be signed in to change notification settings - Fork 322
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 #265 from rohan-techfreak/rohankh-patch-1
Fix #246, Modified Mail Class calling with SendGrid::Mail
- Loading branch information
Showing
3 changed files
with
18 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,7 +150,7 @@ I hope you are having a great day in -city- :) | |
require 'sendgrid-ruby' | ||
include SendGrid | ||
|
||
mail = Mail.new | ||
mail = SendGrid::Mail.new | ||
mail.from = Email.new(email: '[email protected]') | ||
mail.subject = 'I\'m replacing the subject tag' | ||
personalization = Personalization.new | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ def hello_world | |
subject = 'Hello World from the SendGrid Ruby Library' | ||
to = Email.new(email: '[email protected]') | ||
content = Content.new(type: 'text/plain', value: 'some text here') | ||
mail = Mail.new(from, subject, to, content) | ||
mail = SendGrid::Mail.new(from, subject, to, content) | ||
# puts JSON.pretty_generate(mail.to_json) | ||
puts mail.to_json | ||
|
||
|
@@ -19,7 +19,7 @@ def hello_world | |
end | ||
|
||
def kitchen_sink | ||
mail = Mail.new | ||
mail = SendGrid::Mail.new | ||
mail.from = Email.new(email: '[email protected]') | ||
mail.subject = 'Hello World from the SendGrid Ruby Library' | ||
personalization = Personalization.new | ||
|
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 |
---|---|---|
|
@@ -13,13 +13,13 @@ def test_hello_world | |
to = Email.new(email: '[email protected]') | ||
subject = 'Sending with SendGrid is Fun' | ||
content = Content.new(type: 'text/plain', value: 'and easy to do anywhere, even with Ruby') | ||
mail = Mail.new(from, subject, to, content) | ||
mail = SendGrid::Mail.new(from, subject, to, content) | ||
|
||
assert_equal(mail.to_json, JSON.parse('{"from":{"email":"[email protected]"}, "subject":"Sending with SendGrid is Fun", "personalizations":[{"to":[{"email":"[email protected]"}]}], "content":[{"type":"text/plain", "value":"and easy to do anywhere, even with Ruby"}]}')) | ||
end | ||
|
||
def test_kitchen_sink | ||
mail = Mail.new | ||
mail = SendGrid::Mail.new | ||
mail.from = Email.new(email: "[email protected]") | ||
mail.subject = "Hello World from the SendGrid Ruby Library" | ||
personalization = Personalization.new | ||
|
@@ -119,39 +119,39 @@ def test_kitchen_sink | |
end | ||
|
||
def test_that_personalizations_is_empty_initially | ||
mail = Mail.new | ||
mail = SendGrid::Mail.new | ||
assert_equal([], mail.personalizations) | ||
end | ||
|
||
def test_that_contents_is_empty_initially | ||
mail = Mail.new | ||
mail = SendGrid::Mail.new | ||
assert_equal([], mail.contents) | ||
end | ||
|
||
def test_that_attachments_is_empty_initially | ||
mail = Mail.new | ||
mail = SendGrid::Mail.new | ||
assert_equal([], mail.attachments) | ||
end | ||
|
||
def test_that_categories_is_empty_initially | ||
mail = Mail.new | ||
mail = SendGrid::Mail.new | ||
assert_equal([], mail.categories) | ||
end | ||
|
||
def test_add_personalization | ||
mail = Mail.new | ||
mail = SendGrid::Mail.new | ||
mail.add_personalization('foo') | ||
assert_equal(['foo'.to_json], mail.personalizations) | ||
end | ||
|
||
def test_add_content | ||
mail = Mail.new | ||
mail = SendGrid::Mail.new | ||
mail.add_content('foo') | ||
assert_equal(['foo'.to_json], mail.contents) | ||
end | ||
|
||
def test_add_section | ||
mail = Mail.new | ||
mail = SendGrid::Mail.new | ||
mail.add_section(Section.new(key: '%section1%', value: 'Substitution Text for Section 1')) | ||
expected_json = { | ||
"sections"=>{ | ||
|
@@ -170,7 +170,7 @@ def test_add_section | |
end | ||
|
||
def test_add_header | ||
mail = Mail.new | ||
mail = SendGrid::Mail.new | ||
mail.add_header(Header.new(key: 'X-Test3', value: 'test3')) | ||
expected_json = { | ||
"headers"=>{ | ||
|
@@ -189,7 +189,7 @@ def test_add_header | |
end | ||
|
||
def test_add_custom_arg | ||
mail = Mail.new | ||
mail = SendGrid::Mail.new | ||
mail.add_custom_arg(CustomArg.new(key: 'campaign 1', value: 'welcome 1')) | ||
expected_json = { | ||
"custom_args"=>{ | ||
|
@@ -223,20 +223,20 @@ def test_add_non_string_custom_arg | |
end | ||
|
||
def test_add_attachment | ||
mail = Mail.new | ||
mail = SendGrid::Mail.new | ||
mail.add_attachment('foo') | ||
assert_equal(['foo'.to_json], mail.attachments) | ||
end | ||
|
||
def test_add_valid_category | ||
mail = Mail.new | ||
mail = SendGrid::Mail.new | ||
category = Category.new(name: 'foo') | ||
mail.add_category(category) | ||
assert_equal(['foo'], mail.categories) | ||
end | ||
|
||
def test_add_more_than_1_valid_category | ||
mail = Mail.new | ||
mail = SendGrid::Mail.new | ||
category_1 = Category.new(name: 'foo') | ||
category_2 = Category.new(name: 'bar') | ||
mail.add_category(category_1) | ||
|
@@ -245,7 +245,7 @@ def test_add_more_than_1_valid_category | |
end | ||
|
||
def test_add_invalid_category | ||
mail = Mail.new | ||
mail = SendGrid::Mail.new | ||
assert_raises(NoMethodError) do | ||
mail.add_category('foo') | ||
end | ||
|