Compare commits

...

13 Commits

Author SHA1 Message Date
Maikel
ff4b8c82fa Merge pull request #14105 from gbathree/14099-fix-subscriptions-screen-text
Fix raw JSON blob showing on Subscriptions screen
2026-04-08 15:03:51 +10:00
Gaetan Craig-Riou
b0a28aed49 Merge pull request #14140 from openfoodfoundation/dependabot/bundler/json-2.19.3
Bump json from 2.19.2 to 2.19.3
2026-04-08 09:32:00 +10:00
Maikel
7120828123 Merge pull request #14138 from rioug/upgrade-node-version
Upgrade node to 24.14.1
2026-04-08 09:04:38 +10:00
Rachel Arnould
2601a7efd3 Merge pull request #14120 from dacook/clone-variant-links-14080
Clone links when cloning product variants
2026-04-07 17:39:57 +02:00
dependabot[bot]
6b79765622 Bump json from 2.19.2 to 2.19.3
Bumps [json](https://github.com/ruby/json) from 2.19.2 to 2.19.3.
- [Release notes](https://github.com/ruby/json/releases)
- [Changelog](https://github.com/ruby/json/blob/master/CHANGES.md)
- [Commits](https://github.com/ruby/json/compare/v2.19.2...v2.19.3)

---
updated-dependencies:
- dependency-name: json
  dependency-version: 2.19.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-07 09:36:19 +00:00
David Cook
b9eef83753 Fix spec
Find variants by name instead of assuming they'll be in the right order.
2026-04-01 16:56:53 +11:00
David Cook
05f0e71545 Create variant links through Rails association
This allows us to delay saving to the db, reducing overall queries.
2026-04-01 10:53:17 +11:00
David Cook
734af38386 Add spec for db queries
Oh there is quite a lot.
2026-04-01 10:36:11 +11:00
David Cook
b11ce2cdfe Clone links when cloning product variants
Only links within the same product are supported so far.
2026-03-31 15:59:38 +11:00
Gaetan Craig-Riou
9eda07064d Upgrade node to 24.14.1
It includes security fixes
2026-03-27 13:40:19 +11:00
Maikel Linke
78ee53f728 Fix config leak in specs 2026-03-27 13:06:16 +11:00
Maikel Linke
3daabe70ed Undo changes to locales which will come from Transifex 2026-03-27 10:28:17 +11:00
Greg Austic
6a6a1298df Fix raw JSON blob showing on Subscriptions screen (#14099)
The `orders.customer_credit_service` locale keys added by PR #13963
were placed under an `orders:` namespace in locale files. In en.yml
this created a duplicate `orders:` key, causing YAML to override the
existing `orders: "Orders"` string with the hash — so `t('orders')`
returned the hash instead of "Orders", showing raw JSON on the screen.

Move translations to `customer_credit_service:` at the top level and
update the service's `translation_scope` to match.

Fixes #14099

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 10:27:29 +11:00
7 changed files with 114 additions and 16 deletions

View File

@@ -1 +1 @@
24.10.0
24.14.1

View File

@@ -441,7 +441,7 @@ GEM
thor (>= 0.14, < 2.0)
jquery-ui-rails (4.2.1)
railties (>= 3.2.16)
json (2.19.2)
json (2.19.3)
json-canonicalization (1.0.0)
json-jwt (1.17.0)
activesupport (>= 4.2)
@@ -1269,7 +1269,7 @@ CHECKSUMS
jmespath (1.6.2) sha256=238d774a58723d6c090494c8879b5e9918c19485f7e840f2c1c7532cf84ebcb1
jquery-rails (4.4.0) sha256=b1048e5bf181b94dcac82d28a4696cd79c6200167a024a07f57607ab28aa7036
jquery-ui-rails (4.2.1) sha256=5b349e7066150b16d7a784183f040c083d51af3357937b8564aa0cc8b1cd59bd
json (2.19.2) sha256=e7e1bd318b2c37c4ceee2444841c86539bc462e81f40d134cf97826cb14e83cf
json (2.19.3) sha256=289b0bb53052a1fa8c34ab33cc750b659ba14a5c45f3fcf4b18762dc67c78646
json-canonicalization (1.0.0) sha256=d4848a8cca7534455c6721f2d9fc9e5e9adca49486864a898810024f67d59446
json-jwt (1.17.0) sha256=6ff99026b4c54281a9431179f76ceb81faa14772d710ef6169785199caadc4cc
json-ld (3.3.2) sha256=b9531893bf5bdc01db428e96953845a23adb1097125ce918ae0f97c4a6e1ab27

View File

@@ -92,7 +92,7 @@ module Orders
end
def translation_scope
"orders.customer_credit_service"
"customer_credit_service"
end
class Response

View File

@@ -5220,8 +5220,7 @@ en:
credit_payment_method_missing: Credit payment method is missing
no_credit_available: No credit available
not_enough_credit_available: Not enough credit available
orders:
customer_credit_service:
no_credit_owed: No credit owed
credit_payment_method_missing: Customer credit payment method is missing, please check configuration
refund_sucessful: Refund successful!
customer_credit_service:
no_credit_owed: No credit owed
credit_payment_method_missing: Customer credit payment method is missing, please check configuration
refund_sucessful: Refund successful!

View File

@@ -32,9 +32,12 @@ module Spree
end
def duplicate_variants
product.variants.map do |variant|
# Create a hash with mapping: { <orig-variant>: <new-variant>, }
mapped_variants = product.variants.index_with do |variant|
duplicate_variant(variant)
end
duplicate_variant_links(mapped_variants)
mapped_variants.values
end
def duplicate_variant(variant)
@@ -47,6 +50,19 @@ module Spree
end
end
def duplicate_variant_links(mapped_variants)
# Find any links between orig variants (links to/from another product are ignored)
variant_links = VariantLink.where(source_variant: [mapped_variants.keys],
target_variant: [mapped_variants.keys])
# Link the new variants
variant_links.find_each do |variant_link|
source_variant = mapped_variants[variant_link.source_variant]
target_variant = mapped_variants[variant_link.target_variant]
target_variant.variant_links_as_target.new(source_variant:)
end
end
def duplicate_image(image)
new_image = image.dup
new_image.attachment.attach(image.attachment_blob)

View File

@@ -36,6 +36,7 @@ RSpec.describe Spree::Core::ProductDuplicator do
it "can duplicate a product" do
duplicator = Spree::Core::ProductDuplicator.new(product)
allow(duplicator).to receive(:duplicate_variant_links) # tested elsewhere
expect(new_product).to receive(:name=).with("COPY OF foo")
expect(new_product).to receive(:sku=).with("")
expect(new_product).to receive(:product_properties=).with([new_property])
@@ -65,6 +66,92 @@ RSpec.describe Spree::Core::ProductDuplicator do
end
end
describe "duplicating" do
subject { described_class.new(product).duplicate }
context "with multiple variant links" do
let(:product) { create(:product) }
before do
src_variant = product.variants.first.tap { it.update! display_name: "SRC" }
user = src_variant.supplier.owner
src_variant.create_linked_variant(user).tap { it.update! display_name: "LNK1" }
src_variant.create_linked_variant(user).tap { it.update! display_name: "LNK2" }
end
it "duplicates variant links" do
expect(subject).to be_a Spree::Product
expect(subject.variants.count).to eq 3
new_src_variant = subject.variants.find { it.display_name == "SRC" }
new_lnk_variant1 = subject.variants.find { it.display_name == "LNK1" }
new_lnk_variant2 = subject.variants.find { it.display_name == "LNK2" }
expect(new_src_variant.target_variants).to eq [new_lnk_variant1, new_lnk_variant2]
expect(new_lnk_variant1.source_variants).to eq [new_src_variant]
expect(new_lnk_variant2.source_variants).to eq [new_src_variant]
end
it "minimises(?) database queries" do
expect { subject }.to query_database [
"Spree::ProductProperty Load",
"Spree::Image Load",
"Spree::Variant Load",
"Spree::Image Load",
"Spree::Price Load",
"Spree::Image Load",
"Spree::Price Load",
"Spree::Image Load",
"Spree::Price Load",
"VariantLink Load",
"Spree::Variant Load",
"Spree::Variant Load",
"Spree::Variant Load",
"Spree::Variant Load",
"TRANSACTION",
"Spree::ShippingCategory Load",
"Spree::Taxon Load",
"Enterprise Load",
"Spree::ShippingCategory Load",
"Spree::Taxon Load",
"Enterprise Load",
"Spree::ShippingCategory Load",
"Spree::Taxon Load",
"Enterprise Load",
"Spree::Product Create",
"Spree::Variant Create",
"Spree::Price Create",
"Spree::StockItem Exists?",
"Spree::StockItem Exists?",
"Spree::StockItem Create",
"ActsAsTaggableOn::Tagging Load",
"Spree::Variant Update",
"Spree::Variant Create",
"Spree::Price Create",
"VariantLink Create",
"Spree::StockItem Exists?",
"Spree::StockItem Exists?",
"Spree::StockItem Create",
"ActsAsTaggableOn::Tagging Load",
"Spree::Variant Update",
"Spree::Variant Create",
"Spree::Price Create",
"VariantLink Create",
"Spree::StockItem Exists?",
"Spree::StockItem Exists?",
"Spree::StockItem Create",
"ActsAsTaggableOn::Tagging Load",
"Spree::Variant Update",
"Spree::Product Update",
"Enterprise Update",
"Enterprise Update All",
"Spree::Taxon Update",
"TRANSACTION"
]
end
end
end
describe "errors" do
context "with invalid product" do
# Name has a max length of 255 char, when cloning a product the cloned product has a name

View File

@@ -220,13 +220,9 @@ RSpec.describe '
let(:product) { create(:simple_product) }
let(:variant) { product.variants.first }
around do |example|
I18n.default_locale = :es
example.run
I18n.default_locale = :en
end
before do
allow(I18n).to receive(:default_locale).and_return(:es)
variant.update( unit_value: 1, unit_description: 'foo' )
# When I view the variant