lita-flowdock 0.2.0 → 0.2.1
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/lita/adapters/flowdock/message_handler.rb +22 -2
- data/lita-flowdock.gemspec +1 -1
- data/spec/lita/adapters/flowdock/message_handler_spec.rb +38 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66b05584aa8148b798f1ecc0e0e971b9cd8918b2
|
4
|
+
data.tar.gz: 61e11fd94a4978ca62e57ac81c06837bf0abb66b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e7a95d5b77eefff74da386ba28ab8a541136ee404cf6f96b0fdc8c33b298b3be787c9075438277526a456e91e9f2c146ca0b95d2e65578a0931e3f90251da36
|
7
|
+
data.tar.gz: ccd767e90b4ddc5f7bfae995b8e901d2d9d05b894333cba9fdf35c9a11f352b24492cbe1789c2fbb606843199e9ef012445481166eaee05abe65fc1bbd8660cc
|
data/CHANGELOG.md
CHANGED
@@ -15,6 +15,8 @@ module Lita
|
|
15
15
|
|
16
16
|
def handle
|
17
17
|
case type
|
18
|
+
when "comment"
|
19
|
+
handle_message
|
18
20
|
when "message"
|
19
21
|
handle_message
|
20
22
|
when "activity.user"
|
@@ -30,11 +32,29 @@ module Lita
|
|
30
32
|
attr_reader :robot, :robot_id, :data, :type, :flowdock_client
|
31
33
|
|
32
34
|
def body
|
33
|
-
data['content'] || ""
|
35
|
+
content = data['content'] || ""
|
36
|
+
return content.is_a?(Hash) ? content['text'] : content
|
37
|
+
end
|
38
|
+
|
39
|
+
def tags
|
40
|
+
data['tags']
|
41
|
+
end
|
42
|
+
|
43
|
+
def parent_id
|
44
|
+
influx_tag = tags.select { |t| t =~ /influx:(\d+)/ }.first
|
45
|
+
influx_tag.split(':')[-1].to_i
|
46
|
+
end
|
47
|
+
|
48
|
+
def message_id
|
49
|
+
type == 'comment' ? parent_id : id
|
34
50
|
end
|
35
51
|
|
36
52
|
def dispatch_message(user)
|
37
|
-
source = FlowdockSource.new(
|
53
|
+
source = FlowdockSource.new(
|
54
|
+
user: user,
|
55
|
+
room: flow,
|
56
|
+
message_id: message_id
|
57
|
+
)
|
38
58
|
message = Message.new(robot, body, source)
|
39
59
|
robot.receive(message)
|
40
60
|
end
|
data/lita-flowdock.gemspec
CHANGED
@@ -171,6 +171,44 @@ describe Lita::Adapters::Flowdock::MessageHandler, lita: true do
|
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
|
+
context "receives a comment message" do
|
175
|
+
let(:id) { 4321 }
|
176
|
+
let(:parent_id) { 123456 }
|
177
|
+
let(:data) do
|
178
|
+
{
|
179
|
+
'content' => {
|
180
|
+
'title' => 'Thread title',
|
181
|
+
'text' => 'Lita: help'
|
182
|
+
},
|
183
|
+
'event' => 'comment',
|
184
|
+
'flow' => test_flow,
|
185
|
+
'id' => id,
|
186
|
+
'tags' => ["influx:#{parent_id}"],
|
187
|
+
'user' => test_user_id
|
188
|
+
}
|
189
|
+
end
|
190
|
+
let(:message) { instance_double('Lita::Message', command!: true) }
|
191
|
+
let(:source) { instance_double('Lita::FlowdockSource', private_message?: false, message_id: parent_id) }
|
192
|
+
let(:user) { user_double(test_user_id) }
|
193
|
+
|
194
|
+
before do
|
195
|
+
allow(Lita::User).to receive(:find_by_id).and_return(user)
|
196
|
+
allow(Lita::FlowdockSource).to receive(:new).with(
|
197
|
+
user: user,
|
198
|
+
room: test_flow,
|
199
|
+
message_id: parent_id
|
200
|
+
).and_return(source)
|
201
|
+
allow(Lita::Message).to receive(:new).with(
|
202
|
+
robot, 'Lita: help', source).and_return(message)
|
203
|
+
allow(robot).to receive(:receive).with(message)
|
204
|
+
end
|
205
|
+
|
206
|
+
it "dispatches the message to lita" do
|
207
|
+
expect(robot).to receive(:receive).with(message)
|
208
|
+
subject.handle
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
174
212
|
context "receives an action message" do
|
175
213
|
context "for adding a user to the flow" do
|
176
214
|
let(:data) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-flowdock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben House
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|