Permalink
Browse files

Make sure tickets assigned to a user are sorted by ID.

  • Loading branch information...
1 parent 06e586e commit 0a5a742bc5476c585aac92aba75735c4e412c820 @alloy alloy committed Dec 3, 2010
Showing with 15 additions and 0 deletions.
  1. +5 −0 lib/macruby_bugmash_bot/trac.rb
  2. +10 −0 spec/trac_spec.rb
@@ -28,6 +28,10 @@ def ticket(id)
@active_tickets[id]
end
+ def user(name)
+ @users[name]
+ end
+
# Returns a ticket that nobody is working on yet, in ascending order.
def open_ticket
@active_tickets.keys.sort.each do |id|
@@ -41,6 +45,7 @@ def assign_ticket(id, user)
t = ticket(id)
t[:assigned_to] = user
@users[user] << t
+ @users[user] = @users[user].sort_by { |x| x[:id] }
end
def resign_from_ticket(id, user)
View
@@ -100,4 +100,14 @@ def self.raw_active_tickets_feed
@trac.unmark_for_review(19, "lrz").should == "Ticket #19 is un-marked for review by `lrz'."
@trac.ticket(19)[:marked_for_review].should == nil
end
+
+ it "returns a list of tickets the user is working on, sorted by ID" do
+ @trac.user("lrz").should == nil
+ @trac.user("alloy").should == nil
+ @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)]
+ end
end

0 comments on commit 0a5a742

Please sign in to comment.