Lukas Ocilka write:
Dne 13.4.2010 11:55, Klaus Kaempf napsal(a):
* Lukas Ocilka <lukas.ocilka@suse.cz> [Apr 13. 2010 11:42]:
Hmm, what makes you think RAW_POST_DATA gets ignored ?
- From what I've seen, the RAW_POST_DATA should be used as the request input processed by the Rails core, not by the controller itself.
Right. And my initial tests support that.
Not until you read them from the @request manually or at least not in the test environment. Pepa has, kind-of, confirmed that.
Some interesting details which I found and clearly description what is intended with test. At first goal is to catch exception throws by ParamsParser middleware. It is prerequest parser which change request in xml to hash - http://github.com/rails/rails/blob/v2.3.5/actionpack/lib/action_controller/p... and http://github.com/rails/rails/blob/v2.3.5/actionpack/lib/action_controller/m... Problem is that functional test simulate request in final state, so it doesn't call this middleware and just pass hash to it. It fills RAW_POST_DATA just to simulate request, but internally doesn't use it and pass hash. Thats reason why it doesn't take affect - http://github.com/rails/rails/blob/2-3-stable/actionpack/lib/action_controll... So for me it looks the easiest way to test this behavior, that we mock functionalTest simulation and it throw same exception as came from that middleware. Josef
If I send the very same XML via curl --data-binary, it works correctly.
I still do not know what "works correctly" means for you. What does your receiving controller look like and how does it parse the request ?
Works correctly => E.g., :create creates a new customer. Using RAW_POST_DATA does not create it and reports that all the required fields were missing.
Anyway, solved using a different method. All I wanted is to test whether we correctly catch an application exception in the RoR layers. I used mocha: --- cut --- Customer.any_instance.stubs(:initialize).raises(Exception, '[EXPECTED ERROR]...') --- cut --- Which throws an exception while creating the new Customer object at the beginning of the 'create' function.
Thx && Bye Lukas
-- Josef Reidinger YaST team maintainer of perl-Bootloader, YaST2-Repair, parts of webyast -- To unsubscribe, e-mail: opensuse-ruby+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-ruby+help@opensuse.org