summaryrefslogtreecommitdiff
path: root/help
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-11-27 13:01:57 +0100
committerAzul <azul@leap.se>2012-11-27 13:01:57 +0100
commit15d13d9abb9165b23369ea91d58505ca98d48b31 (patch)
treef3084615547baae0bb485c7f0d602b5e16d59da5 /help
parentebf5dddc39f09bac6640084edbaaefa9c9d48477 (diff)
first attempts to map comments
Diffstat (limited to 'help')
-rw-r--r--help/app/models/ticket.rb16
-rw-r--r--help/test/unit/ticket_test.rb12
2 files changed, 26 insertions, 2 deletions
diff --git a/help/app/models/ticket.rb b/help/app/models/ticket.rb
index bc6ea59..81cd08e 100644
--- a/help/app/models/ticket.rb
+++ b/help/app/models/ticket.rb
@@ -48,6 +48,7 @@ class Ticket < CouchRest::Model::Base
emit(doc._id, doc);
}"
view :by_is_open_and_created_by
+ view :by_is_open_and_created_at
view :by_updated_at_and_is_open,
:map =>
"function(doc) {
@@ -62,6 +63,21 @@ class Ticket < CouchRest::Model::Base
emit(doc.updated_at, doc);
}
}"
+ view :by_commented_by,
+ :map =>
+ "function(doc) {
+ doc.comments.forEach(function(comment){
+ emit(comment.posted_by, doc);
+ });
+ }"
+
+ view :by_commented_by_and_commented_at,
+ :map =>
+ "function(doc) {
+ doc.comments.forEach(function(comment){
+ emit([comment.posted_by, comment.posted_at], doc);
+ });
+ }"
end
diff --git a/help/test/unit/ticket_test.rb b/help/test/unit/ticket_test.rb
index 6b63a23..73a2af5 100644
--- a/help/test/unit/ticket_test.rb
+++ b/help/test/unit/ticket_test.rb
@@ -23,7 +23,7 @@ class TicketTest < ActiveSupport::TestCase
#user = LeapWebUsers::User.create
#t.user = user
-
+
#t.email = '' #invalid
#assert !t.valid?
#t.email = 'blah@blah.com, bb@jjj.org'
@@ -40,7 +40,7 @@ class TicketTest < ActiveSupport::TestCase
@sample.created_by = 22 #current_user
assert @sample.is_creator_validated?
end
-
+
=begin
# TODO: do once have current_user stuff in order
test "code if & only if not creator-validated" do
@@ -56,6 +56,14 @@ 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])
+ assert_equal Ticket.by_is_open.key(true).count, tickets.count
+ end
+
+
end