Skip to content

Commit

Permalink
👷 (Github Actions): Build Cron in CI
Browse files Browse the repository at this point in the history
💚 (Github Actions): Cron adjust to: At 07:00 on Monday.
  • Loading branch information
dlanileonardo committed May 7, 2020
1 parent 95926c1 commit 5aa892c
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 27 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI
on:
push:
pull_request:
schedule:
- cron: '0 7 * * 1'

jobs:
unit-test:
name: build and unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Crystal
run: |
curl -sSL https://dist.crystal-lang.org/apt/setup.sh | sudo bash
sudo apt install crystal
crystal --version
shards --version
- run: shards install
- run: crystal build src/sendgrid.cr
- run: crystal spec
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
crystal 0.34.0
1 change: 0 additions & 1 deletion .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Simple lib to send mail using Sendgrid in Crystal-Lang

[![Build Status](https://travis-ci.org/dlanileonardo/sendgrid.cr.svg?branch=master)](https://travis-ci.org/dlanileonardo/sendgrid.cr)
![CI](https://github.com/dlanileonardo/sendgrid.cr/workflows/CI/badge.svg)

## Installation

Expand Down
4 changes: 2 additions & 2 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: sendgrid
version: 0.1.0
version: 0.1.1

authors:
- Dlani <dlanileonardo@gmail.com>

crystal: 0.20.1
crystal: 0.34.0

license: MIT
55 changes: 32 additions & 23 deletions spec/sendgrid_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,40 @@ describe Sendgrid do
message.to << Sendgrid::Address.new(email="lukeskywalker@starwars.stars", name="Luke Skywalker")
message.subject = "Good News"
message.content = Sendgrid::Content.new("No, I am your father.")
extra_fields = {
"template_id" => "death_star",
"asm" => {
"group_id" => "skywalkers",
"groups_to_display" => "skywalkers"
} of String => Sendgrid::ExtraFieldsType,
"attachments" => [
{
"content" => "Blue LightSaber",
"filename" => "blulightsaber.png"
} of String => Sendgrid::ExtraFieldsType
] of Sendgrid::ExtraFieldsType
} of String => Sendgrid::ExtraFieldsType
message.extra_fields.merge!(extra_fields)

object_parse = JSON.parse(message.to_json)
message.to_json.should be_a(String)

object_parse.should contain("personalizations")

object_parse["personalizations"][0].should contain("to")
object_parse["personalizations"][0]["to"][0].should contain("email")
object_parse["personalizations"][0]["to"][0].should contain("name")

object_parse.should contain("from")
object_parse["from"].should contain("email")
object_parse["from"].should contain("name")

object_parse.should contain("reply_to")
object_parse["reply_to"].should contain("email")
object_parse["reply_to"].should contain("name")

object_parse.should contain("subject")
object_parse["subject"].should eq("Good News")

object_parse.should contain("content")
object_parse["content"][0].should contain("type")
object_parse["content"][0].should contain("value")
object_parse["content"][0]["value"].should eq("No, I am your father.")

object_parse = JSON.parse(message.to_json)

object_parse["from"]["name"].should eq "Darth Vader"
object_parse["from"]["email"].should eq "darthvader@host.com"

object_parse["reply_to"]["name"].should eq "Anakin Skywalker"
object_parse["reply_to"]["email"].should eq "anakinskywalker@starwars.stars"

object_parse["personalizations"].size.should eq 1
object_parse["personalizations"][0]["to"][0]["name"].should eq "Luke Skywalker"
object_parse["personalizations"][0]["to"][0]["email"].should eq "lukeskywalker@starwars.stars"

object_parse["content"].size.should eq 1
object_parse["content"][0]["type"].should eq "text/plain"
object_parse["content"][0]["value"].should eq "No, I am your father."

object_parse["subject"].should eq "Good News"
end
end
end

0 comments on commit 5aa892c

Please sign in to comment.