mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Fix admin variant overrides controller specs
This commit is contained in:
@@ -52,15 +52,15 @@ RSpec.describe Admin::VariantOverridesController, type: :controller do
|
||||
|
||||
context "and the producer has granted VO permission" do
|
||||
before do
|
||||
create(:enterprise_relationship, parent: variant.product.supplier, child: hub,
|
||||
create(:enterprise_relationship, parent: variant.supplier, child: hub,
|
||||
permissions_list: [:create_variant_overrides])
|
||||
end
|
||||
|
||||
it "loads data" do
|
||||
put :bulk_update, as: format, params: { variant_overrides: variant_override_params }
|
||||
expect(assigns[:hubs]).to eq [hub]
|
||||
expect(assigns[:producers]).to eq [variant.product.supplier]
|
||||
expect(assigns[:hub_permissions]).to eq Hash[hub.id, [variant.product.supplier.id]]
|
||||
expect(assigns[:producers]).to eq [variant.supplier]
|
||||
expect(assigns[:hub_permissions]).to eq Hash[hub.id, [variant.supplier.id]]
|
||||
expect(assigns[:inventory_items]).to eq [inventory_item]
|
||||
end
|
||||
|
||||
@@ -113,9 +113,9 @@ RSpec.describe Admin::VariantOverridesController, type: :controller do
|
||||
|
||||
let(:hub) { create(:distributor_enterprise) }
|
||||
let(:producer) { create(:supplier_enterprise) }
|
||||
let(:product) { create(:product, supplier: producer) }
|
||||
let(:variant1) { create(:variant, product:) }
|
||||
let(:variant2) { create(:variant, product:) }
|
||||
let(:product) { create(:product) }
|
||||
let(:variant1) { create(:variant, product:, supplier: producer) }
|
||||
let(:variant2) { create(:variant, product:, supplier: producer) }
|
||||
let!(:variant_override1) {
|
||||
create(:variant_override, hub:, variant: variant1, count_on_hand: 5, default_stock: 7,
|
||||
resettable: true)
|
||||
@@ -179,8 +179,8 @@ RSpec.describe Admin::VariantOverridesController, type: :controller do
|
||||
"to another hub I manage" do
|
||||
before { hub.owner.update_attribute(:enterprise_limit, 2) }
|
||||
let(:hub2) { create(:distributor_enterprise, owner: hub.owner) }
|
||||
let(:product) { create(:product, supplier: producer) }
|
||||
let(:variant3) { create(:variant, product:) }
|
||||
let(:product) { create(:product) }
|
||||
let(:variant3) { create(:variant, product:, supplier: producer) }
|
||||
let!(:variant_override3) {
|
||||
create(:variant_override, hub: hub2, variant: variant3, count_on_hand: 1,
|
||||
default_stock: 13, resettable: true)
|
||||
|
||||
Reference in New Issue
Block a user