summaryrefslogtreecommitdiff
path: root/help/test
diff options
context:
space:
mode:
authorjessib <jessib@leap.se>2012-12-18 13:45:49 -0800
committerjessib <jessib@leap.se>2012-12-18 13:45:49 -0800
commit66ce152d5124be52f31d51fc4171fd53ba3a915c (patch)
treea1381abbc899be4f5249fe9f3bd5fc71b19e4529 /help/test
parente61cae8d2fc5d5818e56433a45056a539b621bd3 (diff)
Refactoring of code to filter/order tickets.
Diffstat (limited to 'help/test')
-rw-r--r--help/test/unit/ticket_test.rb18
1 files changed, 7 insertions, 11 deletions
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