Browse files

Make multiple resource uploads pass on form parameters, which should …

…be expected behaviour.

In the situation where you add a field to Resources, upon create, you're unable to save any of those additional attributes because we only pass on the file attribute at the moment when the user is uploading multiple files. Of course, the user is always uploading multiple files, because the default html5ish behaviour is to send an array anyway. This corrects the existing create method and allows the user to submit multiple attributes to be saved.
  • Loading branch information...
1 parent 50749a6 commit c98b9dc5447f898f3ffa33a6420548538a79c4dd @robyurkowski robyurkowski committed Aug 17, 2012
Showing with 8 additions and 1 deletion.
  1. +1 −1 resources/app/models/refinery/resource.rb
  2. +7 −0 resources/spec/models/refinery/resource_spec.rb
@@ -43,7 +43,7 @@ def create_resources(params)
resources << create(params)
params[:file].each do |resource|
- resources << create(:file => resource)
+ resources << create({:file => resource}.merge(params.except(:file)))
@@ -70,6 +70,13 @@ module Refinery
r.should be_an_instance_of(Resource)
+ specify "each returned array item should be passed form parameters" do
+ params = {:file => [file, file, file], :fake_param => 'blah'}
+ Resource.should_receive(:create).exactly(3).times.with({:file => file, :fake_param => 'blah'})
+ Resource.create_resources(params)
+ end
describe "validations" do

0 comments on commit c98b9dc

Please sign in to comment.