Skip to content

Instantly share code, notes, and snippets.

@adamcooper

adamcooper/request_spec.rb

Last active Aug 29, 2015
Embed
What would you like to do?
ABOUT TO CALL POST FROM TESTS WITH THIS DATA
data: {}
source=rack-timeout id=40677bbc82995734013bd5f9f961a8d8 timeout=20000ms state=ready
Started POST "/api/purchases" for 127.0.0.1 at 2015-06-25 11:49:41 -0700
source=rack-timeout id=40677bbc82995734013bd5f9f961a8d8 timeout=20000ms service=5ms state=active
Processing by Api::PurchasesController#create as HTML
Parameters: {"purchase"=>{}}
data = {}
header_data = {"HTTP_X_AUTHTOKEN" => "token", "CONTENT_TYPE" => "application/json"
post "/api/purchases", data.to_json, header_data
# in my controller I get this as my params
params == {"controller"=>"api/purchases", "action"=>"create", "purchase"=>{}}
# where the heck did the "purchase" params come from.
# additionally, if there are other params they get duplicated...
data = {"rails" => "WTF??"}
post "/api/purchases", data.to_json, header_data
# in the controller
params == {"rails"=>"WTF??", "controller"=>"api/purchases", "action"=>"create", "purchase"=>{"rails"=>"WTF??"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.