mardi 25 octobre 2016

Using CanCanCan in a view failing tests

so I'm working on a project that is using rails, CanCanCan and rspec. I have an ability

 can :set_to_user, Post

Then in my view I have

class: "btn btn-primary #{disable_button(!(can? :set_to_user, post))}

This works in a view, but it seems to fail during tests giving the error:

ActionView::Template::Error:
       Devise could not find the `Warden::Proxy` instance on your request environment.
       Make sure that your application is loading Devise and Warden as expected and that the `Warden::Manager` middleware is present in your middleware stack.
       If you are seeing this on one of your tests, ensure that your tests are either executing the Rails middleware stack or that your tests are using the `Devise::Test::ControllerHelpers` module to inject the `request.env['warden']` object for you.

I'm not sure what is causing it, but any help would be greatly appreciated?

Aucun commentaire:

Enregistrer un commentaire