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 api v2 products available on specs (#11273)

Szymon Iwacz985b948ac58f
diff --git a/.circleci/config.yml b/.circleci/config.yml
index ab6634c800..358ebfa7e5 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -25,8 +25,8 @@ run_tests: &run_tests
- checkout
- restore_cache:
keys:
- - spree-bundle-v8-ruby-2-7-{{ .Branch }}
- - spree-bundle-v8-ruby-2-7
+ - spree-bundle-v9-ruby-2-7-{{ .Branch }}
+ - spree-bundle-v9-ruby-2-7
- run:
name: Run rspec in parallel
command: ./bin/build-ci.rb test
@@ -46,8 +46,8 @@ run_tests_3_0: &run_tests_3_0
- checkout
- restore_cache:
keys:
- - spree-bundle-v8-ruby-3-0-{{ .Branch }}
- - spree-bundle-v8-ruby-3-0
+ - spree-bundle-v9-ruby-3-0-{{ .Branch }}
+ - spree-bundle-v9-ruby-3-0
- run:
name: Run rspec in parallel
command: ./bin/build-ci.rb test
@@ -67,15 +67,15 @@ jobs:
- checkout
- restore_cache:
keys:
- - spree-bundle-v8-ruby-2-7-{{ .Branch }}
- - spree-bundle-v8-ruby-2-7
+ - spree-bundle-v9-ruby-2-7-{{ .Branch }}
+ - spree-bundle-v9-ruby-2-7
- run:
name: Bundle Install
command: |
bundle check || bundle install
./bin/build-ci.rb install
- save_cache:
- key: spree-bundle-v8-ruby-2-7-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
+ key: spree-bundle-v9-ruby-2-7-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
paths:
- ~/spree/vendor/bundle
@@ -85,15 +85,15 @@ jobs:
- checkout
- restore_cache:
keys:
- - spree-bundle-v8-ruby-3-0-{{ .Branch }}
- - spree-bundle-v8-ruby-3-0
+ - spree-bundle-v9-ruby-3-0-{{ .Branch }}
+ - spree-bundle-v9-ruby-3-0
- run:
name: Bundle Install
command: |
bundle check || bundle install
./bin/build-ci.rb install
- save_cache:
- key: spree-bundle-v8-ruby-3-0-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
+ key: spree-bundle-v9-ruby-3-0-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
paths:
- ~/spree/vendor/bundle
@@ -129,8 +129,8 @@ jobs:
- checkout
- restore_cache:
keys:
- - spree-bundle-v8-ruby-2-7-{{ .Branch }}
- - spree-bundle-v8-ruby-2-7
+ - spree-bundle-v9-ruby-2-7-{{ .Branch }}
+ - spree-bundle-v9-ruby-2-7
- run:
name: Ensure Bundle Install
command: |
@@ -157,8 +157,8 @@ jobs:
- checkout
- restore_cache:
keys:
- - spree-bundle-v8-ruby-2-7-{{ .Branch }}
- - spree-bundle-v8-ruby-2-7
+ - spree-bundle-v9-ruby-2-7-{{ .Branch }}
+ - spree-bundle-v9-ruby-2-7
- run:
name: Ensure Bundle Install
command: |
@@ -203,8 +203,8 @@ jobs:
- checkout
- restore_cache:
keys:
- - spree-bundle-v8-ruby-3-0-{{ .Branch }}
- - spree-bundle-v8-ruby-3-0
+ - spree-bundle-v9-ruby-3-0-{{ .Branch }}
+ - spree-bundle-v9-ruby-3-0
- run:
name: Run rspec in parallel
command: ./bin/build-ci.rb test
diff --git a/api/spec/requests/spree/api/v2/platform/products_spec.rb b/api/spec/requests/spree/api/v2/platform/products_spec.rb
index 103857fc2b..00c1503ec4 100644
--- a/api/spec/requests/spree/api/v2/platform/products_spec.rb
+++ b/api/spec/requests/spree/api/v2/platform/products_spec.rb
@@ -169,6 +169,8 @@ describe 'API V2 Platform Products Spec' do
end
context 'sorting by available_on' do
+ before { store.products.each_with_index { |p, i| p.update(available_on: Time.current - i.days) } }
+
context 'ascending order' do
before { get '/api/v2/platform/products?sort=available_on', headers: bearer_token }
diff --git a/api/spec/requests/spree/api/v2/storefront/products_spec.rb b/api/spec/requests/spree/api/v2/storefront/products_spec.rb
index 02244e1e95..0c3a7766ad 100644
--- a/api/spec/requests/spree/api/v2/storefront/products_spec.rb
+++ b/api/spec/requests/spree/api/v2/storefront/products_spec.rb
@@ -427,6 +427,8 @@ describe 'API V2 Storefront Products Spec', type: :request do
end
context 'sorting by available_on' do
+ before { store.products.each_with_index { |p, i| p.update(available_on: Time.current - i.days) } }
+
context 'ascending order' do
before { get '/api/v2/storefront/products?sort=available_on' }