summaryrefslogtreecommitdiff
path: root/help/test
diff options
context:
space:
mode:
Diffstat (limited to 'help/test')
-rw-r--r--help/test/test_helper.rb2
-rw-r--r--help/test/unit/ticket_comment_test.rb19
-rw-r--r--help/test/unit/ticket_test.rb8
3 files changed, 23 insertions, 6 deletions
diff --git a/help/test/test_helper.rb b/help/test/test_helper.rb
index 1e26a31..3381f44 100644
--- a/help/test/test_helper.rb
+++ b/help/test/test_helper.rb
@@ -1,7 +1,7 @@
# Configure Rails Environment
ENV["RAILS_ENV"] = "test"
-require File.expand_path("../dummy/config/environment.rb", __FILE__)
+require File.expand_path('../../../test/dummy/config/environment', __FILE__)
require "rails/test_help"
Rails.backtrace_cleaner.remove_silencers!
diff --git a/help/test/unit/ticket_comment_test.rb b/help/test/unit/ticket_comment_test.rb
index 37e6e67..883720f 100644
--- a/help/test/unit/ticket_comment_test.rb
+++ b/help/test/unit/ticket_comment_test.rb
@@ -25,21 +25,32 @@ class TicketCommentTest < ActiveSupport::TestCase
#tc.ticket = Ticket.find_by_title("test title")
#tc.ticket.title
end
+
+=begin
+ test "create authenticated comment" do
+ User.current = 4
+ comment2 = TicketComment.new :body => "help my email is broken!"
+ comment2.valid? #save # should not save comment
+ assert_not_nil comment2.posted_by
+ end
+=end
test "add comments" do
testticket = Ticket.create :title => "testing"
assert_equal testticket.comments.count, 0
comment = TicketComment.new :body => "my email broke"
- assert comment.valid? #validating or saving necessary for setting posted_at
- assert_not_nil comment.posted_at
+ #assert comment.valid? #validating or saving necessary for setting posted_at
+ #assert_not_nil comment.posted_at
testticket.comments << comment
assert_equal testticket.comments.count, 1
sleep(1) # so first comment has earlier posted_at time
comment2 = TicketComment.new :body => "my email broke"
- comment2.save #possible to save only if ticketcomment is a model now
- testticket.comments << comment2
+ testticket.comments << comment2 #this should validate comment2
+ testticket.valid?
assert_equal testticket.comments.count, 2
+ assert_not_nil comment.posted_at
+ assert_not_nil testticket.comments.last.posted_at
assert testticket.comments.first.posted_at < testticket.comments.last.posted_at
end
diff --git a/help/test/unit/ticket_test.rb b/help/test/unit/ticket_test.rb
index fddd719..c3a4759 100644
--- a/help/test/unit/ticket_test.rb
+++ b/help/test/unit/ticket_test.rb
@@ -14,6 +14,11 @@ class TicketTest < ActiveSupport::TestCase
assert t.valid?
assert_equal t.title, 'test title'
+ assert t.is_open
+ t.close
+ assert !t.is_open
+ t.reopen
+ assert t.is_open
#user = LeapWebHelp::User.new(User.valid_attributes_hash)
#user = LeapWebUsers::User.create
@@ -41,7 +46,8 @@ class TicketTest < ActiveSupport::TestCase
assert_not_nil t1.code
assert_nil t1.created_by
- t2 = Ticket.create :title => 'test title', :created_by => 4
+ User.current = 4
+ t2 = Ticket.create :title => 'test title'
assert_nil t2.code
assert_not_nil t2.created_by