lita-jira 0.7.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 372aaea44e1c7953b66a0cb3afe6a53a631e08c9
4
- data.tar.gz: 8ffc592e14e99e246d07effe13f1248d850c7a3f
3
+ metadata.gz: eca25015401127d628654b155f01c2186adee367
4
+ data.tar.gz: 8ecded11919390a55da963235b9b7eeb9f272382
5
5
  SHA512:
6
- metadata.gz: 74d908bfa0e64d3d9331447e75873797b5d1fb8ae485da8beff3c1ecf49cc1faa830ec41e66a4f8a7a646684e531fb8124350f193510457b3b5814944e96a439
7
- data.tar.gz: 76ef2321482c259b729f97475525e671d084fdf6992e68c01b694aff11de65c3b943eae4a5a31d867560709558c1f67edda4e1ab86014cb8f1b79aa6868a083a
6
+ metadata.gz: f736bd91ff2ff195ec600a289f44b1d58397b6eb874643597b4f6fd024c6e6c3fb053eccdc0175f0952354e2ae809ffe63f3a50923bbe9299f3e017daba4de69
7
+ data.tar.gz: dd89520f0235451055bd7243b011aabf3d65ec6a0334b1937e9139032ff9a5bf14956fd69f38ba137daa734f4ee67e5ae0edab4523ff02b703c1750a626bea83
data/README.md CHANGED
@@ -31,14 +31,14 @@ config.handlers.jira.site = 'https://your.jira.instance.example.com/'
31
31
  * `context` (string) - If your instance is in a /subdirectory, put that here. Default: `''`
32
32
  * `format` (string) - You can select a compact one line issue summary by setting this parameter to `one-line`. Default: `verbose`
33
33
  * `ambient` (boolean) - When set to `true`, Lita will show JIRA issue details when a JIRA issue key is mentioned in chat, outside the context of a command. Default: `false`
34
- * `ignore` (array) - Prevent ambient JIRA issue detection in certain users' messages. Default: `[]`
34
+ * `ignore` (array) - Prevent ambient JIRA issue detection in certain users' messages. Accepts user names, mention names, and IDs. Default: `[]`
35
35
  * `rooms` (array) - Limit ambient JIRA issue detection to a certain list of rooms. If unspecified, the bot will respond to detected issues in all rooms.
36
36
 
37
37
  ``` ruby
38
38
  config.handlers.jira.context = '/myjira'
39
- config.handlers.jira.ambient = true
40
39
  config.handlers.jira.format = 'one-line'
41
- config.handlers.jira.ignore = ['Jira', 'Github']
40
+ config.handlers.jira.ambient = true
41
+ config.handlers.jira.ignore = ['Jira', 'Github', 'U1234']
42
42
  config.handlers.jira.rooms = ['devtools', 'engineering']
43
43
  ```
44
44
 
@@ -3,6 +3,7 @@ module Lita
3
3
  # Because we can.
4
4
  module Handlers
5
5
  # Main handler
6
+ # rubocop:disable Metrics/ClassLength
6
7
  class Jira < Handler
7
8
  namespace 'Jira'
8
9
 
@@ -114,18 +115,23 @@ module Lita
114
115
  end
115
116
 
116
117
  def ambient(response)
117
- return if invalid_ambient(response)
118
+ return if invalid_ambient?(response)
118
119
  issue = fetch_issue(response.match_data['issue'], false)
119
120
  response.reply(format_issue(issue)) if issue
120
121
  end
121
122
 
122
123
  private
123
124
 
124
- def invalid_ambient(response)
125
- response.message.command? || !config.ambient || config.ignore.include?(response.user.name) || (config.rooms && !config.rooms.include?(response.message.source.room))
125
+ def invalid_ambient?(response)
126
+ response.message.command? || !config.ambient || ignored?(response.user) || (config.rooms && !config.rooms.include?(response.message.source.room))
127
+ end
128
+
129
+ def ignored?(user)
130
+ config.ignore.include?(user.id) || config.ignore.include?(user.mention_name) || config.ignore.include?(user.name)
126
131
  end
127
132
  # rubocop:enable Metrics/AbcSize
128
133
  end
134
+ # rubocop:enable Metrics/ClassLength
129
135
  Lita.register_handler(Jira)
130
136
  end
131
137
  end
data/lita-jira.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-jira'
3
- spec.version = '0.7.0'
3
+ spec.version = '0.7.1'
4
4
  spec.authors = ['Eric Sigler', 'Matt Critchlow']
5
5
  spec.email = ['me@esigler.com', 'matt.critchlow@gmail.com']
6
6
  spec.description = 'A JIRA plugin for Lita.'
@@ -201,9 +201,11 @@ describe Lita::Handlers::Jira, lita_handler: true do
201
201
 
202
202
  context 'and an ignore list is defined' do
203
203
  before(:each) do
204
- @user1 = Lita::User.create(1, name: 'User1')
205
- @user2 = Lita::User.create(2, name: 'User2')
206
- registry.config.handlers.jira.ignore = ['User2']
204
+ @user1 = Lita::User.create('U1', name: 'User 1', mention_name: 'user1')
205
+ @user2 = Lita::User.create('U2', name: 'User 2', mention_name: 'user2')
206
+ @user3 = Lita::User.create('U3', name: 'User 3', mention_name: 'user3')
207
+ @user4 = Lita::User.create('U4', name: 'User 4', mention_name: 'user4')
208
+ registry.config.handlers.jira.ignore = ['User 2', 'U3', 'user4']
207
209
  end
208
210
 
209
211
  it 'shows details for a detected issue sent by a user absent from the list' do
@@ -211,10 +213,20 @@ describe Lita::Handlers::Jira, lita_handler: true do
211
213
  expect(replies.last).to eq("[XYZ-987] Some summary text\nStatus: In Progress, assigned to: A Person, fixVersion: Sprint 2, priority: P0\nhttp://jira.local/browse/XYZ-987")
212
214
  end
213
215
 
214
- it 'does not show details for a detected issue sent by a user on the list' do
216
+ it 'does not show details for a detected issue sent by a user whose name is on the list' do
215
217
  send_message('foo XYZ-987 bar', as: @user2)
216
218
  expect(replies.size).to eq(0)
217
219
  end
220
+
221
+ it 'does not show details for a detected issue sent by a user whose ID is on the list' do
222
+ send_message('foo XYZ-987 bar', as: @user3)
223
+ expect(replies.size).to eq(0)
224
+ end
225
+
226
+ it 'does not show details for a detected issue sent by a user whose mention name is on the list' do
227
+ send_message('foo XYZ-987 bar', as: @user4)
228
+ expect(replies.size).to eq(0)
229
+ end
218
230
  end
219
231
 
220
232
  context 'and a room list is defined' do
@@ -262,7 +274,7 @@ describe Lita::Handlers::Jira, lita_handler: true do
262
274
  it 'shows results when returned' do
263
275
  grab_request(valid_client)
264
276
  send_command('jira myissues')
265
- expect(replies.last).to eq([
277
+ expect(replies[-3..-1]).to eq([
266
278
  'Here are issues currently assigned to you:',
267
279
  "[XYZ-987] Some summary text\nStatus: In Progress, assigned to: A Person, fixVersion: Sprint 2, priority: P0\nhttp://jira.local/browse/XYZ-987",
268
280
  "[XYZ-988] Some summary text 2\nStatus: In Progress 2, assigned to: A Person 2, fixVersion: none, priority: P1\nhttp://jira.local/browse/XYZ-988"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-jira
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Sigler
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-07 00:00:00.000000000 Z
12
+ date: 2015-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: lita