mardi 13 septembre 2016

How to use session in the test controller in rails 5?

Agile Web Development With Rails4 gives an example code like this:

test "should destroy cart" do
assert_difference('Cart.count', -1) do
  session[:cart_id] = @cart_id
  ...

However, when I try this in rails 5, an error is raised: NoMethodError: undefined method `session' for nil:NilClass.

How to use session in the test controller in rails 5? Or did I overlook some important config?

Aucun commentaire:

Enregistrer un commentaire