Topic: file upload and database saving - RSpec testing


im relatively new with Ruby, Rspec and Rails having come from a PHP background, and am struggling a little with a design decision on how to approach the testing of the feature outlined as the title of this thread.

it is basically a file upload, which i need to write to some directory somewhere and then store the path in a models' table.

i have a controller spec which is passing - i can mock an uploaded file (using fixture_file_upload or a Mock of Http::UploadedFile (that might not be named correctly; i dont have the codebase in front of me right now) and do a

post :create

passing the mock file and other form params (title, description etc etc) to the controllers' create and then the model's save method.

it's at this point im kind of stuck on what to test next and how; upon receiving a create request, the model will have a file object passed as its params. i kind of feel like i should create a spec for a separate method which extracts the object, renames and creates the file in the appropriate directory and sets the correct file_path attribute on the model before saving.

what is the correct way to go about doing this? im 100% sure the controller shouldnt process the file first, pushing responsibility to the model to do its work. its just how i go about doing that process. do i override the model save() method, or use before_save ? or am i going in the wrong direction?

FWIW, im using rails 3/latest stable.

Thanks smile