-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We want to store the tempalte id, personalisation, reference and reply to id options inside the `message` object, right now these are added to the header of the message, which feels a little clunky. Here we use the existing module to add the attributes to message so we can set and get the values. We also drop the `preview` method, this method hides the fact that the impelmentation of the `preview` method is in the DeliveryMethod - on balance the extra code to call the method seems worth the price of the understanding where messages are being sent - to be honest, it already feels odd that the message calls a method and passes it self - but that might just be me?
- Loading branch information
Showing
3 changed files
with
32 additions
and
33 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 was deleted.
Oops, something went wrong.
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,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
class FakeTestClass | ||
include Mail::Notify::Message | ||
end | ||
|
||
RSpec.describe Mail::Notify::Message do | ||
subject { FakeTestClass.new } | ||
|
||
it "adds a template_id attribute" do | ||
expect(subject.template_id = "template-id").to eql "template-id" | ||
expect(subject.template_id).to eql "template-id" | ||
end | ||
|
||
it "adds a personalisation attribute" do | ||
expect(subject.personalisation = {name: "Test Name"}).to eql({name: "Test Name"}) | ||
expect(subject.personalisation).to eql({name: "Test Name"}) | ||
end | ||
|
||
it "adds the reply_to_id attribute" do | ||
expect(subject.reply_to_id = "test-reply-to-id").to eql("test-reply-to-id") | ||
expect(subject.reply_to_id).to eql("test-reply-to-id") | ||
end | ||
|
||
it "adds the reference attribute" do | ||
expect(subject.reference = "test-reference").to eql("test-reference") | ||
expect(subject.reference).to eql("test-reference") | ||
end | ||
end |