customerio-rails 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/customerio-rails/mail.rb +10 -2
- data/lib/customerio-rails/version.rb +1 -1
- data/spec/delivery_spec.rb +30 -3
- data/spec/fixtures/models/test_mailer.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f61734cc94dee78031fa7d1737b8fc4add5d600924714a54dd0dffeeb3d79922
|
4
|
+
data.tar.gz: 16e2e3011627b8331a6efac3452390b46736bf8d164177f5208eb3edf16da1c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0849f2c2c8dfd524e203c7cfae32fd7a81d76069b3b5cac94f9c5080be83319aecafca309fc072d0b72aef932805029687659152cbb53b4579481ecc26731ac9'
|
7
|
+
data.tar.gz: '079842f178dc0042cea0fc27e0c43720437957056b2f807e54cae3260f84f8ba673b6ddf99a2a477caaec1cb3a3026f73b257cc75939e966785d7fdd74372d72'
|
@@ -21,15 +21,23 @@ module CustomerioRails
|
|
21
21
|
reply_to: mail.reply_to,
|
22
22
|
bcc: mail.bcc,
|
23
23
|
headers: mail.headers,
|
24
|
-
identifiers: { email: to }
|
24
|
+
identifiers: { email: to }
|
25
25
|
}
|
26
|
+
params[:tracked] = mail[:tracked].unparsed_value == true unless mail[:tracked].nil?
|
26
27
|
if mail[:transactional_message_id]
|
27
28
|
params[:transactional_message_id] = mail[:transactional_message_id].unparsed_value
|
28
29
|
params[:message_data] = mail[:message_data]&.unparsed_value || {}
|
29
30
|
else
|
30
31
|
params[:body] = mail.html_part.body.to_s if mail.html_part
|
31
32
|
params[:body_plain] = mail.text_part.body.to_s if mail.text_part
|
32
|
-
params[
|
33
|
+
if params[:body].blank?
|
34
|
+
if mail.text?
|
35
|
+
params[:body] = ''
|
36
|
+
params[:body_plain] = mail.body.to_s if params[:body_plain].blank?
|
37
|
+
else
|
38
|
+
params[:body] = mail.body.to_s
|
39
|
+
end
|
40
|
+
end
|
33
41
|
end
|
34
42
|
request = ::Customerio::SendEmailRequest.new(params.compact)
|
35
43
|
mail.attachments.each do |attachment|
|
data/spec/delivery_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe 'Delivering messages with customerio-rails' do
|
|
19
19
|
context 'when delivering a simple message' do
|
20
20
|
let(:expected_body) do
|
21
21
|
{ 'to' => 'sheldon@bigbangtheory.com', 'from' => 'leonard@bigbangtheory.com', 'subject' => 'hello',
|
22
|
-
'body_plain' => "hello\n", 'headers' => {}, 'identifiers' => { 'email' => 'sheldon@bigbangtheory.com' }, 'attachments' => {} }
|
22
|
+
'body' => '', 'body_plain' => "hello\n", 'headers' => {}, 'identifiers' => { 'email' => 'sheldon@bigbangtheory.com' }, 'attachments' => {} }
|
23
23
|
end
|
24
24
|
|
25
25
|
let(:message) { TestMailer.simple_message }
|
@@ -65,7 +65,7 @@ describe 'Delivering messages with customerio-rails' do
|
|
65
65
|
context 'when delivering with a nice from address' do
|
66
66
|
let(:expected_body) do
|
67
67
|
{"to" => "sheldon@bigbangtheory.com", "from" => "Leonard Hofstadter <leonard@bigbangtheory.com>",
|
68
|
-
"subject" => "hello", "headers" => {}, "identifiers" => {"email" => "sheldon@bigbangtheory.com"}, "body_plain" => "hello", "attachments" => {}}
|
68
|
+
"subject" => "hello", "headers" => {}, "identifiers" => {"email" => "sheldon@bigbangtheory.com"}, "body" => "", "body_plain" => "hello", "attachments" => {}}
|
69
69
|
end
|
70
70
|
|
71
71
|
it do
|
@@ -89,7 +89,7 @@ describe 'Delivering messages with customerio-rails' do
|
|
89
89
|
context 'when delivering a single part message' do
|
90
90
|
let(:expected_body) do
|
91
91
|
{ 'to' => 'sheldon@bigbangtheory.com', 'from' => 'leonard@bigbangtheory.com',
|
92
|
-
'subject' => 'Your invitation to join Mixlr.', "body_plain" => "hello\n", 'headers' => {}, 'identifiers' => { 'email' => 'sheldon@bigbangtheory.com' }, 'attachments' => {} }
|
92
|
+
'subject' => 'Your invitation to join Mixlr.', "body" => "", "body_plain" => "hello\n", 'headers' => {}, 'identifiers' => { 'email' => 'sheldon@bigbangtheory.com' }, 'attachments' => {} }
|
93
93
|
end
|
94
94
|
|
95
95
|
it do
|
@@ -135,4 +135,31 @@ describe 'Delivering messages with customerio-rails' do
|
|
135
135
|
message.deliver!
|
136
136
|
end
|
137
137
|
end
|
138
|
+
|
139
|
+
context 'when delivering a message without tracking' do
|
140
|
+
let(:message) { TestMailer.message_without_tracked }
|
141
|
+
|
142
|
+
let(:expected_body) do
|
143
|
+
{ "to" => "sheldon@bigbangtheory.com", "from" => "leonard@bigbangtheory.com", "subject" => "Message without tracking.", "headers" => {},
|
144
|
+
"identifiers" => {"email" => "sheldon@bigbangtheory.com"}, "tracked" => false, "body" => "", "body_plain" => "whatever", "attachments" => {} }
|
145
|
+
end
|
146
|
+
|
147
|
+
it do
|
148
|
+
message.deliver!
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
context 'when delivering a message with tracking' do
|
154
|
+
let(:message) { TestMailer.message_with_tracked }
|
155
|
+
|
156
|
+
let(:expected_body) do
|
157
|
+
{ "to" => "sheldon@bigbangtheory.com", "from" => "leonard@bigbangtheory.com", "subject" => "Message without tracking.", "headers" => {},
|
158
|
+
"identifiers" => {"email" => "sheldon@bigbangtheory.com"}, "tracked" => true, "body" => "", "body_plain" => "whatever", "attachments" => {} }
|
159
|
+
end
|
160
|
+
|
161
|
+
it do
|
162
|
+
message.deliver!
|
163
|
+
end
|
164
|
+
end
|
138
165
|
end
|
@@ -41,6 +41,14 @@ class TestMailer < ActionMailer::Base
|
|
41
41
|
mail(subject: 'Message with template.', transactional_message_id: '123', message_data: { foo: 'bar' })
|
42
42
|
end
|
43
43
|
|
44
|
+
def message_with_tracked
|
45
|
+
mail(subject: 'Message without tracking.', tracked: true, body: 'whatever')
|
46
|
+
end
|
47
|
+
|
48
|
+
def message_without_tracked
|
49
|
+
mail(subject: 'Message without tracking.', tracked: false, body: 'whatever')
|
50
|
+
end
|
51
|
+
|
44
52
|
protected
|
45
53
|
|
46
54
|
def image_file
|