communicator 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -57,7 +57,16 @@ class Communicator::InboundMessage < ActiveRecord::Base
57
57
  return false
58
58
  end
59
59
  source, content = message_content.first
60
- Communicator.receiver_for(source).find_or_initialize_by_id(content["id"]).process_message(content)
60
+
61
+ # We have to distinguish here between inbound messages that have an id and those that
62
+ # don't since some databases (at least Postgres) will raise an error when the ID is set to nil on
63
+ # the ActiveRecord instance because AR includes the id column and it's "NULL" value in the
64
+ # INSERT statement
65
+ if content["id"]
66
+ Communicator.receiver_for(source).find_or_initialize_by_id(content["id"]).process_message(content)
67
+ else
68
+ Communicator.receiver_for(source).new.process_message(content)
69
+ end
61
70
  self.processed_at = Time.now
62
71
  self.save!
63
72
  Communicator.logger.info "Processed inbound message ##{id} successfully"
@@ -73,4 +82,4 @@ class Communicator::InboundMessage < ActiveRecord::Base
73
82
 
74
83
  raise err
75
84
  end
76
- end
85
+ end
@@ -1,3 +1,3 @@
1
1
  module Communicator
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
data/test/test_client.rb CHANGED
@@ -133,6 +133,10 @@ class TestClient < Test::Unit::TestCase
133
133
  assert_nil Communicator::OutboundMessage.last.message_content["post"]["id"]
134
134
  end
135
135
 
136
+ should "not have created the Post locally" do
137
+ assert @post.new_record?
138
+ end
139
+
136
140
  context "after PUSH" do
137
141
  setup do
138
142
  Communicator::Client.push
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: communicator
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Christoph Olszowka