From 66ce152d5124be52f31d51fc4171fd53ba3a915c Mon Sep 17 00:00:00 2001 From: jessib Date: Tue, 18 Dec 2012 13:45:49 -0800 Subject: Refactoring of code to filter/order tickets. --- help/test/unit/ticket_test.rb | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'help/test/unit') diff --git a/help/test/unit/ticket_test.rb b/help/test/unit/ticket_test.rb index e93a121..ac6426e 100644 --- a/help/test/unit/ticket_test.rb +++ b/help/test/unit/ticket_test.rb @@ -56,38 +56,34 @@ class TicketTest < ActiveSupport::TestCase end =end - test "finds open tickets sorted by created_at" do - tickets = Ticket.by_is_open_and_created_at. - startkey([true, 0]). - endkey([true, Time.now + 10.hours]) # some tickets were created in the future - 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 # 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} + Ticket.by_includes_post_by.key('123').each {|t| t.destroy} + # TODO: the by_includes_post_by view is only used for tests. Maybe we should get rid of it and change the test to including ordering? + 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.includes_post_by.key('123').all + assert_equal [], Ticket.by_includes_post_by.key('123').all testticket.comments << comment testticket.save assert_equal 1, testticket.reload.comments.count - assert_equal [testticket], Ticket.includes_post_by.key('123').all + assert_equal [testticket], Ticket.by_includes_post_by.key('123').all comment = TicketComment.new :body => "another comment", :posted_by => "123" testticket.comments << comment testticket.save # 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 + assert_equal [testticket], Ticket.by_includes_post_by.key('123').all testticket.destroy - assert_equal [], Ticket.includes_post_by.key('123').all; + assert_equal [], Ticket.by_includes_post_by.key('123').all; end end -- cgit v1.2.3