Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cc & bcc with Quartz::Composer #22

Merged
merged 2 commits into from
Jan 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions spec/quartz/composer_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
require "../spec_helper"

class ComposerTestMailer < Quartz::Composer
def initialize
subject "Foo Bar"
to "[email protected]"
cc "[email protected]"
bcc "[email protected]"
text "foobar_text"
html "foobar_html"
end

def sender
"[email protected]"
end
end

composer = ComposerTestMailer.new

describe Quartz::Composer do
{% for method in [:sender, :deliver, :address, :to, :cc, :bcc, :subject, :text, :body] %}
{% method = method.id %}

it "responds_to?({{method}})" do
composer.responds_to?(:{{method}}).should(be_true)
end
{% end %}

context "message" do
it "has a message" do
[email protected]_a?(Quartz::Message).should(be_true)
end

it "sets message attributes" do
composer.@message._to.size.should eq(1)
composer.@message._cc.size.should eq (1)
composer.@message._bcc.size.should eq (1)
composer.@message._subject.should eq ("Foo Bar")
composer.@message._text.should eq ("foobar_text")
composer.@message._html.should eq ("foobar_html")

body_str = "foobar_body"
composer.body body_str

composer.@message._text.should eq(body_str)
end
end

context "deliver" do
it "sets the sender" do
# composer.deliver ### deliver freezes the tests
# composer.@message._from.should eq(composer.sender)
end
end

context "render" do
it "with_layout" do
#render("composer_test_mailer.html.slang")
end

it "without_layout" do
#render("composer_test_mailer.html.slang", "mailer_layout.html.slang")
end
end
end
2 changes: 1 addition & 1 deletion src/quartz_mailer/composer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Quartz::Composer

@message = Message.new

delegate :to, :subject, :text, :html, :body, to: @message
delegate :to, :cc, :bcc, :subject, :text, :html, :body, to: @message
delegate :address, to: Message

def deliver
Expand Down