diff --git a/app/controllers/admin/enterprises_controller.rb b/app/controllers/admin/enterprises_controller.rb index d0ad4bfac6..a297eadc9c 100644 --- a/app/controllers/admin/enterprises_controller.rb +++ b/app/controllers/admin/enterprises_controller.rb @@ -6,7 +6,7 @@ module Admin helper 'spree/products' def bulk_update - @enterprise_set = ModelSet.new(Enterprise.all, params[:model_set]) + @enterprise_set = EnterpriseSet.new(params[:enterprise_set]) if @enterprise_set.save redirect_to main_app.admin_enterprises_path, :notice => 'Distributor collection times updated.' else @@ -16,7 +16,7 @@ module Admin private def load_enterprise_set - @enterprise_set = ModelSet.new Enterprise.all, :collection => collection + @enterprise_set = EnterpriseSet.new :collection => collection end def load_countries diff --git a/app/models/enterprise_set.rb b/app/models/enterprise_set.rb new file mode 100644 index 0000000000..f267810c62 --- /dev/null +++ b/app/models/enterprise_set.rb @@ -0,0 +1,5 @@ +class EnterpriseSet < ModelSet + def initialize(attributes={}) + super(Enterprise.all, attributes) + end +end diff --git a/app/models/model_set.rb b/app/models/model_set.rb index e806e44014..737fb9d625 100644 --- a/app/models/model_set.rb +++ b/app/models/model_set.rb @@ -1,6 +1,4 @@ -# Tableless model to handle updating multiple models at once from a -# single form. For example, it is used to update the enterprise next_collection_at -# field for all distributors in the admin backend. +# Tableless model to handle updating multiple models at once from a single form class ModelSet include ActiveModel::Conversion extend ActiveModel::Naming diff --git a/spec/requests/admin/enterprises_spec.rb b/spec/requests/admin/enterprises_spec.rb index 535970cf55..5c4b433852 100644 --- a/spec/requests/admin/enterprises_spec.rb +++ b/spec/requests/admin/enterprises_spec.rb @@ -109,9 +109,9 @@ feature %q{ click_link 'Enterprises' # And I fill in some new collection times and save them - fill_in 'model_set_collection_attributes_0_next_collection_at', :with => 'One' - fill_in 'model_set_collection_attributes_1_next_collection_at', :with => 'Two' - fill_in 'model_set_collection_attributes_2_next_collection_at', :with => 'Three' + fill_in 'enterprise_set_collection_attributes_0_next_collection_at', :with => 'One' + fill_in 'enterprise_set_collection_attributes_1_next_collection_at', :with => 'Two' + fill_in 'enterprise_set_collection_attributes_2_next_collection_at', :with => 'Three' click_button 'Update' # Then my times should have been saved