summaryrefslogtreecommitdiff
path: root/help/test
diff options
context:
space:
mode:
authorjessib <jessib@leap.se>2012-11-29 15:56:41 -0800
committerjessib <jessib@leap.se>2012-11-29 15:56:41 -0800
commit0a49faf417a993e838d1c37361d573bb86223f75 (patch)
tree3e638f0ee2f0c9bd74758845f627b8ac42cc03e7 /help/test
parente78b4e7af81d6350b9064a977e1990d9a6f1408c (diff)
Not yet done, but more sophisticated and refactored ticket filtering. Still have to do more, including allowing user to pick sort order.
Diffstat (limited to 'help/test')
-rw-r--r--help/test/unit/ticket_test.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/help/test/unit/ticket_test.rb b/help/test/unit/ticket_test.rb
index 691597a..e93a121 100644
--- a/help/test/unit/ticket_test.rb
+++ b/help/test/unit/ticket_test.rb
@@ -64,27 +64,30 @@ class TicketTest < ActiveSupport::TestCase
end
test "find tickets user commented on" do
+
# clear old tickets just in case
- Ticket.by_commented_by.key('123').each {|t| t.destroy}
+ # this will cause RestClient::ResourceNotFound errors if there are multiple copies of the same ticket returned
+ Ticket.includes_post_by.key('123').each {|t| t.destroy}
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;
+ assert_equal [], Ticket.includes_post_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;
+ assert_equal [testticket], Ticket.includes_post_by.key('123').all
comment = TicketComment.new :body => "another comment", :posted_by => "123"
testticket.comments << comment
testticket.save
- #this will now fail, as Ticket.by_commented_by will return 2 copies of the same ticket as both of the ticket's comments match
- assert_equal [testticket], Ticket.by_commented_by.key('123').all;
+
+ # this will ensure that the ticket is only included once, even though the user has commented on the ticket twice:
+ assert_equal [testticket], Ticket.includes_post_by.key('123').all
testticket.destroy
- assert_equal [], Ticket.by_commented_by.key('123').all;
+ assert_equal [], Ticket.includes_post_by.key('123').all;
end
end