Errors on bulk update for enterprise index do not allow user to list all enterprises

This commit is contained in:
Rob Harrington
2014-11-06 11:01:44 +11:00
parent 1506b10d8f
commit 93e3d87fcb
2 changed files with 10 additions and 1 deletions

View File

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

View File

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