mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Fix bug in Variant Overrides controller. It was validating authorization for variant overrides of deleted variants
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user