Skip to content

Instantly share code, notes, and snippets.

@adamcooper
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamcooper/7382c2624a1856975bb8 to your computer and use it in GitHub Desktop.
Save adamcooper/7382c2624a1856975bb8 to your computer and use it in GitHub Desktop.
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