Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Fix available_on.nil? out of stock bug (#13490)

Frederik Kragh Nicolajsen2a3235fe777c
diff --git a/core/app/services/spree/data_feeds/google/required_attributes.rb b/core/app/services/spree/data_feeds/google/required_attributes.rb
index 9a4a4b9a6c..c4c2c7b4ab 100644
--- a/core/app/services/spree/data_feeds/google/required_attributes.rb
+++ b/core/app/services/spree/data_feeds/google/required_attributes.rb
@@ -56,7 +56,7 @@ module Spree
end
def get_availability(product)
- return 'in stock' if product.available? && product.available_on&.past?
+ return 'in stock' if product.available? && (product.available_on.nil? || product.available_on.past?)
return 'backorder' if product.backorderable? && product.backordered? && product.available_on&.future?
'out of stock'
diff --git a/core/spec/services/spree/data_feeds/google/rss_spec.rb b/core/spec/services/spree/data_feeds/google/rss_spec.rb
index 7382ff3ae1..ed6a5fff76 100644
--- a/core/spec/services/spree/data_feeds/google/rss_spec.rb
+++ b/core/spec/services/spree/data_feeds/google/rss_spec.rb
@@ -78,8 +78,8 @@ module Spree
context 'availability date is nil' do
let(:product) { create(:product, stores: [store], available_on: nil) }
- it 'shows that product is out of stock' do
- expect(result.value[:file]).to include('<g:availability>out of stock</g:availability>')
+ it 'shows that product is in stock' do
+ expect(result.value[:file]).to include('<g:availability>in stock</g:availability>')
end
it 'shows that product availability date is nil' do