Permalink
Browse files

When reloading the tickets, also remove the ones that are no longer a…

…vailable from the users.
  • Loading branch information...
1 parent 29cd120 commit c0b81f8e04e0dd6a950a40cedffe3ff1305e54c1 @alloy alloy committed Dec 3, 2010
Showing with 7,440 additions and 7 deletions.
  1. +15 −6 lib/macruby_bugmash_bot/trac.rb
  2. +7,391 −0 spec/fixtures/trac_active_tickets_rss-minus-19-and-81.xml
  3. +34 −1 spec/trac_spec.rb
@@ -22,6 +22,10 @@ def load_tickets!
h[id] = { :id => id, :link => entry[:link], :summary => CGI.unescapeHTML(entry[:title]) }
h
end
+ # clean assigned/marked tickets
+ @users.each do |name, tickets|
+ tickets.reject! { |t| @active_tickets[t[:id]].nil? }
+ end
end
def ticket(id)
@@ -34,7 +38,7 @@ def ticket_message(id)
end
def user(name)
- if tickets = @users[name]
+ if (tickets = @users[name]) && !tickets.empty?
tickets.map { |t| ticket_message(t[:id]) }
else
["You don't have any tickets assigned."]
@@ -43,7 +47,9 @@ def user(name)
def marked_for_review
result = []
- @active_tickets.each { |id, t| result << id if t[:marked_for_review] }
+ @users.each do |_, tickets|
+ tickets.each { |t| result << t[:id] if t[:marked_for_review] }
+ end
if result.empty?
["There are currently no open tickets marked for review."]
else
@@ -100,11 +106,14 @@ def resign_from_ticket(id, user)
end
def ticket_status(id)
- t = ticket(id)
- if user = t[:assigned_to]
- "Ticket ##{id} is assigned to `#{user}'#{ ' and marked for review' if t[:marked_for_review] }."
+ if t = ticket(id)
+ if user = t[:assigned_to]
+ "Ticket ##{id} is assigned to `#{user}'#{ ' and marked for review' if t[:marked_for_review] }."
+ else
+ "Ticket ##{id} is unassigned."
+ end
else
- "Ticket ##{id} is unassigned."
+ "Ticket ##{id} is not an open ticket (anymore)."
end
end
Oops, something went wrong.

0 comments on commit c0b81f8

Please sign in to comment.