lita-slack 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/lita/adapters/slack/slack_user.rb +5 -2
- data/lib/lita/adapters/slack/user_creator.rb +1 -0
- data/lita-slack.gemspec +1 -1
- data/spec/lita/adapters/slack/rtm_connection_spec.rb +3 -2
- data/spec/lita/adapters/slack/user_creator_spec.rb +14 -2
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d66ec3a2b33e9d4634eac3a5ea31ade4d9cd2cf8
|
4
|
+
data.tar.gz: f01ab130866459571e789c46eceb842799e65c6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44def16efc15e4f9fff1fa74ea41d1160763549ec0428e387e21866c7b59c61d6316757ed846f68415b8f51bcf037f2eced9206c8dfa0353cb9397a573af3bb1
|
7
|
+
data.tar.gz: f41d6fbca14f735c0488116404f1acdc6afe97353ea9efa4bb5da47b299a9bbc0393bf2693600568f5348bd0702206d067622e464c847eed9776ac0aac97b2d6
|
data/README.md
CHANGED
@@ -47,6 +47,7 @@ Lita will join your default channel after initial setup. To have it join additio
|
|
47
47
|
|
48
48
|
* `:connected` - When the robot has connected to Slack. No payload.
|
49
49
|
* `:disconnected` - When the robot has disconnected from Slack. No payload.
|
50
|
+
* `:slack_user_created` - When the robot creates/updates a user's info - name, mention name, etc..., as directed by Slack. The payload has a single object, under the `:slack_user` key.
|
50
51
|
|
51
52
|
## License
|
52
53
|
|
@@ -7,7 +7,8 @@ module Lita
|
|
7
7
|
new(
|
8
8
|
user_data['id'],
|
9
9
|
user_data['name'],
|
10
|
-
user_data['real_name']
|
10
|
+
user_data['real_name'],
|
11
|
+
user_data
|
11
12
|
)
|
12
13
|
end
|
13
14
|
|
@@ -19,11 +20,13 @@ module Lita
|
|
19
20
|
attr_reader :id
|
20
21
|
attr_reader :name
|
21
22
|
attr_reader :real_name
|
23
|
+
attr_reader :raw_data
|
22
24
|
|
23
|
-
def initialize(id, name, real_name)
|
25
|
+
def initialize(id, name, real_name, raw_data)
|
24
26
|
@id = id
|
25
27
|
@name = name
|
26
28
|
@real_name = real_name.to_s
|
29
|
+
@raw_data = raw_data
|
27
30
|
end
|
28
31
|
end
|
29
32
|
end
|
data/lita-slack.gemspec
CHANGED
@@ -14,11 +14,12 @@ describe Lita::Adapters::Slack::RTMConnection, lita: true do
|
|
14
14
|
let(:api) { instance_double("Lita::Adapters::Slack::API") }
|
15
15
|
let(:registry) { Lita::Registry.new }
|
16
16
|
let(:robot) { Lita::Robot.new(registry) }
|
17
|
+
let(:raw_user_data) { Hash.new }
|
17
18
|
let(:rtm_start_response) do
|
18
19
|
Lita::Adapters::Slack::TeamData.new(
|
19
20
|
[],
|
20
|
-
Lita::Adapters::Slack::SlackUser.new('U12345678', 'carl', nil),
|
21
|
-
[Lita::Adapters::Slack::SlackUser.new('U12345678', 'carl', '')],
|
21
|
+
Lita::Adapters::Slack::SlackUser.new('U12345678', 'carl', nil, raw_user_data),
|
22
|
+
[Lita::Adapters::Slack::SlackUser.new('U12345678', 'carl', '', raw_user_data)],
|
22
23
|
"wss://example.com/"
|
23
24
|
)
|
24
25
|
end
|
@@ -5,10 +5,17 @@ describe Lita::Adapters::Slack::UserCreator do
|
|
5
5
|
|
6
6
|
let(:robot) { instance_double('Lita::Robot') }
|
7
7
|
|
8
|
+
before do
|
9
|
+
allow(robot).to receive(:trigger).with(
|
10
|
+
:slack_user_created, hash_including(:slack_user)
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
8
14
|
describe ".create_users" do
|
9
15
|
let(:real_name) { 'Bobby Tables' }
|
10
|
-
let(:bobby) { Lita::Adapters::Slack::SlackUser.new('U023BECGF', 'bobby', real_name) }
|
16
|
+
let(:bobby) { Lita::Adapters::Slack::SlackUser.new('U023BECGF', 'bobby', real_name, slack_data) }
|
11
17
|
let(:robot_id) { 'U12345678' }
|
18
|
+
let(:slack_data) { { 'id' => 'U023BECGF', 'name' => 'bobby', 'real_name' => real_name } }
|
12
19
|
|
13
20
|
it "creates Lita users for each user in the provided data" do
|
14
21
|
expect(Lita::User).to receive(:create).with(
|
@@ -16,6 +23,10 @@ describe Lita::Adapters::Slack::UserCreator do
|
|
16
23
|
name: 'Bobby Tables',
|
17
24
|
mention_name: 'bobby'
|
18
25
|
)
|
26
|
+
expect(robot).to receive(:trigger).with(
|
27
|
+
:slack_user_created,
|
28
|
+
slack_user: bobby
|
29
|
+
)
|
19
30
|
|
20
31
|
described_class.create_users([bobby], robot, robot_id)
|
21
32
|
end
|
@@ -37,7 +48,8 @@ describe Lita::Adapters::Slack::UserCreator do
|
|
37
48
|
|
38
49
|
describe ".create_user" do
|
39
50
|
let(:robot_id) { 'U12345678' }
|
40
|
-
let(:
|
51
|
+
let(:slack_data) { { 'id' => robot_id, 'name' => 'litabot', 'real_name' => 'Lita Bot' } }
|
52
|
+
let(:slack_user) { Lita::Adapters::Slack::SlackUser.new(robot_id, 'litabot', 'Lita Bot', slack_data) }
|
41
53
|
|
42
54
|
it "updates the robot's name and mention name if it applicable" do
|
43
55
|
expect(robot).to receive(:name=).with('Lita Bot')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-slack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken J.
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-03-
|
12
|
+
date: 2015-03-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -238,4 +238,3 @@ test_files:
|
|
238
238
|
- spec/lita/adapters/slack/user_creator_spec.rb
|
239
239
|
- spec/lita/adapters/slack_spec.rb
|
240
240
|
- spec/spec_helper.rb
|
241
|
-
has_rdoc:
|