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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28f2987f06ad23d327d06b2d38eb054259045dd6
4
- data.tar.gz: 76870cb343e8a97e0303908a24191cea6bb9915b
3
+ metadata.gz: 740e4fe3e5d3a7641f97b2375077d7da15c15770
4
+ data.tar.gz: 91eb64507a4f94d0238f8a56cd915fdc7fbc8b62
5
5
  SHA512:
6
- metadata.gz: 4d2e771630e5b9f77af2edf27a5ed9276d1ebced7d8f47cd74ff660088aa09dc03176cb73a26d525e41be72171e18b293852519abf827c88812670a36a9c5860
7
- data.tar.gz: d0263120ec36f712428cc97de967153c4706ee5610560cf8cabfecf5680e1bc8f4bbd7bf9fae02f61b4b275f05b29cabdeade2b212a82b267eec9d5370d39c17
6
+ metadata.gz: f7aeff2e142de5e638f6369e3730df7182b70f64ffec8c3a96456c5cbb0f29b7e96224c612fa0af599b2318f2e63c3e35a875a8130eff0ca5beb54855dfda370
7
+ data.tar.gz: 852af2b4dbe19ef2f4548f17c3f957b6d4d73747f137998832854f9087059a26f42a299586e2814a4e46162977a3b53fea7aa95008041df6eb9a81add9cef7fb
@@ -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 => (mail.body || mail.html_part.body || mail.text_part.body).to_s
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
- puts "Don't know what to do with link rel '#{rel}' for class #{self.class.to_s}!"
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
@@ -1,3 +1,3 @@
1
1
  module TMS #:nodoc:
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -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
- :from_name => mail[:from].display_names.first,
21
- :subject => mail.subject,
22
- :body => mail.body.to_s || mail.html_part.body.to_s || mail.text_part.body.to_s
23
- ).and_return(tms_message)
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.2
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-10 00:00:00.000000000 Z
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