tms_client 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tms_client/errors.rb +1 -1
- data/lib/tms_client/mail/delivery_method.rb +10 -2
- data/lib/tms_client/util/hal_link_parser.rb +1 -1
- data/lib/tms_client/version.rb +1 -1
- data/spec/errors_spec.rb +13 -0
- data/spec/mail/delivery_method_spec.rb +27 -4
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 740e4fe3e5d3a7641f97b2375077d7da15c15770
|
4
|
+
data.tar.gz: 91eb64507a4f94d0238f8a56cd915fdc7fbc8b62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7aeff2e142de5e638f6369e3730df7182b70f64ffec8c3a96456c5cbb0f29b7e96224c612fa0af599b2318f2e63c3e35a875a8130eff0ca5beb54855dfda370
|
7
|
+
data.tar.gz: 852af2b4dbe19ef2f4548f17c3f957b6d4d73747f137998832854f9087059a26f42a299586e2814a4e46162977a3b53fea7aa95008041df6eb9a81add9cef7fb
|
data/lib/tms_client/errors.rb
CHANGED
@@ -36,7 +36,7 @@ module TMS
|
|
36
36
|
def initialize(record_or_string)
|
37
37
|
if record_or_string.respond_to?(:href)
|
38
38
|
@record = record_or_string
|
39
|
-
super("Couldn't POST #{record.class} to #{record.href}: #{record.errors.join(', ')}")
|
39
|
+
super("Couldn't POST #{record.class} to #{record.href}: #{record.errors.map { |k, v| "#{k} #{v.join(' and ')}" }.join(', ')}")
|
40
40
|
else
|
41
41
|
super(record_or_string)
|
42
42
|
end
|
@@ -24,15 +24,23 @@ module TMS
|
|
24
24
|
attr_accessor :settings
|
25
25
|
|
26
26
|
def deliver!(mail)
|
27
|
-
#check_params(mail)
|
28
27
|
raise TMS::Errors::NoRelation.new('email_messages', client) unless client.respond_to?(:email_messages)
|
29
28
|
|
30
29
|
envelope_from = mail.return_path || mail.sender || mail.from_addrs.first
|
31
30
|
|
31
|
+
body = case
|
32
|
+
when mail.html_part
|
33
|
+
mail.html_part.body
|
34
|
+
when mail.text_part
|
35
|
+
mail.text_part.body
|
36
|
+
else
|
37
|
+
mail.body
|
38
|
+
end.decoded
|
39
|
+
|
32
40
|
tms_message = client.email_messages.build(
|
33
41
|
:from_name => mail[:from].display_names.first,
|
34
42
|
:subject => mail.subject,
|
35
|
-
:body =>
|
43
|
+
:body => body
|
36
44
|
)
|
37
45
|
|
38
46
|
mail.to.each { |recip| tms_message.recipients.build(:email => recip) }
|
@@ -31,7 +31,7 @@ module TMS::Util
|
|
31
31
|
subresources[rel] = klass.new(self.client, href)
|
32
32
|
setup_subresource(link)
|
33
33
|
else
|
34
|
-
|
34
|
+
logger.info("Don't know what to do with link rel '#{rel}' for class #{self.class.to_s}!") if self.respond_to?(:logger)
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
data/lib/tms_client/version.rb
CHANGED
data/spec/errors_spec.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TMS::Errors do
|
4
|
+
context "an errors hash" do
|
5
|
+
let(:object_with_errors) do
|
6
|
+
double('instance', href: 'href', errors: {"body" => ["can't be blank"], "subject" => ["can't be blank"]})
|
7
|
+
end
|
8
|
+
subject { TMS::Errors::InvalidVerb.new(object_with_errors) }
|
9
|
+
it 'should work' do
|
10
|
+
subject.message.should =~ /body can't be blank, subject can't be blank/
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -17,10 +17,33 @@ describe TMS::Mail::DeliveryMethod do
|
|
17
17
|
client.stub(:email_messages).and_return(email_messages)
|
18
18
|
subject.stub(:client).and_return(client)
|
19
19
|
email_messages.should_receive(:build).with(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
:from_name => mail[:from].display_names.first,
|
21
|
+
:subject => mail.subject,
|
22
|
+
:body => '<blink>HI</blink>'
|
23
|
+
).and_return(tms_message)
|
24
|
+
tms_message.should_receive(:post!).and_return(true)
|
25
|
+
|
26
|
+
subject.deliver!(mail)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should work with a multipart Mail::Message' do
|
30
|
+
mail = Mail.new do
|
31
|
+
subject 'hi'
|
32
|
+
from '"My mom" <my@mom.com>'
|
33
|
+
to '"A Nice Fellow" <tyler@sink.govdelivery.com>'
|
34
|
+
|
35
|
+
html_part do
|
36
|
+
content_type 'text/html; charset=UTF-8'
|
37
|
+
body '<blink>HTML</blink>'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
client.stub(:email_messages).and_return(email_messages)
|
41
|
+
subject.stub(:client).and_return(client)
|
42
|
+
email_messages.should_receive(:build).with(
|
43
|
+
:from_name => mail[:from].display_names.first,
|
44
|
+
:subject => mail.subject,
|
45
|
+
:body => '<blink>HTML</blink>'
|
46
|
+
).and_return(tms_message)
|
24
47
|
tms_message.should_receive(:post!).and_return(true)
|
25
48
|
|
26
49
|
subject.deliver!(mail)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tms_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GovDelivery
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- spec/client_spec.rb
|
125
125
|
- spec/command_types_spec.rb
|
126
126
|
- spec/email_message_spec.rb
|
127
|
+
- spec/errors_spec.rb
|
127
128
|
- spec/inbound_sms_messages_spec.rb
|
128
129
|
- spec/instance_resource_spec.rb
|
129
130
|
- spec/ipaws_acknowledgement_spec.rb
|
@@ -169,6 +170,7 @@ test_files:
|
|
169
170
|
- spec/client_spec.rb
|
170
171
|
- spec/command_types_spec.rb
|
171
172
|
- spec/email_message_spec.rb
|
173
|
+
- spec/errors_spec.rb
|
172
174
|
- spec/inbound_sms_messages_spec.rb
|
173
175
|
- spec/instance_resource_spec.rb
|
174
176
|
- spec/ipaws_acknowledgement_spec.rb
|