Hi. I try to create an integration test for a form that updates two models (order and floorplan), Creating a functional test for this situation works fine, however I cannot build an equivalent integration test.
My master model (order) contains has_many :floorplans accepts_nested_attributes_for :floorplans that makes it possible to assign floorplans directly to order then I have a form (new.html.erb) containing <% form_for(@order, :html => {:multipart => true}) do |f| %> <% f.fields_for :floorplans do |floorplan_fields| %> <%= floorplan_fields.file_field :file_upload %> <% end %> <% end %> I only want my form to contain one floorplan object to be created, so in the controller I have def new @order = Order.new @order.floorplans.build end In the functional test I can now verify what I see in the browser: test "should create order" do assert_difference('Order.count') do post :create, { :order => { :floorplans_attributes => [{:file_upload => fixture_file_upload('files/empty', 'image/png')} ] }} end This works fine, but if I try to test this in an integration test I can't test this, I have tried both post "orders/create", {:order => { :floorplans_attributes => [ {:file_upload => fixture_file_upload('files/empty', 'image/png')} ] }} and post "orders/create", {:order => { :floorplans_attributes_0_file_upload => fixture_file_upload('files/empty', 'image/png') }} but it doesn't work. The first attempt just serialises the list [ {:file_upload => fixture_file_upload('files/empty', 'image/png')} ] into a string when creating the HTTP POST request and produces Hash or Array expected, got String ("file_upload#<ActionController::TestUploadedFile:0x7f47ee571f60>") The second one fails with unknown attribute: floorplans_attributes_0_file_upload What to do? Jarl --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---