symposium icon indicating copy to clipboard operation
symposium copied to clipboard

PostsController tests not passing

Open terenceponce opened this issue 13 years ago • 2 comments

I'm not sure why all the tests are passing on your machine, but on mine it's not. I tried imitating the tests you made for the ForumsController, but no dice. Here's the error that I've been getting:

Failures:

  1) PostsController GET 'show' returns http success
     Failure/Error: get :index
     AbstractController::ActionNotFound:
       The action 'index' could not be found for PostsController
     # ./spec/controllers/posts_controller_spec.rb:7:in `block (3 levels) in '

  2) PostsController GET 'new' returns http success
     Failure/Error: response.should be_success
       expected success? to return true, got false
     # ./spec/controllers/posts_controller_spec.rb:15:in `block (3 levels) in '

  3) PostsController GET 'create' returns http success
     Failure/Error: response.should be_success
       expected success? to return true, got false
     # ./spec/controllers/posts_controller_spec.rb:22:in `block (3 levels) in '

  4) PostsController GET 'edit' returns http success
     Failure/Error: response.should be_success
       expected success? to return true, got false
     # ./spec/controllers/posts_controller_spec.rb:29:in `block (3 levels) in '

  5) PostsController GET 'update' returns http success
     Failure/Error: response.should be_success
       expected success? to return true, got false
     # ./spec/controllers/posts_controller_spec.rb:36:in `block (3 levels) in '

  6) PostsController GET 'destroy' returns http success
     Failure/Error: response.should be_success
       expected success? to return true, got false
     # ./spec/controllers/posts_controller_spec.rb:43:in `block (3 levels) in '

I did a bit of investigation and I figured that the cause of the failure is that it requires authentication for it to pass, so I tried following this tutorial on the Devise Wiki. I guess it kind of worked because the cause of the failure changed:

ActiveRecord::RecordInvalid:
       Validation failed: Email has already been taken

I think Ryan Bates mentioned something about using sequences on Factory Girl to solve that problem, but I can't seem to get it right. I think this is the best that I can do regarding this issue. I've been trying to fix this for almost 2 hours now, but I don't think I'll be able to fix this on my own.

terenceponce avatar Jan 17 '12 03:01 terenceponce

Oops! I totally forgot about the other controller specs that you are referring to.

I've only put work into the Forums Controller Spec. The other controller specs are relics from the scaffold generator that I haven't replaced yet. Sorry to waste your attention on those.

Note: forums controller spec has one failure now on my machine because something on the app homepage (forums#index) is calling creator on a NilClass. Apparently the app index now breaks when you have a forum that doesn't have any topics/posts. You can try to resolve it if you want, else I'll get to it after I make some more test progress.

danneu avatar Jan 17 '12 21:01 danneu

Weird. I'm not having that error on my machine, so I don't know what I should do about it.

terenceponce avatar Jan 18 '12 01:01 terenceponce