lita-ticket_notifier 0.0.16 → 0.0.17
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b80a502e26bde3b64f26ec101abc9197d8a99db
|
4
|
+
data.tar.gz: 99a0e39ef697bc37e50245501ebc4b6f191df388
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5f2d71bd678b6de2263a153ed6adf9749b48a6d25b441cb1df3b40ab29ed425290f584ea93552f373b6a78bfdf7f7a4c020703c3ca37a3dc23fee83c29687f9
|
7
|
+
data.tar.gz: daa99f4220a17de77a0ca03742c54a4367786ee02dd7bc72b926242830afb19559f696bb7abc4fda90c4afcfb3baad42b65e571e4d868b102723d6eb1e26143f
|
@@ -2,6 +2,11 @@ module Lita
|
|
2
2
|
module Handlers
|
3
3
|
class TicketNotifier < Handler
|
4
4
|
attr_accessor :ticket_json, :ticket_object
|
5
|
+
|
6
|
+
def self.default_config(config)
|
7
|
+
config.tags_watching = ''
|
8
|
+
end
|
9
|
+
|
5
10
|
http.post "/ticket_notification", :ticket_notification
|
6
11
|
|
7
12
|
route(/ticket notify start/i, :add_ticket_notification, command: true,
|
@@ -15,7 +20,7 @@ module Lita
|
|
15
20
|
def ticket_notification(request, response)
|
16
21
|
self.ticket_json ||= JSON.parse(request.body.read)
|
17
22
|
user_names.each do |user_name|
|
18
|
-
send_message_to_user(user_name, ticket_message)
|
23
|
+
send_message_to_user(user_name, ticket_message) if notify?
|
19
24
|
end
|
20
25
|
end
|
21
26
|
|
@@ -35,6 +40,22 @@ module Lita
|
|
35
40
|
|
36
41
|
private
|
37
42
|
|
43
|
+
def tags_watching
|
44
|
+
Lita.config.handlers.ticket_notifier.tags_watching
|
45
|
+
end
|
46
|
+
|
47
|
+
def watching_all_tags?
|
48
|
+
tags_watching.empty?
|
49
|
+
end
|
50
|
+
|
51
|
+
def watching_tag?
|
52
|
+
(ticket.tag.split & tags_watching.split).any?
|
53
|
+
end
|
54
|
+
|
55
|
+
def notify?
|
56
|
+
watching_all_tags? || watching_tag?
|
57
|
+
end
|
58
|
+
|
38
59
|
def send_message_to_user(user_name, message)
|
39
60
|
robot.send_message(source_from_name(user_name), message)
|
40
61
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-ticket_notifier"
|
3
|
-
spec.version = "0.0.
|
3
|
+
spec.version = "0.0.17"
|
4
4
|
spec.authors = ["Michael van den Beuken", "Ruben Estevez", "Jordan Babe", "Mathieu Gilbert", "Ryan Jones", "Darko Dosenovic"]
|
5
5
|
spec.email = ["michael.beuken@gmail.com", "ruben.a.estevez@gmail.com", "jorbabe@gmail.com", "mathieu.gilbert@ama.ab.ca", "ryan.michael.jones@gmail.com", "darko.dosenovic@ama.ab.ca"]
|
6
6
|
spec.description = %q{Notify users about new tickets coming in.}
|
data/spec/fixtures/ticket.json
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
{
|
2
|
+
"version": {
|
3
|
+
"assigned_user_id": null,
|
4
|
+
"attachments_count": 0,
|
5
|
+
"body": "",
|
6
|
+
"body_html": "",
|
7
|
+
"closed": true,
|
8
|
+
"created_at": "2014-08-06T22:55:30Z",
|
9
|
+
"creator_id": 240273,
|
10
|
+
"creator_name": "Mathieu Gilbert",
|
11
|
+
"diffable_attributes": {
|
12
|
+
"state": "resolved"
|
13
|
+
},
|
14
|
+
"importance": 3,
|
15
|
+
"importance_name": "Low",
|
16
|
+
"milestone_id": null,
|
17
|
+
"milestone_order": 9999,
|
18
|
+
"number": 4146,
|
19
|
+
"permalink": "test-ticket",
|
20
|
+
"priority": 3,
|
21
|
+
"project_id": 66073,
|
22
|
+
"spam": false,
|
23
|
+
"state": "review",
|
24
|
+
"tag": "doomsday",
|
25
|
+
"title": "test ticket",
|
26
|
+
"updated_at": "2014-08-06T22:55:32Z",
|
27
|
+
"url": "http://waffles.lighthouseapp.com/projects/1/tickets/200",
|
28
|
+
"user_id": 240273,
|
29
|
+
"user_name": "Mathieu Gilbert",
|
30
|
+
"version": 3,
|
31
|
+
"watchers_ids": [
|
32
|
+
240273,
|
33
|
+
216682
|
34
|
+
]
|
35
|
+
}
|
36
|
+
}
|
@@ -4,9 +4,16 @@ require "json"
|
|
4
4
|
describe Lita::Handlers::TicketNotifier, lita_handler: true do
|
5
5
|
let(:payload) { File.read(File.join('spec', 'fixtures', 'ticket.json')) }
|
6
6
|
let(:request) { OpenStruct.new({ body: OpenStruct.new({ read: payload }) }) }
|
7
|
+
let(:unwatched_payload) { File.read(File.join('spec', 'fixtures', 'unwatched_ticket.json')) }
|
8
|
+
let(:unwatched_request) { OpenStruct.new({ body: OpenStruct.new({ read: unwatched_payload }) }) }
|
9
|
+
|
7
10
|
let(:teddy) { Lita::User.create(123, name: "Teddy Ruxbin") }
|
8
11
|
let(:batman) { Lita::User.create(567, name: "The Batman") }
|
9
|
-
let(:ticket_messsage) { "Ticket: test ticket\nState:review\nImportance:Low\nTags:dev\nhttp://waffles.lighthouseapp.com/projects/1/tickets/200" }
|
12
|
+
let(:ticket_messsage) { "Ticket: test ticket\nState:review\nImportance:Low\nTags:dev pies\nhttp://waffles.lighthouseapp.com/projects/1/tickets/200" }
|
13
|
+
|
14
|
+
before(:each) do
|
15
|
+
Lita.config.handlers.ticket_notifier.tags_watching = 'pies cakes'
|
16
|
+
end
|
10
17
|
|
11
18
|
it { routes_command("ticket notify start").to(:add_ticket_notification) }
|
12
19
|
it { routes_command("ticket notify stop").to(:remove_ticket_notification) }
|
@@ -25,6 +32,31 @@ describe Lita::Handlers::TicketNotifier, lita_handler: true do
|
|
25
32
|
subject.ticket_notification(request, nil)
|
26
33
|
end
|
27
34
|
|
35
|
+
it "sends notifications for chosen tags" do
|
36
|
+
expect(subject).to receive(:send_message_to_user).once
|
37
|
+
|
38
|
+
send_command("ticket notify start")
|
39
|
+
|
40
|
+
subject.ticket_notification(request, nil)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "defaults to watching all tags" do
|
44
|
+
Lita.config.handlers.ticket_notifier.tags_watching = ''
|
45
|
+
expect(subject).to receive(:send_message_to_user).once
|
46
|
+
|
47
|
+
send_command("ticket notify start")
|
48
|
+
|
49
|
+
subject.ticket_notification(request, nil)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "doesn't send notifications for unwatched tags" do
|
53
|
+
expect(subject).to_not receive(:send_message_to_user)
|
54
|
+
|
55
|
+
send_command("ticket notify start")
|
56
|
+
|
57
|
+
subject.ticket_notification(unwatched_request, nil)
|
58
|
+
end
|
59
|
+
|
28
60
|
it "doesn't add you twice" do
|
29
61
|
send_command("ticket notify start")
|
30
62
|
send_command("ticket notify start")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-ticket_notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael van den Beuken
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2014-08-
|
16
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: lita
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lita-ticket_notifier.gemspec
|
108
108
|
- locales/en.yml
|
109
109
|
- spec/fixtures/ticket.json
|
110
|
+
- spec/fixtures/unwatched_ticket.json
|
110
111
|
- spec/lita/handlers/ticket_notifier_spec.rb
|
111
112
|
- spec/spec_helper.rb
|
112
113
|
homepage: https://github.com/amaabca/lita-ticket_notifier
|
@@ -136,5 +137,6 @@ specification_version: 4
|
|
136
137
|
summary: Users can opt-in/out from Lighthouse new ticket notifications.
|
137
138
|
test_files:
|
138
139
|
- spec/fixtures/ticket.json
|
140
|
+
- spec/fixtures/unwatched_ticket.json
|
139
141
|
- spec/lita/handlers/ticket_notifier_spec.rb
|
140
142
|
- spec/spec_helper.rb
|