Permalink
Browse files

Return a list of formatted tickets for a user.

  • Loading branch information...
alloy committed Dec 3, 2010
1 parent 97a497a commit 9bf8ef240a81a4358a839237b674062e69e4ece8
Showing with 19 additions and 7 deletions.
  1. +11 −2 lib/macruby_bugmash_bot/trac.rb
  2. +8 −5 spec/trac_spec.rb
@@ -28,8 +28,17 @@ def ticket(id)
@active_tickets[id]
end
+ def ticket_message(id)
+ t = ticket(id)
+ "#{t[:summary]} (#{t[:link]})"
+ end
+
def user(name)
- @users[name]
+ if tickets = @users[name]
+ tickets.map { |t| ticket_message(t[:id]) }
+ else
+ ["You don't have any tickets assigned."]
+ end
end
# Returns a ticket that nobody is working on yet, in ascending order.
@@ -43,7 +52,7 @@ def open_ticket
end
end
if ot
- "Ticket available #{ot[:summary]} (#{ot[:link]})"
+ "Ticket available #{ticket_message(ot[:id])}"
else
"There are no more open tickets! \o/"
end
View
@@ -59,7 +59,7 @@ def self.raw_active_tickets_feed
@trac.assign_ticket(47, "alloy").should == "Ticket #47 is now assigned to `alloy'."
@trac.ticket(47)[:assigned_to].should == "alloy"
- @trac.user("alloy").should == [@trac.ticket(19), @trac.ticket(47)]
+ @trac.users["alloy"].should == [@trac.ticket(19), @trac.ticket(47)]
@trac.assign_ticket(19, "lrz").should == "Ticket #19 can't be assigned to `lrz', as it is already assigned to `alloy'."
@trac.assign_ticket(19, "alloy").should == "Ticket #19 is already assigned to `alloy'."
@@ -111,12 +111,15 @@ def self.raw_active_tickets_feed
end
it "returns a list of messages about tickets the user is working on, sorted by ID" do
- @trac.user("lrz").should == nil
- @trac.user("alloy").should == nil
+ @trac.user("lrz").should == ["You don't have any tickets assigned."]
+ @trac.user("alloy").should == ["You don't have any tickets assigned."]
@trac.assign_ticket(81, "alloy")
@trac.assign_ticket(47, "lrz")
@trac.assign_ticket(19, "alloy")
- @trac.user("lrz").should == [@trac.ticket(47)]
- @trac.user("alloy").should == [@trac.ticket(19), @trac.ticket(81)]
+ @trac.user("lrz").should == ["#47: Cannot pass a :symbol directly as a named parameter (http://www.macruby.org/trac/ticket/47)"]
+ @trac.user("alloy").should == ["#19: Problems with method_missing (http://www.macruby.org/trac/ticket/19)", "#81: Enumerable::Enumerator seems to be broken (http://www.macruby.org/trac/ticket/81)"]
+ end
+
+ it "returns a list of tickets that are marked for review" do
end
end

0 comments on commit 9bf8ef2

Please sign in to comment.