Skip to content

Commit

Permalink
implemented .discard
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Aug 25, 2009
1 parent 744fb10 commit 663de25
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/ruote/dm/ticket.rb
Expand Up @@ -48,6 +48,11 @@ def self.draw (holder, target)

ticket.save ? ticket : nil
end

def self.discard (target)

Ticket.all(:target => target).destroy!
end
end
end
end
Expand Down
17 changes: 17 additions & 0 deletions test/ut_2_ticket.rb
Expand Up @@ -43,6 +43,23 @@ def test_two_tickets
assert_equal true, l1.consumable?
end

def test_discard

Ruote::Dm::Ticket.draw('a', 't0')
Ruote::Dm::Ticket.draw('b', 't0')
Ruote::Dm::Ticket.draw('b', 't1')

assert_equal 3, Ruote::Dm::Ticket.all.size

Ruote::Dm::Ticket.discard('t1')

assert_equal 2, Ruote::Dm::Ticket.all.size

Ruote::Dm::Ticket.discard('t0')

assert_equal 0, Ruote::Dm::Ticket.all.size
end

def test_same_same

Ruote::Dm::Ticket.draw('ticketer1', 'target')
Expand Down

0 comments on commit 663de25

Please sign in to comment.