Skip to content

Commit 465d7c8

Browse files
committed
Add mailto
1 parent 4b2a11b commit 465d7c8

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

spec/supermail_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,42 @@ def initialize(to:, from:, subject:, body:)
4242
it "sets the body" do
4343
expect(subject.body.to_s).to eq("Hi there")
4444
end
45+
46+
describe "#mailto" do
47+
let(:full_mailer_class) do
48+
Class.new(Supermail::Rails::Base) do
49+
def initialize(to:, from:, subject:, body:, cc:, bcc:)
50+
@to = to
51+
@from = from
52+
@subject = subject
53+
@body = body
54+
@cc = cc
55+
@bcc = bcc
56+
end
57+
58+
attr_reader :to, :from, :subject, :body, :cc, :bcc
59+
end
60+
end
61+
62+
let(:full_mailer) do
63+
full_mailer_class.new(
64+
to: "recipient@example.com",
65+
from: "sender@example.com",
66+
subject: "Test Subject",
67+
body: "Test body content",
68+
cc: ["cc@example.com"],
69+
bcc: ["bcc@example.com"]
70+
)
71+
end
72+
73+
it "passes all mail fields to the mailto URL" do
74+
result = full_mailer.mailto
75+
expect(result).to start_with("mailto:recipient@example.com?")
76+
expect(result).to include("from=sender%40example.com")
77+
expect(result).to include("subject=Test%20Subject")
78+
expect(result).to include("body=Test%20body%20content")
79+
expect(result).to include("cc=%5B%22cc%40example.com%22%5D")
80+
expect(result).to include("bcc=%5B%22bcc%40example.com%22%5D")
81+
end
82+
end
4583
end

0 commit comments

Comments
 (0)