mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-21 05:09:15 +00:00
Create sourced variant link on clone
This commit is contained in:
@@ -118,10 +118,10 @@ module Admin
|
||||
variant = source_variant.dup #may need a VariantDuplicator like producs?
|
||||
variant.price = source_variant.price
|
||||
variant.save!
|
||||
variant.source_variants << source_variant
|
||||
variant.on_demand = source_variant.on_demand
|
||||
variant.on_hand = source_variant.on_hand
|
||||
variant.save!
|
||||
#todo: create link to source
|
||||
|
||||
flash.now[:success] = t('.success')
|
||||
variant_index = "-#{variant.id}"
|
||||
|
||||
@@ -97,6 +97,12 @@ RSpec.describe "Admin::ProductsV3" do
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(response.body).to match "Original variant" # cloned variant name
|
||||
}.to change { variant.product.variants.count }.by(1)
|
||||
|
||||
new_variant = variant.product.variants.last
|
||||
# The new variant is a target of the original. It is a "sourced" variant.
|
||||
expect(variant.target_variants.first).to eq new_variant
|
||||
# The new variant's source is the original
|
||||
expect(new_variant.source_variants.first).to eq variant
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user