summaryrefslogtreecommitdiff
path: root/engines/support/test/functional/ticket_comments_test.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-05-20 11:18:28 +0200
committerAzul <azul@leap.se>2014-05-26 12:59:26 +0200
commit29fd85f605ee41275e383681a6b3e8ea0615d525 (patch)
tree2411faf97d0258acbe600ce83615e360a22d26a6 /engines/support/test/functional/ticket_comments_test.rb
parent730e31017109994c24db431fde12f575ed5c1467 (diff)
splitting up long functional test case
Diffstat (limited to 'engines/support/test/functional/ticket_comments_test.rb')
-rw-r--r--engines/support/test/functional/ticket_comments_test.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/engines/support/test/functional/ticket_comments_test.rb b/engines/support/test/functional/ticket_comments_test.rb
index e30a018..5cbe233 100644
--- a/engines/support/test/functional/ticket_comments_test.rb
+++ b/engines/support/test/functional/ticket_comments_test.rb
@@ -39,8 +39,7 @@ class TicketsCommentsTest < ActionController::TestCase
end
- test "cannot comment if it is not your ticket" do
-
+ test "cannot comment if it is another users ticket" do
other_user = find_record :user
login :is_admin? => false, :email => nil
ticket = FactoryGirl.create :ticket, :created_by => other_user.id
@@ -50,10 +49,23 @@ class TicketsCommentsTest < ActionController::TestCase
assert_access_denied
assert_equal ticket.comments.map(&:body), assigns(:ticket).comments.map(&:body)
+ end
+ test "authenticated comment on an anonymous ticket adds to my tickets" do
+ login
+ ticket = FactoryGirl.create :ticket
+ other_ticket = FactoryGirl.create :ticket
+ put :update, :id => ticket.id,
+ :ticket => {:comments_attributes => {"0" => {"body" =>"NEWER comment"}} }
+ assert_not_nil assigns(:ticket).comments.last.posted_by
+ assert_equal assigns(:ticket).comments.last.posted_by, @current_user.id
+ visible_tickets = Ticket.search admin_status: 'mine',
+ user_id: @current_user.id, is_admin: false
+ assert_equal [ticket], visible_tickets.all
end
+
test "admin add comment to authenticated ticket" do
other_user = find_record :user