« Return to Thread: Attachment-fu + Story Runner
Hi,I had the same problem, couldn't get it to run with Stories thought...Had to test file uploads using controller specs, which works but is not asclear as a Story.I'm guessing the bug where it changes the TempFile to a String will be fixedsoon by the core team, but if someone has a patch it would be awesome!RaiDaniel Tenner wrote:I've now located where this is going wrong, though I am not yet surehow to fix it.In rails' integration.rb, there is a method called 'process'. aroundline 226. It mangles the parameters by calling:data = requestify(parameters)doing:puts "\n1----===#{parameters.inspect}"puts "\n2----===#{data.inspect}"a bit later reveals the problem:1----==={:quick_file=>{:filename=>"file-TFile.txt", :uploaded_data=>#<ActionController::TestUploadedFile:0x3434150 @content_type="text/plain", @tempfile=#<File:/tmp/test_upload29259-0.txt>,@original_filename="test_upload.txt">}, :quick_folder=>{:id=>1330}, :request_type=>"xml"}2----==="quick_file%5Bfilename%5D=file-TFile.txt&quick_file%5Buploaded_data%5D=%23%3CActionController%3A%3ATestUploadedFile%3A0x3434150%3E&quick_folder%5Bid%5D=1330&request_type=xml"Obviously that's not going to work. I wonder how Test::Unit does it,then, though...DanielOn 11 Dec 2007, at 14:54 11 Dec 2007, Daniel Tenner wrote:Hi Luis,I read through that thread, but unfortunately it wasn't much help.fixture_file_upload also creates anActionController::TestUploadedFile. It's is just a shortcut toActionController::TestUploadedFile.new.There's no problem with the path - it creates the fixture and loadsthe file, and has the right values inside if I inspect the paramsdirectly before posting them:{:filename=>"file-TFile.txt", :uploaded_data=>#<ActionController::TestUploadedFile:0x33f83bc @content_type=#<Mime::Type:0x10e2490 @symbol=:text,@synonyms=[], @string="text/plain">, @tempfile=#<File:/tmp/test_upload29049-0.txt>, @original_filename="test_upload.txt">}It's only once this is passed into the controller that it all getsto_s'ed.I like the idea of 'providing a real file upload', but I'm not surehow to do that in a Story... if anyone has any suggestions orpointers, they would be welcome!Thanks,DanielOn 11 Dec 2007, at 14:39 11 Dec 2007, Luis Lavena wrote:On Dec 11, 2007 10:57 AM, Daniel Tenner <daniel.ruby@...>wrote:I've pasted up the code at:Since there are quite a few files involved.Thanks for your time,A similar discussion was raised back in november (aboutfixture_file_upload):Instead of mocking the FileUpload, why not provide a real one?After all, the StoryRunner is aimed to fully exercise your code :-DAlso, adjust the path of your TestFileUpload file location,instead ofa relative one (../spec/fixtures) provide one related to RAILS_ROOT,which will work no matter where you put your helper or what is yourcurrent directory (Dir.chdir).HTH,--Luis LavenaMultimedia systems-A common mistake that people make when trying to designsomething completely foolproof is to underestimatethe ingenuity of complete fools.Douglas Adams_______________________________________________rspec-users mailing list_______________________________________________rspec-users mailing list_______________________________________________rspec-users mailing list--View this message in context: http://www.nabble.com/Attachment-fu-%2B-Story-Runner-tp14272891p14291797.htmlSent from the rspec-users mailing list archive at Nabble.com._______________________________________________rspec-users mailing list
« Return to Thread: Attachment-fu + Story Runner
| Free embeddable forum powered by Nabble | Forum Help |