From 5bc3eae400754dda90a45d6953a02a069a1c0285 Mon Sep 17 00:00:00 2001 From: jessib Date: Tue, 2 Oct 2012 15:29:28 -0700 Subject: Some more tweaks to help ticket models. Still want to tweak current_user access from users engine. --- help/test/unit/ticket_comment_test.rb | 7 +++++++ help/test/unit/ticket_test.rb | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'help/test/unit') diff --git a/help/test/unit/ticket_comment_test.rb b/help/test/unit/ticket_comment_test.rb index 37e6e67..ba6120b 100644 --- a/help/test/unit/ticket_comment_test.rb +++ b/help/test/unit/ticket_comment_test.rb @@ -25,6 +25,13 @@ class TicketCommentTest < ActiveSupport::TestCase #tc.ticket = Ticket.find_by_title("test title") #tc.ticket.title end + + test "create authenticated comment" do + User.current = 4 + comment2 = TicketComment.new :body => "help my email is broken!" + comment2.save + assert_not_nil comment2.posted_by + end test "add comments" do testticket = Ticket.create :title => "testing" diff --git a/help/test/unit/ticket_test.rb b/help/test/unit/ticket_test.rb index fddd719..2dbd63c 100644 --- a/help/test/unit/ticket_test.rb +++ b/help/test/unit/ticket_test.rb @@ -41,7 +41,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 -- cgit v1.2.3 From c89610d1aad8500b4f7058c970bb07a60a55a5ce Mon Sep 17 00:00:00 2001 From: jessib Date: Wed, 3 Oct 2012 16:53:00 -0700 Subject: Some model/unit test tweaks --- help/test/unit/ticket_comment_test.rb | 14 +++++++++----- help/test/unit/ticket_test.rb | 5 +++++ 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'help/test/unit') diff --git a/help/test/unit/ticket_comment_test.rb b/help/test/unit/ticket_comment_test.rb index ba6120b..883720f 100644 --- a/help/test/unit/ticket_comment_test.rb +++ b/help/test/unit/ticket_comment_test.rb @@ -26,27 +26,31 @@ class TicketCommentTest < ActiveSupport::TestCase #tc.ticket.title end +=begin test "create authenticated comment" do User.current = 4 comment2 = TicketComment.new :body => "help my email is broken!" - comment2.save + 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 2dbd63c..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 -- cgit v1.2.3