Create EnterpriseSet as subclass of ModelSet

This commit is contained in:
Rohan Mitchell
2012-11-21 09:08:41 +11:00
parent 98143ffe5b
commit ff0d2bc983
4 changed files with 11 additions and 8 deletions

View File

@@ -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

View File

@@ -0,0 +1,5 @@
class EnterpriseSet < ModelSet
def initialize(attributes={})
super(Enterprise.all, attributes)
end
end

View File

@@ -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

View File

@@ -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