diff options
author | jessib <jessib@riseup.net> | 2012-11-12 10:42:07 -0800 |
---|---|---|
committer | jessib <jessib@riseup.net> | 2012-11-12 10:42:07 -0800 |
commit | 67cb22d50193a58e4697549d9ce8a22e790a7a0d (patch) | |
tree | 5b4f27ff3e47fade97afec78618cfdddf2bd6931 /help/test/functional | |
parent | 90af08d51eb24202bd703bfdfa1d2811fa26a5e0 (diff) |
some notes to test that aren't working now.
Diffstat (limited to 'help/test/functional')
-rw-r--r-- | help/test/functional/tickets_controller_test.rb | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/help/test/functional/tickets_controller_test.rb b/help/test/functional/tickets_controller_test.rb index 7a03a86..8fae44c 100644 --- a/help/test/functional/tickets_controller_test.rb +++ b/help/test/functional/tickets_controller_test.rb @@ -2,7 +2,10 @@ require 'test_helper' class TicketsControllerTest < ActionController::TestCase - test "should get index" do + test "should get index if logged in" do + #todo: should redo this and actually authorize + user = User.last + session[:user_id] = user.id get :index assert_response :success assert_not_nil assigns(:tickets) @@ -28,6 +31,7 @@ class TicketsControllerTest < ActionController::TestCase assert_nil assigns(:ticket).created_by assert_equal assigns(:ticket).comments.count, 1 + assigns(:ticket).destroy # destroys without checking permission. is that okay? end @@ -48,16 +52,46 @@ class TicketsControllerTest < ActionController::TestCase assert_equal assigns(:ticket).email, user.email assert_equal assigns(:ticket).comments.count, 1 + + assigns(:ticket).destroy # ? end - test "add comment to ticket" do + test "add comment to unauthenticated ticket" do t = Ticket.last + t.created_by = nil # TODO: hacky, but this makes sure this ticket is an unauthenticated one + t.save comment_count = t.comments.count put :update, :id => t.id, :ticket => {:comments_attributes => {"0" => {"body" =>"NEWER comment"}} } assert_equal(comment_count + 1, assigns(:ticket).comments.count) #assert_difference block isn't working + end + + test "add comment to 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 + + post :create, :ticket => params + t = assigns(:ticket) + + comment_count = t.comments.count + debugger + put :update, :id => t.id, :ticket => {:comments_attributes => {"0" => {"body" =>"NEWER comment"}} } # this isn't working + assert_equal(comment_count + 1, t.comments.count) + + #comment_count = t.comments.count + # now log out: and retry + #session[:user_id] = nil + #put :update, :id => t.id, :ticket => {:comments_attributes => {"0" => {"body" =>"EVEN NEWER comment"}} } # should fail +# assert_equal(comment_count, t.comments.count) + #assert_difference block isn't working + t.destroy end end |