Skip to content
Browse files

Before listing assigned/marked tickets, give a summary.

  • Loading branch information...
1 parent 4b00c0d commit ba41b5ea09d154e3aa4719c022ef78dcd27cb4d3 @alloy alloy committed Dec 3, 2010
Showing with 22 additions and 5 deletions.
  1. +1 −0 lib/macruby_bugmash_bot.rb
  2. +18 −2 lib/macruby_bugmash_bot/trac.rb
  3. +3 −3 spec/trac_spec.rb
View
1 lib/macruby_bugmash_bot.rb
@@ -1,4 +1,5 @@
# encoding: UTF-8
+
$:.unshift File.expand_path("../../vendor/cinch/lib", __FILE__)
require "cinch"
require "macruby_bugmash_bot/trac"
View
20 lib/macruby_bugmash_bot/trac.rb
@@ -1,3 +1,5 @@
+# encoding: UTF-8
+
$:.unshift File.expand_path("../../../vendor/simple-rss/lib", __FILE__)
require "simple-rss"
require "net/http"
@@ -66,7 +68,9 @@ def ticket_message(id)
def user(name)
if (tickets = @users[name]) && !tickets.empty?
- tickets.map { |t| ticket_message(t[:id]) }
+ result = tickets.map { |t| ticket_message(t[:id]) }
+ result.unshift("You are currently working on #{pluralize(result.size, 'ticket')}:")
+ result
else
["You don't have any tickets assigned."]
end
@@ -80,7 +84,9 @@ def marked_for_review
if result.empty?
["There are currently no open tickets marked for review."]
else
- result.sort.map { |id| ticket_message(id) }
+ result = result.sort.map { |id| ticket_message(id) }
+ result.unshift("There #{result.size == 1 ? 'is' : 'are'} currently #{pluralize(result.size, 'ticket')} marked for review:")
+ result
end
end
@@ -163,4 +169,14 @@ def open_ticket
"Ticket ##{id} isn't marked for review."
end
end
+
+ private
+
+ def pluralize(count, string)
+ if count == 1
+ "#{count} #{string}"
+ else
+ "#{count} #{string}s"
+ end
+ end
end
View
6 spec/trac_spec.rb
@@ -133,7 +133,7 @@ def self.raw_active_tickets_feed
@trac.mark_for_review(47, "lrz")
@trac.assign_ticket(19, "alloy")
@trac.mark_for_review(19, "alloy")
- @trac.marked_for_review.should == ["There are currently 3 tickets that are marked for review:", "#19: Problems with method_missing (http://www.macruby.org/trac/ticket/19)", "#47: Cannot pass a :symbol directly as a named parameter (http://www.macruby.org/trac/ticket/47)", "#81: Enumerable::Enumerator seems to be broken (http://www.macruby.org/trac/ticket/81)"]
+ @trac.marked_for_review.should == ["There are currently 3 tickets marked for review:", "#19: Problems with method_missing (http://www.macruby.org/trac/ticket/19)", "#47: Cannot pass a :symbol directly as a named parameter (http://www.macruby.org/trac/ticket/47)", "#81: Enumerable::Enumerator seems to be broken (http://www.macruby.org/trac/ticket/81)"]
end
it "returns a good message when a ticket is not open (anymore)" do
@@ -165,10 +165,10 @@ def self.raw_active_tickets_feed
it "no longer lists assigned tickets if they're not in the active-tickets feed anymore" do
@trac.user("alloy").should == ["You don't have any tickets assigned."]
- @trac.user("lrz").should == ["#47: Cannot pass a :symbol directly as a named parameter (http://www.macruby.org/trac/ticket/47)"]
+ @trac.user("lrz").should == ["You are currently working on 1 ticket:", "#47: Cannot pass a :symbol directly as a named parameter (http://www.macruby.org/trac/ticket/47)"]
end
it "no longer lists tickets to be reviewed if they're not in the active-tickets feed anymore" do
- @trac.marked_for_review.should == ["#47: Cannot pass a :symbol directly as a named parameter (http://www.macruby.org/trac/ticket/47)"]
+ @trac.marked_for_review.should == ["There is currently 1 ticket marked for review:", "#47: Cannot pass a :symbol directly as a named parameter (http://www.macruby.org/trac/ticket/47)"]
end
end

0 comments on commit ba41b5e

Please sign in to comment.
Something went wrong with that request. Please try again.