From a4fd38b7cce5fbc5ccdab670f31ab5f74c2bdf03 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 27 Nov 2012 15:01:37 +0100 Subject: testing Ticket#by_commented_by --- help/test/unit/ticket_test.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'help/test') diff --git a/help/test/unit/ticket_test.rb b/help/test/unit/ticket_test.rb index 73a2af5..8d6d197 100644 --- a/help/test/unit/ticket_test.rb +++ b/help/test/unit/ticket_test.rb @@ -63,7 +63,22 @@ class TicketTest < ActiveSupport::TestCase assert_equal Ticket.by_is_open.key(true).count, tickets.count end + test "find tickets user commented on" do + # clear old tickets just in case + Ticket.by_commented_by.key('123').each {|t| t.destroy} -end + testticket = Ticket.create :title => "test retrieving commented tickets" + comment = TicketComment.new :body => "my email broke", :posted_by => "123" + assert_equal 0, testticket.comments.count + assert_equal [], Ticket.by_commented_by.key('123').all; + + testticket.comments << comment + testticket.save + assert_equal 1, testticket.reload.comments.count + assert_equal [testticket], Ticket.by_commented_by.key('123').all; + testticket.destroy + assert_equal [], Ticket.by_commented_by.key('123').all; + end +end -- cgit v1.2.3