Fix bug in Variant Overrides controller. It was validating authorization for variant overrides of deleted variants

This commit is contained in:
luisramos0
2019-04-17 15:31:19 +01:00
parent 6b84edb6d9
commit a68b5eaf22
2 changed files with 16 additions and 0 deletions

View File

@@ -77,6 +77,7 @@ module Admin
def collection
@variant_overrides = VariantOverride.for_hubs(params[:hub_id] || @hubs)
@variant_overrides.select { |vo| vo.variant.present? }
end
def collection_actions

View File

@@ -68,6 +68,21 @@ describe Admin::VariantOverridesController, type: :controller do
expect(VariantOverride.find_by_id(variant_override.id)).to be_nil
end
end
context "and there is a variant override for a deleted variant" do
let(:deleted_variant) { create(:variant) }
let!(:variant_override_of_deleted_variant) { create(:variant_override, hub: hub, variant: deleted_variant) }
it "allows to update other variant overrides" do
deleted_variant.update_attribute :deleted_at, Time.zone.now
spree_put :bulk_update, format: format, variant_overrides: variant_override_params
expect(response).to_not redirect_to spree.unauthorized_path
variant_override.reload
expect(variant_override.price).to eq 123.45
end
end
end
end
end