customerio-rails 0.1.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67c845f6f2c71391044755e3412a1674f24a129dab76f841455eeebf135fc897
4
- data.tar.gz: 21785d8a8cd965fa463ce6ebbc2ca8c3336bff9cd1b195a923ebebf129025bd8
3
+ metadata.gz: 5adee29125bb8586d4fda950db62af40292c31a993a1690b839ca4e24f17671a
4
+ data.tar.gz: 92f387d08d78fdd31a460687a29f28c1e019d954c590da6b2390f1f1b5962215
5
5
  SHA512:
6
- metadata.gz: f07811ee4d2cc6e212327f39537ce20a7ac681af323dd0b249d8fcd5cf185ca40d4b4e03f94599b413ff706e10e807b59d303755c5aac5296952ce1527233a66
7
- data.tar.gz: 30664d979cba3887204f723ecccd2506360b871061f8d6f31a23dfb0ccc4cc97981ff0789092100610aa92c6c5a7ecaf03fe2cbab94723b92f1ffdf1cbfd01f2
6
+ metadata.gz: a28b9efc02aa6df47a7cafdaa332ad6f4afa858c14ee6d7ce435a4d275f099120e9c9211605f721d2d3ec75ef9d4268a2de235cb8fdc9af822dc25f35a865d4a
7
+ data.tar.gz: 5f287d2ca36b4bfef0f163b600a603d0369d761f85b8dc35a57ef8c69b3465e57955fedf6e7df8a9257a0c62ee90a4c6309044c2c58b2f352a24e8daab53075a
@@ -16,7 +16,7 @@ module CustomerioRails
16
16
  (Array.wrap(mail.to) + Array.wrap(mail.cc)).compact.each do |to|
17
17
  params = {
18
18
  to: to,
19
- from: Array.wrap(mail.from).first,
19
+ from: Array.wrap(mail[:from]).first.unparsed_value,
20
20
  subject: mail.subject,
21
21
  reply_to: mail.reply_to,
22
22
  bcc: mail.bcc,
@@ -27,8 +27,9 @@ module CustomerioRails
27
27
  params[:transactional_message_id] = mail[:transactional_message_id].unparsed_value
28
28
  params[:message_data] = mail[:message_data]&.unparsed_value || {}
29
29
  else
30
- params[:body] = mail.html_part&.body&.to_s || mail.body.to_s
31
- params[:body_plain] = mail.text_part&.body&.to_s
30
+ params[:body] = mail.html_part.body.to_s if mail.html_part
31
+ params[:body_plain] = mail.text_part.body.to_s if mail.text_part
32
+ params[mail.text? ? :body_plain : :body] = mail.body.to_s if !mail.html_part && !mail.text_part
32
33
  end
33
34
  request = ::Customerio::SendEmailRequest.new(params.compact)
34
35
  mail.attachments.each do |attachment|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CustomerioRails
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.1'
5
5
  end
@@ -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' => "hello\n", 'headers' => {}, 'identifiers' => { 'email' => 'sheldon@bigbangtheory.com' }, 'attachments' => {} }
22
+ 'body_plain' => "hello\n", 'headers' => {}, 'identifiers' => { 'email' => 'sheldon@bigbangtheory.com' }, 'attachments' => {} }
23
23
  end
24
24
 
25
25
  let(:message) { TestMailer.simple_message }
@@ -62,6 +62,18 @@ describe 'Delivering messages with customerio-rails' do
62
62
  end
63
63
  end
64
64
 
65
+ context 'when delivering with a nice from address' do
66
+ let(:expected_body) do
67
+ {"to" => "sheldon@bigbangtheory.com", "from" => "Leonard Hofstadter <leonard@bigbangtheory.com>",
68
+ "subject" => "hello", "headers" => {}, "identifiers" => {"email" => "sheldon@bigbangtheory.com"}, "body_plain" => "hello", "attachments" => {}}
69
+ end
70
+
71
+ it do
72
+ message = TestMailer.simple_message_with_nice_from
73
+ message.deliver!
74
+ end
75
+ end
76
+
65
77
  context 'when delivering a multipart message' do
66
78
  let(:expected_body) do
67
79
  { 'to' => 'sheldon@bigbangtheory.com', 'from' => 'leonard@bigbangtheory.com',
@@ -74,6 +86,18 @@ describe 'Delivering messages with customerio-rails' do
74
86
  end
75
87
  end
76
88
 
89
+ context 'when delivering a single part message' do
90
+ let(:expected_body) do
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' => {} }
93
+ end
94
+
95
+ it do
96
+ message = TestMailer.singlepart_message
97
+ message.deliver!
98
+ end
99
+ end
100
+
77
101
  context 'when delivering a message with attachments' do
78
102
  let(:expected_body) do
79
103
  { 'to' => 'sheldon@bigbangtheory.com', 'from' => 'leonard@bigbangtheory.com',
@@ -7,6 +7,10 @@ class TestMailer < ActionMailer::Base
7
7
  mail
8
8
  end
9
9
 
10
+ def simple_message_with_nice_from
11
+ mail(from: 'Leonard Hofstadter <leonard@bigbangtheory.com>', body: 'hello')
12
+ end
13
+
10
14
  def multipart_message
11
15
  mail(subject: "Your invitation to join Mixlr.") do |format|
12
16
  format.text
@@ -14,6 +18,10 @@ class TestMailer < ActionMailer::Base
14
18
  end
15
19
  end
16
20
 
21
+ def singlepart_message
22
+ mail(subject: "Your invitation to join Mixlr.")
23
+ end
24
+
17
25
  def message_with_attachment
18
26
  attachments['empty.gif'] = File.read(image_file)
19
27
  mail(subject: "Message with attachment.")
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: customerio-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Utard
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-18 00:00:00.000000000 Z
10
+ date: 2025-05-16 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: actionmailer
@@ -74,6 +74,7 @@ files:
74
74
  - spec/fixtures/views/test_mailer/multipart_message.html.erb
75
75
  - spec/fixtures/views/test_mailer/multipart_message.text.erb
76
76
  - spec/fixtures/views/test_mailer/simple_message.erb
77
+ - spec/fixtures/views/test_mailer/singlepart_message.text.erb
77
78
  - spec/spec.opts
78
79
  - spec/spec_helper.rb
79
80
  homepage: https://github.com/altertable-ai/customerio-rails
@@ -107,5 +108,6 @@ test_files:
107
108
  - spec/fixtures/views/test_mailer/multipart_message.html.erb
108
109
  - spec/fixtures/views/test_mailer/multipart_message.text.erb
109
110
  - spec/fixtures/views/test_mailer/simple_message.erb
111
+ - spec/fixtures/views/test_mailer/singlepart_message.text.erb
110
112
  - spec/spec.opts
111
113
  - spec/spec_helper.rb