intercom 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/intercom/user_event.rb +6 -2
- data/lib/intercom/version.rb +1 -1
- data/spec/unit/intercom/user_event_spec.rb +13 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2853f9208fb251cd3a7cf50ff37cf6c650e0b689
|
4
|
+
data.tar.gz: dbd8ea0ee7fffed060e8c76827dbc7d3fa75bcfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90837953885802d3e3fefeb511c3eedbcd96eac382d274e179873a2e66ed2e43d6526befbbd90fd2a2e3fc711fcfe58fa49a0cd5faee9eca104a0c881ed577a7
|
7
|
+
data.tar.gz: 8ba9b140e61579bcbe2b9b73752023fe9594d5c0f9399fcaee53e36cb6b267db854f6f7ea656e2ed8b07e620f7e086dee053480108220115cab99a17f08ae68e
|
data/lib/intercom/user_event.rb
CHANGED
@@ -76,19 +76,23 @@ module Intercom
|
|
76
76
|
# Save a list of User Events, with an optional base_user
|
77
77
|
def self.save_batch_events(events, base_user=nil)
|
78
78
|
hash = { :type => 'event.list', :data => []}
|
79
|
-
hash[:user] =
|
79
|
+
hash[:user] = user_hash(base_user) if base_user
|
80
80
|
events.each do |event|
|
81
81
|
hash[:data] << event.event_hash
|
82
82
|
end
|
83
83
|
post_to_intercom(hash)
|
84
84
|
end
|
85
|
+
|
86
|
+
def self.user_hash(user)
|
87
|
+
user.user_id ? { :user_id => user.user_id } : { :email => user.email }
|
88
|
+
end
|
85
89
|
|
86
90
|
def self.post_to_intercom(hash)
|
87
91
|
Intercom.post('/events', hash)
|
88
92
|
end
|
89
93
|
|
90
94
|
def user_hash
|
91
|
-
|
95
|
+
UserEvent.user_hash(user)
|
92
96
|
end
|
93
97
|
|
94
98
|
def event_hash
|
data/lib/intercom/version.rb
CHANGED
@@ -9,10 +9,10 @@ describe "Intercom::UserEvent" do
|
|
9
9
|
Intercom.expects(:post).with("/events",
|
10
10
|
{ :type => 'event.list',
|
11
11
|
:data => [ {:event_name => "signup", :created => created_time.to_i, :type => 'event',
|
12
|
-
:user => { :user_id => user.user_id},
|
12
|
+
:user => { :user_id => user.user_id},
|
13
13
|
}]}).returns(:status => 200)
|
14
14
|
|
15
|
-
Intercom::UserEvent.create({ :event_name => "signup", :user => user, :created_at => created_time
|
15
|
+
Intercom::UserEvent.create({ :event_name => "signup", :user => user, :created_at => created_time })
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'automatically adds a created time upon creation' do
|
@@ -39,6 +39,17 @@ describe "Intercom::UserEvent" do
|
|
39
39
|
proc { user_event.save }.must_raise ArgumentError, "Missing User"
|
40
40
|
end
|
41
41
|
|
42
|
+
it 'uses the user.email if no user.id found' do
|
43
|
+
user2 = Intercom::User.new("email" => "jim@example.com", :created_at => Time.now, :name => "Jim Bob")
|
44
|
+
Intercom.expects(:post).with("/events",
|
45
|
+
{ :type => 'event.list',
|
46
|
+
:data => [ {:event_name => "signup", :created => created_time.to_i, :type => 'event',
|
47
|
+
:user => { :email => user2.email}
|
48
|
+
}]}).returns(:status => 200)
|
49
|
+
|
50
|
+
Intercom::UserEvent.create({ :event_name => "signup", :user => user2, :created_at => created_time })
|
51
|
+
end
|
52
|
+
|
42
53
|
describe 'while batching events' do
|
43
54
|
|
44
55
|
let (:event1) do
|