lita-locker 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lita/handlers/locker.rb +21 -18
- data/lib/lita/handlers/locker_misc.rb +6 -4
- data/lib/locker/label.rb +1 -1
- data/lita-locker.gemspec +1 -1
- data/locales/en.yml +15 -15
- data/spec/lita/handlers/locker_labels_spec.rb +5 -5
- data/spec/lita/handlers/locker_misc_spec.rb +18 -10
- data/spec/lita/handlers/locker_spec.rb +45 -15
- data/templates/mention.erb +1 -0
- data/templates/mention.hipchat.erb +1 -0
- data/templates/mention.slack.erb +1 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6486024efd68e3b338f738adb2dad218b8d1b23f
|
4
|
+
data.tar.gz: 70ca546c520752096d4c0130de5f7907a98be117
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8adf1447143a90c49860d5bed23255b71420483db7d328619c6ccdb17e1ccb8c401e6eb77e95f52d3daaf6b34f0a9113c91d062a452956e29c6cba1b7976d37d
|
7
|
+
data.tar.gz: 1122f9f8241f56561ea73244f2547b2f3ed3deada9fd0983345f4aa03ebac7d8e415253902ec1163803104f8e332b34acd1e0c1fd61818fa292794b3391f4936
|
data/lib/lita/handlers/locker.rb
CHANGED
@@ -73,7 +73,7 @@ module Lita
|
|
73
73
|
return response.reply(failed(t('label.does_not_exist', name: name))) unless Label.exists?(name)
|
74
74
|
l = Label.new(name)
|
75
75
|
return response.reply(failed(t('label.no_resources', name: name))) unless l.membership.count > 0
|
76
|
-
return response.reply(t('label.self_lock', name: name)) if l.owner == response.user
|
76
|
+
return response.reply(t('label.self_lock', name: name, user: response.user.name)) if l.owner == response.user
|
77
77
|
return response.reply(success(t('label.lock', name: name))) if l.lock!(response.user.id)
|
78
78
|
|
79
79
|
response.reply(label_ownership(name))
|
@@ -90,7 +90,7 @@ module Lita
|
|
90
90
|
|
91
91
|
return if l.locked?
|
92
92
|
mention_names = l.observers
|
93
|
-
.map { |observer| observer.mention_name
|
93
|
+
.map { |observer| render_template('mention', name: observer.mention_name, id: observer.id) }
|
94
94
|
.reject { |mention| mention == '' }
|
95
95
|
.sort
|
96
96
|
.join(' ')
|
@@ -99,20 +99,22 @@ module Lita
|
|
99
99
|
|
100
100
|
def observe(response)
|
101
101
|
name = response.match_data['label']
|
102
|
+
user = response.user
|
102
103
|
return response.reply(failed(t('label.does_not_exist', name: name))) unless Label.exists?(name)
|
103
104
|
l = Label.new(name)
|
104
|
-
return response.reply(t('observe.already_observing', name: name)) if l.observer?(
|
105
|
-
l.add_observer!(
|
106
|
-
response.reply(t('observe.now_observing', name: name))
|
105
|
+
return response.reply(t('observe.already_observing', name: name, user: user.name)) if l.observer?(user.id)
|
106
|
+
l.add_observer!(user.id)
|
107
|
+
response.reply(t('observe.now_observing', name: name, user: user.name))
|
107
108
|
end
|
108
109
|
|
109
110
|
def unobserve(response)
|
110
111
|
name = response.match_data['label']
|
112
|
+
user = response.user
|
111
113
|
return response.reply(failed(t('label.does_not_exist', name: name))) unless Label.exists?(name)
|
112
114
|
l = Label.new(name)
|
113
|
-
return response.reply(t('observe.were_not_observing', name: name)) unless l.observer?(
|
114
|
-
l.remove_observer!(
|
115
|
-
response.reply(t('observe.stopped_observing', name: name))
|
115
|
+
return response.reply(t('observe.were_not_observing', name: name, user: user.name)) unless l.observer?(user.id)
|
116
|
+
l.remove_observer!(user.id)
|
117
|
+
response.reply(t('observe.stopped_observing', name: name, user: user.name))
|
116
118
|
end
|
117
119
|
|
118
120
|
def steal(response)
|
@@ -130,13 +132,14 @@ module Lita
|
|
130
132
|
|
131
133
|
return response.reply(failed(t('subject.does_not_exist', name: name))) unless Label.exists?(name)
|
132
134
|
l = Label.new(name)
|
133
|
-
owner_mention = l.owner.mention_name
|
135
|
+
owner_mention = render_template('mention', name: l.owner.mention_name, id: l.owner.id)
|
134
136
|
return response.reply(t('give.not_owner',
|
135
137
|
label: name,
|
136
138
|
owner: l.owner.name,
|
137
139
|
mention: owner_mention)) unless l.owner == response.user
|
138
|
-
|
139
|
-
|
140
|
+
recipient_name = response.match_data['username'].rstrip
|
141
|
+
recipient = Lita::User.fuzzy_find(recipient_name)
|
142
|
+
return response.reply(t('user.unknown', user: recipient_name)) unless recipient
|
140
143
|
|
141
144
|
response.reply(attempt_give(name, response.user, recipient))
|
142
145
|
end
|
@@ -145,20 +148,20 @@ module Lita
|
|
145
148
|
|
146
149
|
def attempt_give(name, giver, recipient)
|
147
150
|
label = Label.new(name)
|
148
|
-
return t('give.self') if recipient == giver
|
151
|
+
return t('give.self', user: giver.name) if recipient == giver
|
149
152
|
old_owner = label.owner
|
150
153
|
label.give!(recipient.id)
|
151
|
-
mention = recipient.mention_name
|
154
|
+
mention = render_template('mention', name: recipient.mention_name, id: recipient.id)
|
152
155
|
success(t('give.given', label: name, giver: old_owner.name, recipient: recipient.name, mention: mention))
|
153
156
|
end
|
154
157
|
|
155
158
|
def attempt_steal(name, user)
|
156
159
|
label = Label.new(name)
|
157
|
-
return t('steal.self') if label.owner == user
|
160
|
+
return t('steal.self', user: user.name) if label.owner == user
|
158
161
|
old_owner = label.owner
|
159
162
|
label.steal!(user.id)
|
160
|
-
mention = old_owner.mention_name
|
161
|
-
success(t('steal.stolen', label: name,
|
163
|
+
mention = render_template('mention', name: old_owner.mention_name, id: old_owner.id)
|
164
|
+
success(t('steal.stolen', label: name, thief: user.name, victim: old_owner.name, mention: mention))
|
162
165
|
end
|
163
166
|
|
164
167
|
def attempt_unlock(name, user)
|
@@ -166,13 +169,13 @@ module Lita
|
|
166
169
|
if label.owner == user
|
167
170
|
label.unlock!
|
168
171
|
if label.locked?
|
169
|
-
mention = label.owner.mention_name
|
172
|
+
mention = render_template('mention', name: label.owner.mention_name, id: label.owner.id)
|
170
173
|
failed(t('label.now_locked_by', name: name, owner: label.owner.name, mention: mention))
|
171
174
|
else
|
172
175
|
success(t('label.unlock', name: name))
|
173
176
|
end
|
174
177
|
else
|
175
|
-
mention = label.owner.mention_name
|
178
|
+
mention = render_template('mention', name: label.owner.mention_name, id: label.owner.id)
|
176
179
|
failed(t('label.owned_unlock', name: name, owner_name: label.owner.name, mention: mention, time: label.held_for))
|
177
180
|
end
|
178
181
|
end
|
@@ -65,19 +65,21 @@ module Lita
|
|
65
65
|
|
66
66
|
def dequeue(response)
|
67
67
|
name = response.match_data['label']
|
68
|
+
user = response.user
|
68
69
|
return response.reply(t('subject.does_not_exist', name: name)) unless Label.exists?(name)
|
69
70
|
l = Label.new(name)
|
70
|
-
l.wait_queue.
|
71
|
+
return response.reply(t('label.unknown_in_queue', name: name, user: user.name)) unless l.wait_queue.include?(user.id)
|
72
|
+
l.wait_queue.delete(user.id)
|
71
73
|
l.dedupe!
|
72
|
-
response.reply(t('label.removed_from_queue', name: name))
|
74
|
+
response.reply(t('label.removed_from_queue', name: name, user: user.name))
|
73
75
|
end
|
74
76
|
|
75
77
|
def list(response)
|
76
78
|
username = response.match_data['username']
|
77
79
|
user = Lita::User.fuzzy_find(username)
|
78
|
-
return response.reply(t('user.unknown')) unless user
|
80
|
+
return response.reply(t('user.unknown', user: username)) unless user
|
79
81
|
l = user_locks(user)
|
80
|
-
return response.reply(t('user.no_active_locks')) unless l.size > 0
|
82
|
+
return response.reply(t('user.no_active_locks', user: user.name)) unless l.size > 0
|
81
83
|
composed = ''
|
82
84
|
l.each do |label_name|
|
83
85
|
composed += "Label: #{label_name}\n"
|
data/lib/locker/label.rb
CHANGED
@@ -193,7 +193,7 @@ module Locker
|
|
193
193
|
usr = Lita::User.find_by_id(u)
|
194
194
|
queue.push(usr.name)
|
195
195
|
end
|
196
|
-
mention = l.owner.mention_name
|
196
|
+
mention = render_template('mention', name: l.owner.mention_name, id: l.owner.id)
|
197
197
|
failed(t('label.owned_lock', name: name,
|
198
198
|
owner_name: l.owner.name,
|
199
199
|
mention: mention,
|
data/lita-locker.gemspec
CHANGED
data/locales/en.yml
CHANGED
@@ -3,18 +3,18 @@ en:
|
|
3
3
|
handlers:
|
4
4
|
locker:
|
5
5
|
steal:
|
6
|
-
stolen: "%{label}
|
6
|
+
stolen: "%{thief} stole %{label} from %{victim} %{mention}"
|
7
7
|
already_unlocked: "%{label} was already unlocked"
|
8
|
-
self:
|
8
|
+
self: "%{user}, why are you stealing the lock from yourself?"
|
9
9
|
give:
|
10
10
|
not_owner: "The lock on %{label} can only be given by its current owner: %{owner} %{mention}"
|
11
11
|
given: "%{giver} gave %{label} to %{recipient} %{mention}"
|
12
|
-
self:
|
12
|
+
self: "%{user}, why are you giving the lock to yourself?"
|
13
13
|
observe:
|
14
|
-
now_observing: "
|
15
|
-
already_observing: "
|
16
|
-
stopped_observing: "
|
17
|
-
were_not_observing: "
|
14
|
+
now_observing: "%{user} is now observing %{name}"
|
15
|
+
already_observing: "%{user}, you are already observing %{name}"
|
16
|
+
stopped_observing: "%{user}, you have stopped observing %{name}"
|
17
|
+
were_not_observing: "%{user}, you were not observing %{name}"
|
18
18
|
help:
|
19
19
|
log:
|
20
20
|
syntax: locker log <label>
|
@@ -91,12 +91,12 @@ en:
|
|
91
91
|
owned: "%{name} is locked by %{owner_name}"
|
92
92
|
owned_mention: "%{name} is locked by %{owner_name} (@%{owner_mention})"
|
93
93
|
status:
|
94
|
-
does_not_exist: "
|
94
|
+
does_not_exist: "%{name} does not exist. Use * for wildcard search"
|
95
95
|
subject:
|
96
|
-
does_not_exist: "
|
96
|
+
does_not_exist: "%{name} does not exist"
|
97
97
|
label:
|
98
98
|
log_entry: "%{entry}"
|
99
|
-
self_lock: "
|
99
|
+
self_lock: "%{user}, you already have the lock on %{name}"
|
100
100
|
unlock: "%{name} unlocked"
|
101
101
|
owned_lock: "%{name} is locked by %{owner_name} %{mention} (taken %{time}), you have been added to the queue (currently: %{queue}), type 'locker dequeue %{name}' to be removed"
|
102
102
|
owned_unlock: "%{name} is locked by %{owner_name} %{mention} (taken %{time})"
|
@@ -110,7 +110,7 @@ en:
|
|
110
110
|
created: "Label %{name} created"
|
111
111
|
exists: "%{name} already exists"
|
112
112
|
deleted: "Label %{name} deleted"
|
113
|
-
does_not_exist: "Label %{name} does not exist.
|
113
|
+
does_not_exist: "Label %{name} does not exist. To create it: \"!locker label create %{name}\""
|
114
114
|
has_no_resources: "Label %{name} has no resources"
|
115
115
|
resource_added: "Resource %{resource} has been added to %{label}"
|
116
116
|
resource_removed: "Resource %{resource} has been removed from %{label}"
|
@@ -119,8 +119,8 @@ en:
|
|
119
119
|
no_resources: "%{name} has no resources, so it cannot be locked"
|
120
120
|
dependency: 'Label unable to be locked, blocked on:'
|
121
121
|
now_locked_by: "%{name} now locked by %{owner} %{mention}"
|
122
|
-
removed_from_queue: "
|
123
|
-
unknown_in_queue: "
|
122
|
+
removed_from_queue: "%{user} has been removed from the queue for %{name}"
|
123
|
+
unknown_in_queue: "%{user}, you weren't in the queue for %{name}"
|
124
124
|
user:
|
125
|
-
unknown: Unknown user
|
126
|
-
no_active_locks:
|
125
|
+
unknown: "Unknown user '%{user}'"
|
126
|
+
no_active_locks: "%{user} has no active locks"
|
@@ -81,7 +81,7 @@ describe Lita::Handlers::LockerLabels, lita_handler: true do
|
|
81
81
|
|
82
82
|
it 'shows a warning when <name> does not exist' do
|
83
83
|
send_command('locker label delete foobar')
|
84
|
-
expect(replies.last).to eq('Label foobar does not exist.
|
84
|
+
expect(replies.last).to eq('Label foobar does not exist. To create it: "!locker label create foobar"')
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'accepts a comma-separated list of labels' do
|
@@ -108,7 +108,7 @@ describe Lita::Handlers::LockerLabels, lita_handler: true do
|
|
108
108
|
|
109
109
|
it 'shows an error if the label does not exist' do
|
110
110
|
send_command('locker label show foobar')
|
111
|
-
expect(replies.last).to eq('Label foobar does not exist.
|
111
|
+
expect(replies.last).to eq('Label foobar does not exist. To create it: "!locker label create foobar"')
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
@@ -144,7 +144,7 @@ describe Lita::Handlers::LockerLabels, lita_handler: true do
|
|
144
144
|
|
145
145
|
it 'shows an error if the label does not exist' do
|
146
146
|
send_command('locker label add foo to bar')
|
147
|
-
expect(replies.last).to eq('Label bar does not exist.
|
147
|
+
expect(replies.last).to eq('Label bar does not exist. To create it: "!locker label create bar"')
|
148
148
|
end
|
149
149
|
|
150
150
|
it 'shows an error if the resource does not exist' do
|
@@ -182,12 +182,12 @@ describe Lita::Handlers::LockerLabels, lita_handler: true do
|
|
182
182
|
|
183
183
|
it 'shows an error if the label does not exist' do
|
184
184
|
send_command('locker label add foo to bar')
|
185
|
-
expect(replies.last).to eq('Label bar does not exist.
|
185
|
+
expect(replies.last).to eq('Label bar does not exist. To create it: "!locker label create bar"')
|
186
186
|
end
|
187
187
|
|
188
188
|
it 'shows an error if the label does not exist when given a list of resources' do
|
189
189
|
send_command('locker label add foo, baz to bar')
|
190
|
-
expect(replies.last).to eq('Label bar does not exist.
|
190
|
+
expect(replies.last).to eq('Label bar does not exist. To create it: "!locker label create bar"')
|
191
191
|
end
|
192
192
|
|
193
193
|
it 'shows an error if the resource does not exist' do
|
@@ -57,25 +57,25 @@ describe Lita::Handlers::LockerMisc, lita_handler: true do
|
|
57
57
|
|
58
58
|
it 'shows a warning if the label does not exist' do
|
59
59
|
send_command('locker log something')
|
60
|
-
expect(replies.last).to eq('
|
60
|
+
expect(replies.last).to eq('something does not exist')
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
describe '#dequeue' do
|
65
|
-
|
65
|
+
before(:each) do
|
66
66
|
send_command('locker resource create bar')
|
67
67
|
send_command('locker label create foo')
|
68
68
|
send_command('locker label add bar to foo')
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'shows a successful dequeue' do
|
69
72
|
send_command('lock foo', as: alice)
|
70
73
|
send_command('lock foo', as: bob)
|
71
74
|
send_command('locker dequeue foo', as: bob)
|
72
|
-
expect(replies.last).to eq('
|
75
|
+
expect(replies.last).to eq('Bob has been removed from the queue for foo')
|
73
76
|
end
|
74
77
|
|
75
78
|
it 'avoids adjacent duplicates in the queue when a sandwiched dequeue occurs' do
|
76
|
-
send_command('locker resource create bar')
|
77
|
-
send_command('locker label create foo')
|
78
|
-
send_command('locker label add bar to foo')
|
79
79
|
send_command('lock foo', as: alice)
|
80
80
|
send_command('lock foo', as: bob)
|
81
81
|
send_command('lock foo', as: doris)
|
@@ -84,6 +84,14 @@ describe Lita::Handlers::LockerMisc, lita_handler: true do
|
|
84
84
|
send_command('locker status foo')
|
85
85
|
expect(replies.last).to match(/^foo is locked by Alice \(taken \d seconds? ago\)\. Next up: Bob$/)
|
86
86
|
end
|
87
|
+
|
88
|
+
it 'does not allow a user who is not in the queue to dequeue' do
|
89
|
+
send_command('lock foo', as: alice)
|
90
|
+
send_command('lock foo', as: bob)
|
91
|
+
send_command('unlock foo', as: alice)
|
92
|
+
send_command('locker dq foo', as: bob)
|
93
|
+
expect(replies.last).to match(/^Bob, you weren't in the queue for foo$/)
|
94
|
+
end
|
87
95
|
end
|
88
96
|
|
89
97
|
describe '#status' do
|
@@ -142,7 +150,7 @@ describe Lita::Handlers::LockerMisc, lita_handler: true do
|
|
142
150
|
send_command('locker label create bazbar')
|
143
151
|
send_command('locker label add bazbarluhrmann to bazbar')
|
144
152
|
send_command('locker status foo')
|
145
|
-
expect(replies.last).to eq('
|
153
|
+
expect(replies.last).to eq('foo does not exist. Use * for wildcard search')
|
146
154
|
end
|
147
155
|
end
|
148
156
|
|
@@ -179,16 +187,16 @@ describe Lita::Handlers::LockerMisc, lita_handler: true do
|
|
179
187
|
send_command('locker label create bazbat')
|
180
188
|
send_command('locker label add foobar to bazbat')
|
181
189
|
send_command('locker list Alice', as: alice)
|
182
|
-
expect(replies.last).to eq('
|
190
|
+
expect(replies.last).to eq('Alice has no active locks')
|
183
191
|
send_command('lock bazbat', as: alice)
|
184
192
|
send_command('unlock bazbat', as: alice)
|
185
193
|
send_command('locker list Alice', as: alice)
|
186
|
-
expect(replies.last).to eq('
|
194
|
+
expect(replies.last).to eq('Alice has no active locks')
|
187
195
|
end
|
188
196
|
|
189
197
|
it 'shows a warning when the user does not exist' do
|
190
198
|
send_command('locker list foobar')
|
191
|
-
expect(replies.last).to eq(
|
199
|
+
expect(replies.last).to eq("Unknown user 'foobar'")
|
192
200
|
end
|
193
201
|
end
|
194
202
|
end
|
@@ -74,9 +74,9 @@ describe Lita::Handlers::Locker, lita_handler: true do
|
|
74
74
|
send_command('locker resource create foobar')
|
75
75
|
send_command('locker label create bazbat')
|
76
76
|
send_command('locker label add foobar to bazbat')
|
77
|
-
send_command('lock bazbat')
|
78
|
-
send_command('lock bazbat')
|
79
|
-
expect(replies.last).to eq('
|
77
|
+
send_command('lock bazbat', as: alice)
|
78
|
+
send_command('lock bazbat', as: alice)
|
79
|
+
expect(replies.last).to eq('Alice, you already have the lock on bazbat')
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'does not add a user multiple times to the end of a queue' do
|
@@ -134,7 +134,37 @@ describe Lita::Handlers::Locker, lita_handler: true do
|
|
134
134
|
|
135
135
|
it 'shows an error when a label does not exist' do
|
136
136
|
send_command('lock foobar')
|
137
|
-
expect(replies.last).to eq('Label foobar does not exist.
|
137
|
+
expect(replies.last).to eq('Label foobar does not exist. To create it: "!locker label create foobar"')
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'when mentioning a user' do
|
141
|
+
before(:each) do
|
142
|
+
send_command('locker resource create foobar')
|
143
|
+
send_command('locker label create bazbat')
|
144
|
+
send_command('locker label add foobar to bazbat')
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'only uses a full name when the user has no mention name' do
|
148
|
+
david = Lita::User.create('123', name: 'David', mention_name: nil)
|
149
|
+
send_command('lock bazbat', as: david)
|
150
|
+
send_command('lock bazbat', as: bob)
|
151
|
+
expect(replies.last).to match(/^bazbat is locked by David \(taken/)
|
152
|
+
end
|
153
|
+
|
154
|
+
it "includes the user's mention name in Hipchat" do
|
155
|
+
allow(robot.config.robot).to receive(:adapter).and_return('hipchat')
|
156
|
+
send_command('lock bazbat', as: alice)
|
157
|
+
send_command('lock bazbat', as: bob)
|
158
|
+
expect(replies.last).to match(/^\(failed\) bazbat is locked by Alice \(@alice\) \(taken/)
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'uses the correct mention formatting in Slack' do
|
162
|
+
allow(robot.config.robot).to receive(:adapter).and_return('slack')
|
163
|
+
emily = Lita::User.create('U12345678', name: 'Emily', mention_name: 'emily')
|
164
|
+
send_command('lock bazbat', as: emily)
|
165
|
+
send_command('lock bazbat', as: bob)
|
166
|
+
expect(replies.last).to match(/^:failed: bazbat is locked by Emily \(<@U12345678\|emily>\) \(taken/)
|
167
|
+
end
|
138
168
|
end
|
139
169
|
end
|
140
170
|
|
@@ -225,7 +255,7 @@ describe Lita::Handlers::Locker, lita_handler: true do
|
|
225
255
|
|
226
256
|
it 'shows an error when a <subject> does not exist' do
|
227
257
|
send_command('unlock foobar')
|
228
|
-
expect(replies.last).to eq('
|
258
|
+
expect(replies.last).to eq('foobar does not exist')
|
229
259
|
end
|
230
260
|
end
|
231
261
|
|
@@ -236,7 +266,7 @@ describe Lita::Handlers::Locker, lita_handler: true do
|
|
236
266
|
send_command('locker label add foobar to bazbat')
|
237
267
|
send_command('lock bazbat', as: alice)
|
238
268
|
send_command('steal bazbat # with a comment', as: bob)
|
239
|
-
expect(replies.last).to eq('bazbat
|
269
|
+
expect(replies.last).to eq('Bob stole bazbat from Alice (@alice)')
|
240
270
|
end
|
241
271
|
|
242
272
|
it 'preserves the state of the queue when there is one' do
|
@@ -264,12 +294,12 @@ describe Lita::Handlers::Locker, lita_handler: true do
|
|
264
294
|
send_command('locker label add foobar to bazbat')
|
265
295
|
send_command('lock bazbat', as: alice)
|
266
296
|
send_command('steal bazbat # with a comment', as: alice)
|
267
|
-
expect(replies.last).to eq('
|
297
|
+
expect(replies.last).to eq('Alice, why are you stealing the lock from yourself?')
|
268
298
|
end
|
269
299
|
|
270
300
|
it 'shows an error when a <subject> does not exist' do
|
271
301
|
send_command('steal foobar')
|
272
|
-
expect(replies.last).to eq('
|
302
|
+
expect(replies.last).to eq('foobar does not exist')
|
273
303
|
end
|
274
304
|
end
|
275
305
|
|
@@ -301,7 +331,7 @@ describe Lita::Handlers::Locker, lita_handler: true do
|
|
301
331
|
send_command('locker label add foobar to bazbat')
|
302
332
|
send_command('lock bazbat', as: alice)
|
303
333
|
send_command('locker give bazbat to @alice # with a comment', as: alice)
|
304
|
-
expect(replies.last).to eq('
|
334
|
+
expect(replies.last).to eq('Alice, why are you giving the lock to yourself?')
|
305
335
|
end
|
306
336
|
|
307
337
|
it 'shows an error when the attempted giver is not the owner' do
|
@@ -315,7 +345,7 @@ describe Lita::Handlers::Locker, lita_handler: true do
|
|
315
345
|
|
316
346
|
it 'shows an error when the label does not exist' do
|
317
347
|
send_command('locker give foobar to @bob', as: alice)
|
318
|
-
expect(replies.last).to eq('
|
348
|
+
expect(replies.last).to eq('foobar does not exist')
|
319
349
|
end
|
320
350
|
|
321
351
|
it 'shows an error when the recipient does not exist' do
|
@@ -324,7 +354,7 @@ describe Lita::Handlers::Locker, lita_handler: true do
|
|
324
354
|
send_command('locker label add foobar to bazbat')
|
325
355
|
send_command('lock bazbat', as: alice)
|
326
356
|
send_command('locker give bazbat to @doris', as: alice)
|
327
|
-
expect(replies.last).to eq(
|
357
|
+
expect(replies.last).to eq("Unknown user 'doris'")
|
328
358
|
end
|
329
359
|
end
|
330
360
|
|
@@ -334,7 +364,7 @@ describe Lita::Handlers::Locker, lita_handler: true do
|
|
334
364
|
send_command('locker label create bazbat')
|
335
365
|
send_command('locker label add foobar to bazbat')
|
336
366
|
send_command('locker observe bazbat', as: alice)
|
337
|
-
expect(replies.last).to eq('
|
367
|
+
expect(replies.last).to eq('Alice is now observing bazbat')
|
338
368
|
end
|
339
369
|
|
340
370
|
it 'warns user if already observing label' do
|
@@ -343,7 +373,7 @@ describe Lita::Handlers::Locker, lita_handler: true do
|
|
343
373
|
send_command('locker label add foobar to bazbat')
|
344
374
|
send_command('locker observe bazbat', as: alice)
|
345
375
|
send_command('locker observe bazbat', as: alice)
|
346
|
-
expect(replies.last).to eq('
|
376
|
+
expect(replies.last).to eq('Alice, you are already observing bazbat')
|
347
377
|
end
|
348
378
|
end
|
349
379
|
|
@@ -354,7 +384,7 @@ describe Lita::Handlers::Locker, lita_handler: true do
|
|
354
384
|
send_command('locker label add foobar to bazbat')
|
355
385
|
send_command('locker observe bazbat', as: alice)
|
356
386
|
send_command('locker unobserve bazbat', as: alice)
|
357
|
-
expect(replies.last).to eq('
|
387
|
+
expect(replies.last).to eq('Alice, you have stopped observing bazbat')
|
358
388
|
end
|
359
389
|
|
360
390
|
it 'warns user if already not observing label' do
|
@@ -364,7 +394,7 @@ describe Lita::Handlers::Locker, lita_handler: true do
|
|
364
394
|
send_command('locker observe bazbat', as: alice)
|
365
395
|
send_command('locker unobserve bazbat', as: alice)
|
366
396
|
send_command('locker unobserve bazbat', as: alice)
|
367
|
-
expect(replies.last).to eq('
|
397
|
+
expect(replies.last).to eq('Alice, you were not observing bazbat')
|
368
398
|
end
|
369
399
|
end
|
370
400
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<% unless @name.empty? %>(@<%= @name %>)<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
(@<%= @name %>)
|
@@ -0,0 +1 @@
|
|
1
|
+
(<@<%= @id %>|<%= @name %>>)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-locker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Sigler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -178,6 +178,9 @@ files:
|
|
178
178
|
- templates/lock.erb
|
179
179
|
- templates/lock.hipchat.erb
|
180
180
|
- templates/lock.slack.erb
|
181
|
+
- templates/mention.erb
|
182
|
+
- templates/mention.hipchat.erb
|
183
|
+
- templates/mention.slack.erb
|
181
184
|
- templates/success.erb
|
182
185
|
- templates/success.hipchat.erb
|
183
186
|
- templates/success.slack.erb
|