From 48d6c2aac9ae2bf1c140e734a576e45289c99150 Mon Sep 17 00:00:00 2001
From: jessib <jessib@riseup.net>
Date: Tue, 16 Oct 2012 15:51:35 -0700
Subject: Some functional tests and other tweaks.

---
 help/app/models/ticket.rb         | 12 ++++++++----
 help/app/models/ticket_comment.rb |  4 ++--
 2 files changed, 10 insertions(+), 6 deletions(-)

(limited to 'help/app/models')

diff --git a/help/app/models/ticket.rb b/help/app/models/ticket.rb
index 537a7c6..76fa5c8 100644
--- a/help/app/models/ticket.rb
+++ b/help/app/models/ticket.rb
@@ -15,8 +15,8 @@ class Ticket < CouchRest::Model::Base
 =end
 
   #belongs_to :user #from leap_web_users. doesn't necessarily belong to a user though
-  property :created_by, String#Integer #nil unless user was authenticated for ticket creation, #THIS should not be changed after being set
-  property :regarding_user, String#Integer # form cannot be submitted if they type in a username w/out corresponding ID. this field can be nil. for authenticated ticket creation by non-admins, should this just automatically be set to be same as created_by?  or maybe we don't use this field unless created_by is nil?
+  property :created_by, String, :protected => true #Integer #nil unless user was authenticated for ticket creation, #THIS should not be changed after being set
+  #property :regarding_user, String#Integer # form cannot be submitted if they type in a username w/out corresponding ID. this field can be nil. for authenticated ticket creation by non-admins, should this just automatically be set to be same as created_by?  or maybe we don't use this field unless created_by is nil?
   #also, both created_by and regarding_user could be nil---say user forgets username, or has general question
   property :title, String
   property :email, String #verify
@@ -32,6 +32,9 @@ class Ticket < CouchRest::Model::Base
   #before_validation :set_created_by, :set_code, :set_email, :on => :create
   before_validation :set_code, :set_email, :on => :create
 
+
+  #named_scope :open, :conditions => {:is_open => true} #??
+
   design do
     view :by_title
   end
@@ -60,7 +63,7 @@ class Ticket < CouchRest::Model::Base
 
   def set_email
     self.email = nil if self.email == ""
-    #self.email = current users email if is_creator_validated?
+    # in controller set to be current users email if that exists
   end
 
   def close
@@ -74,8 +77,9 @@ class Ticket < CouchRest::Model::Base
   end
 
   def comments_attributes=(attributes)
+
     comment = TicketComment.new(attributes.values.first) #TicketComment.new(attributes)
-    comment.posted_by = User.current_test.id if User.current_test
+    comment.posted_by = User.current_test.id if User.current_test #should we not access User.current here?
     comment.posted_at = Time.now
     comments << comment
     
diff --git a/help/app/models/ticket_comment.rb b/help/app/models/ticket_comment.rb
index 9026bc1..a8639a1 100644
--- a/help/app/models/ticket_comment.rb
+++ b/help/app/models/ticket_comment.rb
@@ -2,13 +2,13 @@ class TicketComment
   include CouchRest::Model::Embeddable 
 
   #belongs_to :ticket #is this best way to do it? will want to access all of a tickets comments, so maybe this isn't the way?
-  property :posted_by, Integer#, :protected => true# maybe this should be current_user if that is set, meaning the user is logged in  #String # user??
+  property :posted_by, String#, :protected => true #Integer#this should be current_user if that is set, meaning the user is logged in  #cannot have it be protected and set via comments_attributes=
   # if the current user is not set, then we could just say the comment comes from an 'unauthenticated user', which would be somebody with the secret URL
   property :posted_at, Time#, :protected => true
   #property :posted_verified, TrueClass, :protected => true #should be true if current_user is set when the comment is created
   property :body, String
 
-
+  # ? timestamps!
   validates :body, :presence => true
   #before_validation :set_time#, :set_posted_by
 
-- 
cgit v1.2.3