customerio-rails 0.2.0 → 0.2.2

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: e4ff8ea662f0b7c46f92abcb2bff6036c7eb0ceac0a094b1897999de95b84bfb
4
- data.tar.gz: 97d58d0c475a0173b3921408be4b617feb410bc9bc524d362de765db1c7ad446
3
+ metadata.gz: 89e736882d200a4d1285d1172b0a69bebd2b296189dd97381d4a9ac8ac998523
4
+ data.tar.gz: f5c69c0c71d4090da1035f7c0faa13ea03afa355798fcb1bdcda6b05836e93d6
5
5
  SHA512:
6
- metadata.gz: e17bda7150e69e7e3f0fcc69f4736309f0eedcb66ebbb8aeb4bc98d46ca7a6ed893a0fd784999e916cbb4ae42c4379d3c3a56daea81cb3831a37ec8fa212493b
7
- data.tar.gz: dd577b97550d0104045f51b43c5fe88e42e077337b75f8d4bfd471b871290524e55a8d08a77201f7f2a5af876b4b534fefb35d2a852bbc81d36a58ae956584af
6
+ metadata.gz: b4639bc1ba882ebd9a49d95f0571579a1af4eebf17596660ee4f488f261bdeee05515737fa471182ec7f3c5b063afb64f3fa6babb37833c03fa18aa7dd49ff5d
7
+ data.tar.gz: b171efc85d282dc29480074a3179184ec0451868993937484cf71874ce060d3f66b848a31062413e534245333b8661028589a418fa78e8c0b64c244c9bd471ec
@@ -27,8 +27,16 @@ 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
+ if params[:body].blank?
33
+ if mail.text?
34
+ params[:body] = ''
35
+ params[:body_plain] = mail.body.to_s if params[:body_plain].blank?
36
+ else
37
+ params[:body] = mail.body.to_s
38
+ end
39
+ end
32
40
  end
33
41
  request = ::Customerio::SendEmailRequest.new(params.compact)
34
42
  mail.attachments.each do |attachment|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CustomerioRails
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.2'
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' => '', '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" => "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
@@ -86,6 +86,18 @@ describe 'Delivering messages with customerio-rails' do
86
86
  end
87
87
  end
88
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" => "", "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
+
89
101
  context 'when delivering a message with attachments' do
90
102
  let(:expected_body) do
91
103
  { 'to' => 'sheldon@bigbangtheory.com', 'from' => 'leonard@bigbangtheory.com',
@@ -18,6 +18,10 @@ class TestMailer < ActionMailer::Base
18
18
  end
19
19
  end
20
20
 
21
+ def singlepart_message
22
+ mail(subject: "Your invitation to join Mixlr.")
23
+ end
24
+
21
25
  def message_with_attachment
22
26
  attachments['empty.gif'] = File.read(image_file)
23
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.2.0
4
+ version: 0.2.2
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