lita-team 1.0.0 → 2.0.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 +4 -4
- data/.rubocop.yml +243 -0
- data/.ruby-version +1 -1
- data/.travis.yml +1 -1
- data/README.md +2 -1
- data/lib/lita/handlers/add_member_to_team.rb +74 -0
- data/lib/lita/handlers/block_team.rb +42 -0
- data/lib/lita/handlers/clear_team.rb +38 -0
- data/lib/lita/handlers/confirm_member.rb +56 -0
- data/lib/lita/handlers/create_team.rb +38 -0
- data/lib/lita/handlers/delete_team.rb +26 -0
- data/lib/lita/handlers/list_team.rb +36 -0
- data/lib/lita/handlers/list_teams.rb +35 -0
- data/lib/lita/handlers/remove_member_from_team.rb +63 -0
- data/lib/lita/handlers/team.rb +2 -53
- data/lib/lita/handlers/update_team.rb +63 -0
- data/lib/lita-team.rb +12 -16
- data/lita-team.gemspec +2 -2
- data/locales/en.yml +21 -15
- data/spec/lita/handlers/add_member_to_team_spec.rb +92 -0
- data/spec/lita/handlers/block_team_spec.rb +29 -0
- data/spec/lita/handlers/clear_team_spec.rb +21 -0
- data/spec/lita/handlers/confirm_member_spec.rb +82 -0
- data/spec/lita/handlers/create_team_spec.rb +18 -0
- data/spec/lita/handlers/delete_team_spec.rb +20 -0
- data/spec/lita/handlers/list_team_spec.rb +65 -0
- data/spec/lita/handlers/list_teams_spec.rb +26 -0
- data/spec/lita/handlers/remove_member_from_team_spec.rb +104 -0
- data/spec/lita/handlers/team_spec.rb +0 -199
- data/spec/lita/handlers/update_team_spec.rb +41 -0
- data/spec/spec_helper.rb +1 -1
- data/templates/list_team.erb +8 -5
- data/templates/list_teams.erb +2 -8
- data/templates/member_added_to_team.erb +2 -2
- data/templates/member_confirmed.erb +4 -0
- data/templates/member_not_on_team.erb +0 -0
- data/templates/member_removed_from_team.erb +3 -3
- data/templates/team_already_exists.erb +1 -0
- data/templates/team_blocked.erb +1 -0
- data/templates/team_cannot_perform_operation.erb +1 -0
- data/templates/team_created.erb +1 -0
- data/templates/team_deleted.erb +1 -0
- data/templates/team_not_found.erb +1 -0
- data/templates/team_unblocked.erb +1 -0
- data/templates/team_updated.erb +1 -0
- metadata +46 -17
- data/lib/lita/actions/add_member_to_team.rb +0 -38
- data/lib/lita/actions/base.rb +0 -28
- data/lib/lita/actions/clear_team.rb +0 -30
- data/lib/lita/actions/create_team.rb +0 -21
- data/lib/lita/actions/delete_team.rb +0 -21
- data/lib/lita/actions/list_team.rb +0 -25
- data/lib/lita/actions/list_teams.rb +0 -11
- data/lib/lita/actions/remove_member_from_team.rb +0 -37
- data/lib/lita/member.rb +0 -17
- data/lib/lita/store/member.rb +0 -32
- data/lib/lita/store/team.rb +0 -34
- data/lib/lita/team.rb +0 -27
@@ -0,0 +1,63 @@
|
|
1
|
+
module Lita
|
2
|
+
module Handlers
|
3
|
+
class RemoveMemberFromTeam < Handler
|
4
|
+
namespace :team
|
5
|
+
template_root File.expand_path("../../../../templates", __FILE__)
|
6
|
+
|
7
|
+
route(
|
8
|
+
/(\S*) team (-1|remove me|remove (\S*))$/i,
|
9
|
+
:remove,
|
10
|
+
command: true,
|
11
|
+
help:
|
12
|
+
{
|
13
|
+
"<name> team -1" => "remove me from team",
|
14
|
+
"<name> team remove me" => "remove me from team",
|
15
|
+
"<name> team remove <member>" => "remove member from team"
|
16
|
+
}
|
17
|
+
)
|
18
|
+
|
19
|
+
def remove(response)
|
20
|
+
team_name = response.match_data[1]
|
21
|
+
if team = get_team(team_name)
|
22
|
+
if team[:limit] && team[:limit] <= team[:members].count
|
23
|
+
return response.reply(
|
24
|
+
render_template(:team_cannot_perform_operation,
|
25
|
+
team_name: team_name)
|
26
|
+
)
|
27
|
+
else
|
28
|
+
member_name = (response.match_data[3] ||
|
29
|
+
response.user.mention_name).delete("@")
|
30
|
+
if team[:members].key?(member_name.to_sym)
|
31
|
+
member = team[:members].delete(member_name.to_sym)
|
32
|
+
count = team[:members].count
|
33
|
+
redis.set(team_name, MultiJson.dump(team))
|
34
|
+
response.reply(
|
35
|
+
render_template(:member_removed_from_team,
|
36
|
+
team_name: team_name,
|
37
|
+
member_name: member[:name],
|
38
|
+
count: count)
|
39
|
+
)
|
40
|
+
else
|
41
|
+
response.reply(
|
42
|
+
t("member.not_in_team",
|
43
|
+
team_name: team_name,
|
44
|
+
member_name: member_name)
|
45
|
+
)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
else
|
49
|
+
response.reply(render_template(:team_not_found, team_name: team_name))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def get_team(team_name)
|
56
|
+
data = redis.get(team_name)
|
57
|
+
MultiJson.load(data, symbolize_keys: true) if data
|
58
|
+
end
|
59
|
+
|
60
|
+
Lita.register_handler(self)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/lita/handlers/team.rb
CHANGED
@@ -1,58 +1,7 @@
|
|
1
1
|
module Lita
|
2
2
|
module Handlers
|
3
|
-
class Team
|
4
|
-
|
5
|
-
|
6
|
-
route(/create (\S*) team/i, command: true, help: {
|
7
|
-
"create <name> team" => "create team called <name>"
|
8
|
-
}) do |response|
|
9
|
-
Lita::Actions::CreateTeam.new(response).call
|
10
|
-
end
|
11
|
-
|
12
|
-
route(/(delete|remove) (\S*) team/i, command: true, help: {
|
13
|
-
"delete <name> team" => "delete team called <name>",
|
14
|
-
"remove <name> team" => "delete team called <name>",
|
15
|
-
}) do |response|
|
16
|
-
Lita::Actions::DeleteTeam.new(response).call
|
17
|
-
end
|
18
|
-
|
19
|
-
route(/list teams/i, command: true, help: {
|
20
|
-
"list teams" => "list all teams"
|
21
|
-
}) do |response|
|
22
|
-
Lita::Actions::ListTeams.new(response).call
|
23
|
-
end
|
24
|
-
|
25
|
-
route(/(\S*) team (\+1|add me|add (\S*))/i, command: true, help: {
|
26
|
-
"<name> team +1" => "add me to team",
|
27
|
-
"<name> team add me" => "add me to team",
|
28
|
-
"<name> team add <user>" => "add user to team",
|
29
|
-
}) do |response|
|
30
|
-
Lita::Actions::AddMemberToTeam.new(response).call
|
31
|
-
end
|
32
|
-
|
33
|
-
route(/(\S*) team (-1|remove me|remove (\S*))/i, command: true, help: {
|
34
|
-
"<name> team -1" => "remove me from team",
|
35
|
-
"<name> team remove me" => "remove me from team",
|
36
|
-
"<name> team remove <user>" => "remove <user> from team",
|
37
|
-
}) do |response|
|
38
|
-
Lita::Actions::RemoveMemberFromTeam.new(response).call
|
39
|
-
end
|
40
|
-
|
41
|
-
route(/(\S*) team (list|show)/i, command: true, help: {
|
42
|
-
"<name> team list" => "list the people in the team",
|
43
|
-
"<name> team show" => "list the people in the team",
|
44
|
-
}) do |response|
|
45
|
-
Lita::Actions::ListTeam.new(response).call
|
46
|
-
end
|
47
|
-
|
48
|
-
route(/(\S*) team (clear|empty)/i, command: true, help: {
|
49
|
-
"<name> team clear" => "clear team list",
|
50
|
-
"<name> team empty" => "clear team list",
|
51
|
-
}) do |response|
|
52
|
-
Lita::Actions::ClearTeam.new(response).call
|
53
|
-
end
|
3
|
+
class Team < Handler
|
4
|
+
Lita.register_handler(self)
|
54
5
|
end
|
55
|
-
|
56
|
-
Lita.register_handler(Team)
|
57
6
|
end
|
58
7
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Lita
|
2
|
+
module Handlers
|
3
|
+
class UpdateTeam < Handler
|
4
|
+
namespace :team
|
5
|
+
template_root File.expand_path("../../../../templates", __FILE__)
|
6
|
+
|
7
|
+
route(
|
8
|
+
/(\S*) team set (limit|location|icon) (.+)/i,
|
9
|
+
:update,
|
10
|
+
command: true,
|
11
|
+
help: {
|
12
|
+
"<name> team set limit <value>" => "update team members limit",
|
13
|
+
"<name> team set location <value>" => "update team location",
|
14
|
+
"<name> team set icon <value>" => "update team icon"
|
15
|
+
}
|
16
|
+
)
|
17
|
+
|
18
|
+
ATTRIBUTES_MAPPING = {
|
19
|
+
limit: :to_i,
|
20
|
+
location: :to_s,
|
21
|
+
icon: :to_s
|
22
|
+
}.freeze
|
23
|
+
|
24
|
+
def update(response)
|
25
|
+
team_name = response.match_data[1]
|
26
|
+
if team = get_team(team_name)
|
27
|
+
attribute = response.match_data[2].to_sym
|
28
|
+
value = parse_attribute_value(attribute, response.match_data[3])
|
29
|
+
team[attribute] = value
|
30
|
+
save_team(team)
|
31
|
+
response.reply(
|
32
|
+
render_template(:team_updated,
|
33
|
+
team_name: team_name,
|
34
|
+
attribute: attribute,
|
35
|
+
value: value
|
36
|
+
)
|
37
|
+
)
|
38
|
+
else
|
39
|
+
response.reply(
|
40
|
+
render_template(:team_not_found, team_name: team_name)
|
41
|
+
)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def get_team(team_name)
|
48
|
+
data = redis.get(team_name)
|
49
|
+
MultiJson.load(data, symbolize_keys: true) if data
|
50
|
+
end
|
51
|
+
|
52
|
+
def save_team(team)
|
53
|
+
redis.set(team[:name], MultiJson.dump(team))
|
54
|
+
end
|
55
|
+
|
56
|
+
def parse_attribute_value(attribute, raw_value)
|
57
|
+
raw_value.send(ATTRIBUTES_MAPPING[attribute])
|
58
|
+
end
|
59
|
+
|
60
|
+
Lita.register_handler(self)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/lita-team.rb
CHANGED
@@ -5,21 +5,17 @@ Lita.load_locales Dir[File.expand_path(
|
|
5
5
|
)]
|
6
6
|
|
7
7
|
require "lita/handlers/team"
|
8
|
-
require "lita/
|
9
|
-
require "lita/
|
10
|
-
require "lita/
|
11
|
-
require "lita/
|
12
|
-
require "lita/
|
13
|
-
require "lita/
|
14
|
-
require "lita/
|
15
|
-
require "lita/
|
16
|
-
require "lita/
|
17
|
-
require "lita/
|
18
|
-
require "lita/team"
|
19
|
-
require "lita/member"
|
8
|
+
require "lita/handlers/create_team"
|
9
|
+
require "lita/handlers/delete_team"
|
10
|
+
require "lita/handlers/block_team"
|
11
|
+
require "lita/handlers/list_teams"
|
12
|
+
require "lita/handlers/clear_team"
|
13
|
+
require "lita/handlers/add_member_to_team"
|
14
|
+
require "lita/handlers/remove_member_from_team"
|
15
|
+
require "lita/handlers/confirm_member"
|
16
|
+
require "lita/handlers/list_team"
|
17
|
+
require "lita/handlers/update_team"
|
20
18
|
|
21
|
-
template_root
|
22
|
-
File.join("..", "..", "templates"), __FILE__
|
19
|
+
Lita::Handlers::Team.template_root(
|
20
|
+
File.expand_path(File.join("..", "..", "templates"), __FILE__)
|
23
21
|
)
|
24
|
-
Lita::Actions::Base.template_root template_root
|
25
|
-
Lita::Handlers::Team.template_root template_root
|
data/lita-team.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-team"
|
3
|
-
spec.version = "
|
3
|
+
spec.version = "2.0.0"
|
4
4
|
spec.authors = ["Edgar Ortega"]
|
5
5
|
spec.email = ["edgarortegaramirez@gmail.com"]
|
6
6
|
spec.description = "create and manage the members of a team with Lita"
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
|
17
17
|
spec.required_ruby_version = '~> 2.0'
|
18
18
|
|
19
|
-
spec.add_runtime_dependency "lita", ">= 4.
|
19
|
+
spec.add_runtime_dependency "lita", ">= 4.7"
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "pry-byebug"
|
data/locales/en.yml
CHANGED
@@ -2,21 +2,27 @@ en:
|
|
2
2
|
lita:
|
3
3
|
handlers:
|
4
4
|
team:
|
5
|
-
|
5
|
+
created: "%{team_name} team created, add some people to it"
|
6
|
+
updated: "%{team_name} team %{attribute} set to %{value}"
|
7
|
+
cannot_perform_operation: "%{team_name} team is blocked. You cannot perform this operation"
|
8
|
+
already_exists: "%{team_name} team already exists"
|
9
|
+
not_found: "%{team_name} team does not exist"
|
10
|
+
deleted: "%{team_name} team deleted"
|
6
11
|
no_teams_has_been_created: "No team has been created so far"
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
members_in_team:
|
12
|
+
teams_title: "Teams"
|
13
|
+
blocked: "%{team_name} team blocked"
|
14
|
+
unblocked: "%{team_name} team unblocked"
|
15
|
+
cleared: "%{team_name} team cleared"
|
16
|
+
empty: "There is no one in the %{team_name} team currently"
|
17
|
+
members_count:
|
14
18
|
one: ", 1 other is in"
|
15
19
|
other: ", %{count} others are in"
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
unconfirmed_count:
|
21
|
+
one: ", %{count} member has not confirmed yet"
|
22
|
+
other: ", %{count} members have not confirmed yet"
|
23
|
+
member:
|
24
|
+
confirmed: "%{member_name} has been confirmed in the %{team_name} team"
|
25
|
+
already_in_team: "%{member_name} already in the %{team_name} team"
|
26
|
+
not_in_team: "%{member_name} is not on the %{team_name} team"
|
27
|
+
added: "%{member_name} added to the %{team_name} team"
|
28
|
+
removed: "%{member_name} removed from the %{team_name} team"
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::AddMemberToTeam,
|
4
|
+
lita_handler: true,
|
5
|
+
additional_lita_handlers: [Lita::Handlers::CreateTeam,
|
6
|
+
Lita::Handlers::BlockTeam] do
|
7
|
+
describe "add member to team" do
|
8
|
+
it "adds a member to the team" do
|
9
|
+
send_command "create testing team"
|
10
|
+
send_command "testing team add mel"
|
11
|
+
expect(replies.last).to eq("mel added to the testing team")
|
12
|
+
end
|
13
|
+
|
14
|
+
context "me" do
|
15
|
+
it "adds current user to the team" do
|
16
|
+
send_command "create testing team"
|
17
|
+
send_command "testing team add me"
|
18
|
+
expect(replies.last).to eq("#{user.name} added to the testing team")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "+1" do
|
23
|
+
it "adds current user to the team" do
|
24
|
+
send_command "create testing team"
|
25
|
+
send_command "testing team +1"
|
26
|
+
expect(replies.last).to eq("#{user.name} added to the testing team")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "mention" do
|
31
|
+
it "uses the lita users database" do
|
32
|
+
send_command "create testing team"
|
33
|
+
send_command "testing team add @Test"
|
34
|
+
expect(replies.last).to eq("Test User added to the testing team")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "removes @ from non-existing users" do
|
38
|
+
send_command "create testing team"
|
39
|
+
send_command "testing team add @james"
|
40
|
+
expect(replies.last).to eq("james added to the testing team")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "there is a member in the team" do
|
45
|
+
it "adds the member and shows a message" do
|
46
|
+
send_command "create testing team"
|
47
|
+
send_command "testing team add john"
|
48
|
+
send_command "testing team add james"
|
49
|
+
expect(replies.last).
|
50
|
+
to eq("james added to the testing team, 1 other is in")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "there are two or more members in the team" do
|
55
|
+
it "adds the member and shows a message" do
|
56
|
+
send_command "create testing team"
|
57
|
+
send_command "testing team add john"
|
58
|
+
send_command "testing team add james"
|
59
|
+
send_command "testing team add robert"
|
60
|
+
expect(replies.last).
|
61
|
+
to eq("robert added to the testing team, 2 others are in")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "the member is already in the team" do
|
66
|
+
it "does not add the member to the team" do
|
67
|
+
send_command "create testing team"
|
68
|
+
send_command "testing team add john"
|
69
|
+
send_command "testing team add john"
|
70
|
+
expect(replies.last).to eq("john already in the testing team")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "team does not exist" do
|
75
|
+
it "does not add the member" do
|
76
|
+
send_command "testing team add john"
|
77
|
+
expect(replies.last).to eq("testing team does not exist")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "team blocked" do
|
82
|
+
it "does not add the member" do
|
83
|
+
send_command "create testing team"
|
84
|
+
send_command "block testing team"
|
85
|
+
send_command "testing team add john"
|
86
|
+
reply =
|
87
|
+
"testing team is blocked. You cannot perform this operation"
|
88
|
+
expect(replies.last).to eq(reply)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::BlockTeam,
|
4
|
+
lita_handler: true,
|
5
|
+
additional_lita_handlers: Lita::Handlers::CreateTeam do
|
6
|
+
describe "block team" do
|
7
|
+
it "blocks a team" do
|
8
|
+
send_command "create testing team"
|
9
|
+
send_command "block testing team"
|
10
|
+
expect(replies.last).to eq("testing team blocked")
|
11
|
+
end
|
12
|
+
|
13
|
+
context "team already exists" do
|
14
|
+
it "does not block any team" do
|
15
|
+
send_command "block testing team"
|
16
|
+
expect(replies.last).to eq("testing team does not exist")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "unblock team" do
|
22
|
+
it "unblocks a team" do
|
23
|
+
send_command "create testing team"
|
24
|
+
send_command "block testing team"
|
25
|
+
send_command "unblock testing team"
|
26
|
+
expect(replies.last).to eq("testing team unblocked")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::ClearTeam,
|
4
|
+
lita_handler: true,
|
5
|
+
additional_lita_handlers: Lita::Handlers::CreateTeam do
|
6
|
+
describe "clear team" do
|
7
|
+
it "removes the members of a team" do
|
8
|
+
send_command "create testing team"
|
9
|
+
send_command "testing team add john"
|
10
|
+
send_command "testing team clear"
|
11
|
+
expect(replies.last).to eq("testing team cleared")
|
12
|
+
end
|
13
|
+
|
14
|
+
context "team does not exist" do
|
15
|
+
it "shows a message" do
|
16
|
+
send_command "testing team clear"
|
17
|
+
expect(replies.last).to eq("testing team does not exist")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::ConfirmMember,
|
4
|
+
lita_handler: true,
|
5
|
+
additional_lita_handlers: [Lita::Handlers::CreateTeam,
|
6
|
+
Lita::Handlers::AddMemberToTeam] do
|
7
|
+
describe "confirm member attendance" do
|
8
|
+
it "confirm member to the team" do
|
9
|
+
send_command "create testing team"
|
10
|
+
send_command "testing team add mel"
|
11
|
+
send_command "testing team confirm mel"
|
12
|
+
expect(replies.last).
|
13
|
+
to eq("mel has been confirmed in the testing team")
|
14
|
+
end
|
15
|
+
|
16
|
+
context "me" do
|
17
|
+
it "confirm current user to the team" do
|
18
|
+
send_command "create testing team"
|
19
|
+
send_command "testing team add me"
|
20
|
+
send_command "testing team confirm me"
|
21
|
+
expect(replies.last).
|
22
|
+
to eq("#{user.name} has been confirmed in the testing team")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "mention" do
|
27
|
+
it "uses the lita users database" do
|
28
|
+
send_command "create testing team"
|
29
|
+
send_command "testing team add @Test"
|
30
|
+
send_command "testing team confirm @Test"
|
31
|
+
expect(replies.last).
|
32
|
+
to eq("Test User has been confirmed in the testing team")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "removes @ from non-existing users" do
|
36
|
+
send_command "create testing team"
|
37
|
+
send_command "testing team add @james"
|
38
|
+
send_command "testing team confirm @james"
|
39
|
+
expect(replies.last).
|
40
|
+
to eq("james has been confirmed in the testing team")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "there is a member in the team" do
|
45
|
+
it "confirmed the member and displays a message" do
|
46
|
+
send_command "create testing team"
|
47
|
+
send_command "testing team add john"
|
48
|
+
send_command "testing team add james"
|
49
|
+
send_command "testing team confirm james"
|
50
|
+
expect(replies.last).
|
51
|
+
to match("1 member has not confirmed yet")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "there are two or more members in the team" do
|
56
|
+
it "confirmed the member and displays a message" do
|
57
|
+
send_command "create testing team"
|
58
|
+
send_command "testing team add john"
|
59
|
+
send_command "testing team add mel"
|
60
|
+
send_command "testing team add james"
|
61
|
+
send_command "testing team confirm james"
|
62
|
+
expect(replies.last).
|
63
|
+
to match("2 members have not confirmed yet")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "team does not exist" do
|
68
|
+
it "does not confirm the member" do
|
69
|
+
send_command "testing team confirm john"
|
70
|
+
expect(replies.last).to eq("testing team does not exist")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "member not in team" do
|
75
|
+
it "does not confirm the member" do
|
76
|
+
send_command "create testing team"
|
77
|
+
send_command "testing team confirm john"
|
78
|
+
expect(replies.last).to eq("john is not on the testing team")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::CreateTeam, lita_handler: true do
|
4
|
+
describe "create team" do
|
5
|
+
it "creates a new team" do
|
6
|
+
send_command "create testing team"
|
7
|
+
expect(replies.last).to eq("testing team created, add some people to it")
|
8
|
+
end
|
9
|
+
|
10
|
+
context "team already exists" do
|
11
|
+
it "does not create a new team" do
|
12
|
+
send_command "create testing team"
|
13
|
+
send_command "create testing team"
|
14
|
+
expect(replies.last).to eq("testing team already exists")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::DeleteTeam,
|
4
|
+
lita_handler: true,
|
5
|
+
additional_lita_handlers: Lita::Handlers::CreateTeam do
|
6
|
+
describe "delete team" do
|
7
|
+
it "deletes a team" do
|
8
|
+
send_command "create testing team"
|
9
|
+
send_command "delete testing team"
|
10
|
+
expect(replies.last).to eq("testing team deleted")
|
11
|
+
end
|
12
|
+
|
13
|
+
context "team does not exist" do
|
14
|
+
it "does not delete a team" do
|
15
|
+
send_command "delete testing team"
|
16
|
+
expect(replies.last).to eq("testing team does not exist")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::ListTeam,
|
4
|
+
lita_handler: true,
|
5
|
+
additional_lita_handlers: [Lita::Handlers::CreateTeam,
|
6
|
+
Lita::Handlers::AddMemberToTeam,
|
7
|
+
Lita::Handlers::ConfirmMember,
|
8
|
+
Lita::Handlers::UpdateTeam] do
|
9
|
+
describe "list team" do
|
10
|
+
it "lists the members in the team" do
|
11
|
+
send_command "create testing team"
|
12
|
+
send_command "testing team add james"
|
13
|
+
send_command "testing team add john"
|
14
|
+
send_command "testing team list"
|
15
|
+
expect(replies.last).
|
16
|
+
to eq("testing\n:bust_in_silhouette: 2\n1. james\n2. john\n")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "list team summary" do
|
20
|
+
send_command "create testing team"
|
21
|
+
send_command "testing team add melissa"
|
22
|
+
send_command "update testing team set limit 10"
|
23
|
+
send_command "update testing team set icon :love:"
|
24
|
+
send_command "update testing team set location best place"
|
25
|
+
send_command "testing team list"
|
26
|
+
reply = <<-OUTPUT
|
27
|
+
testing
|
28
|
+
:bust_in_silhouette: 1 | :love: best place | Max: 10
|
29
|
+
1. melissa
|
30
|
+
OUTPUT
|
31
|
+
expect(replies.last).to eq(reply)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "lists the members with confirmed tag in the team" do
|
35
|
+
send_command "create testing team"
|
36
|
+
send_command "testing team add james"
|
37
|
+
send_command "testing team add john"
|
38
|
+
send_command "testing team confirm john"
|
39
|
+
send_command "testing team list"
|
40
|
+
reply = <<-OUTPUT
|
41
|
+
testing
|
42
|
+
:bust_in_silhouette: 2
|
43
|
+
1. james
|
44
|
+
2. john :point_up:
|
45
|
+
OUTPUT
|
46
|
+
expect(replies.last).to eq(reply)
|
47
|
+
end
|
48
|
+
|
49
|
+
context "team is empty" do
|
50
|
+
it "shows a message" do
|
51
|
+
send_command "create testing team"
|
52
|
+
send_command "testing team list"
|
53
|
+
expect(replies.last).
|
54
|
+
to eq("There is no one in the testing team currently")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "team does not exist" do
|
59
|
+
it "shows a message" do
|
60
|
+
send_command "testing team list"
|
61
|
+
expect(replies.last).to eq("testing team does not exist")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::ListTeams,
|
4
|
+
lita_handler: true,
|
5
|
+
additional_lita_handlers: Lita::Handlers::CreateTeam do
|
6
|
+
describe "list teams" do
|
7
|
+
it "list all teams" do
|
8
|
+
send_command "create testing team"
|
9
|
+
send_command "create qa team"
|
10
|
+
send_command "list teams"
|
11
|
+
reply = <<-OUTPUT
|
12
|
+
Teams:
|
13
|
+
qa (0 :bust_in_silhouette:)
|
14
|
+
testing (0 :bust_in_silhouette:)
|
15
|
+
OUTPUT
|
16
|
+
expect(replies.last).to eq(reply)
|
17
|
+
end
|
18
|
+
|
19
|
+
context "without teams" do
|
20
|
+
it "shows a message" do
|
21
|
+
send_command "list teams"
|
22
|
+
expect(replies.last).to eq("No team has been created so far")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|