summaryrefslogtreecommitdiff
path: root/help/test
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2012-10-18 13:42:37 -0700
committerjessib <jessib@riseup.net>2012-10-18 13:42:37 -0700
commit8b9d5235faed6c15e8ef2e2dc76aec7f24d0bb50 (patch)
treede26dada544adf1158548ef437892759504323d0 /help/test
parente927ad44c1f3e7e31cd393ce92a78267e4761660 (diff)
Uses the working authentication code.
Diffstat (limited to 'help/test')
-rw-r--r--help/test/functional/tickets_controller_test.rb28
1 files changed, 25 insertions, 3 deletions
diff --git a/help/test/functional/tickets_controller_test.rb b/help/test/functional/tickets_controller_test.rb
index 7af4c22..7a03a86 100644
--- a/help/test/functional/tickets_controller_test.rb
+++ b/help/test/functional/tickets_controller_test.rb
@@ -15,7 +15,7 @@ class TicketsControllerTest < ActionController::TestCase
end
- test "should create authenticated ticket" do
+ test "should create unauthenticated ticket" do
params = {:title => "ticket test title", :comments_attributes => {"0" => {"body" =>"body of test ticket"}}}
assert_difference('Ticket.count') do
@@ -23,8 +23,30 @@ class TicketsControllerTest < ActionController::TestCase
end
assert_response :redirect
- assert_equal assigns(:ticket).email, User.current_test.email
- assert_equal User.find(assigns(:ticket).created_by).login, User.current_test.login
+ #assert_equal assigns(:ticket).email, User.current.email
+ #assert_equal User.find(assigns(:ticket).created_by).login, User.current.login
+ assert_nil assigns(:ticket).created_by
+
+ assert_equal assigns(:ticket).comments.count, 1
+ end
+
+
+ test "should create authenticated ticket" do
+
+ params = {:title => "ticket test title", :comments_attributes => {"0" => {"body" =>"body of test ticket"}}}
+
+ #todo: should redo this and actually authorize
+ user = User.last
+ session[:user_id] = user.id
+
+ assert_difference('Ticket.count') do
+ post :create, :ticket => params
+ end
+
+ assert_response :redirect
+ assert_equal assigns(:ticket).created_by, user.id
+ assert_equal assigns(:ticket).email, user.email
+
assert_equal assigns(:ticket).comments.count, 1
end