lita-flowdock 0.2.3 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e7c5b59bef6c79b46baabff5bb13104fd702d9a
4
- data.tar.gz: 09e2d9d829cdcfc726c759b499b88c850ffc4904
3
+ metadata.gz: bb7e7149a8b43f305857dc0d9eef5ead5be2bfba
4
+ data.tar.gz: cb5880f71af7eea569d73cbd013b1e784cdb1875
5
5
  SHA512:
6
- metadata.gz: a5f12b386be541e133c554c5fb70cb894bebe50997b262d3622b5811ff35acd9b384f8f3389821198b806ca9cc91f2ff3c0a2c76fce2660053569d7eca34726e
7
- data.tar.gz: bc3da50050ee8c6d0b4d168874ca0df07aa6c5f120a870cfe9366cc75450082fa3aee95f19d59f694de44b9ad59c40683f8ebcb80d53f6d77510508c08274a01
6
+ metadata.gz: a7bf46d9a687efb8f6f4ae127b529531e3434cbb4c6dfd3cf5e8a35e6be6aa0ceb46c73ddf87c8c9c99cb7fc5caa0c0784ad1a253271954152654e0ecbc467b2
7
+ data.tar.gz: 1fc10004c9db4671c04a73ebf7c6f95a93e9dd8013768e63590416344ce367325f96da554f5d9559c2659d131d3d1d62f8d708b161cd7e62836cdfefea03f5a2
@@ -39,14 +39,6 @@ module Lita
39
39
  return content.is_a?(Hash) ? content['text'] : content
40
40
  end
41
41
 
42
- def tags
43
- data['tags']
44
- end
45
-
46
- def thread_id
47
- data['thread_id']
48
- end
49
-
50
42
  def dispatch_message(user)
51
43
  source = FlowdockSource.new(
52
44
  user: user,
@@ -54,7 +46,7 @@ module Lita
54
46
  private_message: private_message?,
55
47
  message_id: private_message? ? data['id'] : data['thread']['initial_message']
56
48
  )
57
- message = FlowdockMessage.new(robot, body, source, tags, thread_id)
49
+ message = FlowdockMessage.new(robot, body, source, data)
58
50
  robot.receive(message)
59
51
  end
60
52
 
@@ -1,10 +1,23 @@
1
1
  module Lita
2
2
  class FlowdockMessage < Message
3
- attr_reader :tags, :thread_id
4
- def initialize(robot, body, source, tags, thread_id)
5
- @tags = tags
6
- @thread_id = thread_id
3
+
4
+ attr_reader :data
5
+
6
+ def initialize(robot, body, source, data)
7
+ @data = data
7
8
  super(robot, body, source)
8
9
  end
10
+
11
+ def tags
12
+ @data['tags']
13
+ end
14
+
15
+ def thread_id
16
+ @data['thread_id']
17
+ end
18
+
19
+ def new_thread?
20
+ @data['id'] == @data['thread']['initial_message']
21
+ end
9
22
  end
10
23
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-flowdock"
3
- spec.version = "0.2.3"
3
+ spec.version = "0.3.0"
4
4
  spec.authors = ["Ben House"]
5
5
  spec.email = ["ben@benhouse.io"]
6
6
  spec.description = %q{flowdock adapter for lita.io}
@@ -52,7 +52,7 @@ describe Lita::Adapters::Flowdock::MessageHandler, lita: true do
52
52
  message_id: id
53
53
  ).and_return(source)
54
54
  allow(Lita::FlowdockMessage).to receive(:new).with(
55
- robot, 'Hello World!', source, [], nil).and_return(message)
55
+ robot, 'Hello World!', source, data).and_return(message)
56
56
  allow(robot).to receive(:receive).with(message)
57
57
  end
58
58
 
@@ -81,8 +81,7 @@ describe Lita::Adapters::Flowdock::MessageHandler, lita: true do
81
81
  robot,
82
82
  "",
83
83
  source,
84
- [],
85
- nil
84
+ data
86
85
  ).and_return(message)
87
86
 
88
87
  subject.handle
@@ -244,7 +243,7 @@ describe Lita::Adapters::Flowdock::MessageHandler, lita: true do
244
243
  message_id: parent_id
245
244
  ).and_return(source)
246
245
  allow(Lita::FlowdockMessage).to receive(:new).with(
247
- robot, 'Lita: help', source, tags, nil).and_return(message)
246
+ robot, 'Lita: help', source, data).and_return(message)
248
247
  allow(robot).to receive(:receive).with(message)
249
248
  end
250
249
 
@@ -30,100 +30,62 @@ describe Lita::FlowdockMessage, lita: true do
30
30
  allow(Lita::User).to receive(:find_by_id).and_return(user)
31
31
  end
32
32
 
33
- context "a message in a thread has a tag" do
34
- let(:tags) { ['down'] }
33
+ context "a message" do
35
34
  let(:body) { 'the system is #down' }
35
+ let(:initial_message){ 1234 }
36
36
  let(:data) do
37
37
  {
38
38
  'content' => {
39
39
  'title' => 'Thread title',
40
40
  'text' => body
41
41
  },
42
+ 'thread_id' => 'a385473',
42
43
  'event' => 'comment',
43
44
  'flow' => test_flow,
44
45
  'id' => 2345,
45
46
  'thread' => {
46
- 'initial_message' => 1234
47
+ 'initial_message' => initial_message
47
48
  },
48
- 'tags' => tags,
49
+ 'tags' => ['down'],
49
50
  'user' => 3
50
51
  }
51
52
  end
52
53
 
53
- it 'creates a message with tags' do
54
+ it 'creates a message with data' do
54
55
  expect(Lita::FlowdockMessage).to receive(:new).with(
55
56
  robot,
56
57
  body,
57
58
  source,
58
- tags,
59
- nil
59
+ data
60
60
  )
61
61
 
62
62
  message_handler.handle
63
63
  end
64
- end
65
-
66
- context "a message in a thread" do
67
- let(:tags) { ['down'] }
68
- let(:body) { 'the system is #down' }
69
- let(:data) do
70
- {
71
- 'content' => {
72
- 'title' => 'Thread title',
73
- 'text' => body
74
- },
75
- 'event' => 'comment',
76
- 'flow' => test_flow,
77
- 'id' => 2345,
78
- 'thread_id' => 'deadbeef',
79
- 'thread' => {
80
- 'initial_message' => 1234
81
- },
82
- 'tags' => tags,
83
- 'user' => 3
84
- }
85
- end
86
-
87
- it 'stores the message_id on the flowdock_message' do
88
- expect(Lita::FlowdockMessage).to receive(:new).with(
89
- robot,
90
- body,
91
- source,
92
- tags,
93
- 'deadbeef'
94
- )
95
64
 
96
- message_handler.handle
97
- end
98
- end
65
+ context 'instance methods' do
66
+ subject{ Lita::FlowdockMessage.new( robot, body, source, data) }
67
+ it 'has #tags' do
68
+ expect(subject.tags).to eq(['down'])
69
+ end
99
70
 
100
- context 'a regular message with a tag' do
101
- let(:tags) { ['world'] }
102
- let(:body) { 'Hello #world' }
103
- let(:data) do
104
- {
105
- 'content' => body,
106
- 'event' => 'message',
107
- 'flow' => test_flow,
108
- 'id' => 1234,
109
- 'thread' => {
110
- 'initial_message' => 1234
111
- },
112
- 'tags' => tags,
113
- 'user' => 3
114
- }
115
- end
71
+ it 'has #thread_id' do
72
+ expect(subject.thread_id).to eq('a385473')
73
+ end
116
74
 
117
- it 'creates a message with tags' do
118
- expect(Lita::FlowdockMessage).to receive(:new).with(
119
- robot,
120
- body,
121
- source,
122
- tags,
123
- nil
124
- )
75
+ context 'new_thread?' do
76
+ context 'non new-thread' do
77
+ it 'is false' do
78
+ expect(subject.new_thread?).to be false
79
+ end
80
+ end
125
81
 
126
- message_handler.handle
82
+ context 'a new thread' do
83
+ let(:initial_message){ 2345 }
84
+ it 'is true' do
85
+ expect(subject.new_thread?).to be true
86
+ end
87
+ end
88
+ end
127
89
  end
128
90
  end
129
91
  end
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.3
4
+ version: 0.3.0
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-12-03 00:00:00.000000000 Z
11
+ date: 2015-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita