diff --git a/app/controllers/admin/enterprises_controller.rb b/app/controllers/admin/enterprises_controller.rb index b8dd9b9bd5..96e77f129d 100644 --- a/app/controllers/admin/enterprises_controller.rb +++ b/app/controllers/admin/enterprises_controller.rb @@ -42,7 +42,7 @@ module Admin end def bulk_update - @enterprise_set = EnterpriseSet.new(params[:enterprise_set]) + @enterprise_set = EnterpriseSet.new(params[:enterprise_set].merge collection: collection) if @enterprise_set.save flash[:success] = 'Enterprises updated successfully' redirect_to main_app.admin_enterprises_path diff --git a/spec/controllers/admin/enterprises_controller_spec.rb b/spec/controllers/admin/enterprises_controller_spec.rb index 1e961e3710..cda73d4079 100644 --- a/spec/controllers/admin/enterprises_controller_spec.rb +++ b/spec/controllers/admin/enterprises_controller_spec.rb @@ -254,6 +254,15 @@ module Admin expect(profile_enterprise1.owner).to eq original_owner expect(profile_enterprise2.owner).to eq original_owner end + + it "cuts down the list of enterprises displayed when error received on bulk update" do + EnterpriseSet.any_instance.stub(:save) { false } + profile_enterprise1.enterprise_roles.build(user: new_owner).save + controller.stub spree_current_user: new_owner + bulk_enterprise_params = { enterprise_set: { collection_attributes: { '0' => { id: profile_enterprise1.id, visible: 'false' } } } } + spree_put :bulk_update, bulk_enterprise_params + expect(assigns(:enterprise_set).collection).to eq [profile_enterprise1] + end end context "as super admin" do