Question

I am trying run an integartion test, testing an email that is sent after the user uses the edit action of the order controller to assign the shipping date of the product.

This is what I have so far:

# the user visits the order edit page
get "orders/#{order.id}/edit"
assert_response :success

# the user submits the edit form with a shipped_on date
# a nonredirect response is returned
post_via_redirect "/orders/#{order.id}/edit",
        order: {
            ship_date: "2014-3-13 20:20:20"
        }

assert_response :success
#check that the user was redirected to edit template
assert_template "edit"

I think this is not working because I am making a POST request and not at PUT request. So my question is, how do I make the PUT request to the update action and pass the new information that would normally be in the form submitted through the browser.

Était-ce utile?

La solution

There is a method put_via_redirect , so it can be used in your test.

More information about the method is there http://apidock.com/rails/ActionController/Integration/Session/put_via_redirect

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top