Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use +/-/= instead of smiles. Closes #1 #2

Merged
merged 2 commits into from Dec 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -27,6 +27,8 @@ Sophie: Lita retro :| What are we supposed to do during downtime?
Lita: Neutral topic added!
```

Alternatively you could use `+`, `-`, and `=` instead of smiles.

When it's time for the retro, ask Lita to list all the topics for you.

```
Expand Down
6 changes: 3 additions & 3 deletions lib/lita/handlers/retro.rb
@@ -1,15 +1,15 @@
module Lita
module Handlers
class Retro < Handler
route /retro\s+:\)\s+(.+)/i, :add_good, command: true, help: {
route /retro\s+(?::\)|\+)\s+(.+)/i, :add_good, command: true, help: {
t("help.add_good_key") => t("help.add_good_value")
}

route /retro\s+:\(\s+(.+)/i, :add_bad, command: true, help: {
route /retro\s+(?::\(|\-)\s+(.+)/i, :add_bad, command: true, help: {
t("help.add_bad_key") => t("help.add_bad_value")
}

route /retro\s+:\|\s+(.+)/i, :add_neutral, command: true, help: {
route /retro\s+(?::\||\=)\s+(.+)/i, :add_neutral, command: true, help: {
t("help.add_neutral_key") => t("help.add_neutral_value")
}

Expand Down
2 changes: 1 addition & 1 deletion lita-retro.gemspec
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_runtime_dependency "lita", ">= 3.0"
spec.add_runtime_dependency "lita", ">= 4.0"

spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
Expand Down
6 changes: 3 additions & 3 deletions locales/en.yml
Expand Up @@ -3,11 +3,11 @@ en:
handlers:
retro:
help:
add_good_key: "retro :) TOPIC"
add_good_key: "retro :) TOPIC or retro + TOPIC"
add_good_value: Add a positive topic for the next retrospective.
add_bad_key: "retro :( TOPIC"
add_bad_key: "retro :( TOPIC or retro - TOPIC"
add_bad_value: Add a negative topic for the next retrospective.
add_neutral_key: "retro :| TOPIC"
add_neutral_key: "retro :| TOPIC or retro = TOPIC"
add_neutral_value: Add a neutral topic for the next retrospective.
list_value: List all topics for the next retrospective.
clear_value: Clear the retrospective topics.
Expand Down
30 changes: 21 additions & 9 deletions spec/lita/handlers/retro_spec.rb
Expand Up @@ -3,12 +3,17 @@
describe Lita::Handlers::Retro, lita_handler: true do
let(:bad_user) { Lita::User.create(2, name: "Bad User") }
let(:neutral_user) { Lita::User.create(3, name: "Neutral User") }
let(:retro_admin) do
user = Lita::User.create(3, name: "Retro Admin")
Lita::Authorization.new(registry.config).add_user_to_group!(user, :retro_admins)
user
end

it { routes_command("retro :) topic").to(:add_good) }
it { routes_command("retro :( topic").to(:add_bad) }
it { routes_command("retro :| topic").to(:add_neutral) }
it { routes_command("retro list").to(:list) }
it { routes_command("retro clear").to(:clear) }
it { is_expected.to route_command("retro :) topic").to(:add_good) }
it { is_expected.to route_command("retro :( topic").to(:add_bad) }
it { is_expected.to route_command("retro :| topic").to(:add_neutral) }
it { is_expected.to route_command("retro list").to(:list) }
it { is_expected.to route_command("retro clear").with_authorization_for(:retro_admins).to(:clear) }

it "adds good topics" do
send_command("retro :) foo bar")
Expand Down Expand Up @@ -39,14 +44,21 @@
end

it "clears all topics" do
allow(Lita::Authorization).to receive(:user_in_group?).with(user, :retro_admins).and_return(
true
)
send_command("retro :) something good!")
send_command("retro :( something bad!", as: bad_user)
send_command("retro :| something neutral!", as: neutral_user)
send_command("retro clear")
send_command("retro clear", as: retro_admin)
send_command("retro list")
expect(replies.last).to eq("There are no retrospective topics yet.")
end

it "supports +/-/= syntax" do
send_command("retro + something good!")
send_command("retro - something bad!", as: bad_user)
send_command("retro = something neutral!", as: neutral_user)
send_command("retro list")
expect(replies.last).to include("Good topic from Test User: something good!")
expect(replies.last).to include("Bad topic from Bad User: something bad!")
expect(replies.last).to include("Neutral topic from Neutral User: something neutral!")
end
end
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -8,3 +8,5 @@

require "lita-retro"
require "lita/rspec"

Lita.version_3_compatibility_mode = false