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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Speed up test suite, improve dummy app creation (#12319)
Damian Legawiec26c248deb08b
diff --git a/.circleci/config.yml b/.circleci/config.ymlindex e189ea590f..f328483717 100644--- a/.circleci/config.yml+++ b/.circleci/config.yml@@ -27,6 +27,9 @@ defaults: &defaultsBUNDLE_PATH: ~/spree/vendor/bundleRAILS_VERSION: << parameters.rails_version >>DB: postgres # default value, this will speed up bundle install for all postgres builds+ DB_HOST: localhost+ DB_USERNAME: postgres+working_directory: ~/spreedocker:- image: &ruby_image cimg/ruby:3.3.0-browsers@@ -70,37 +73,74 @@ jobs:- store_test_results:path: /tmp/test-results- tests_postgres:+ tests_core:<<: *run_test- parallelism: 12- parameters:- <<: *default_parameters+ docker:+ - image: *ruby_image+ - image: cimg/postgres:16.2+ environment:+ POSTGRES_USER: postgres+ parallelism: 6environment:<<: *environment- DB_HOST: localhost- DB_USERNAME: postgres+ PROJECTS: core++ tests_api:+ <<: *run_test+ parallelism: 4docker:- image: *ruby_image- image: cimg/postgres:16.2environment:POSTGRES_USER: postgres+ environment:+ <<: *environment+ PROJECTS: api- tests_mysql:+ tests_admin:<<: *run_test- parallelism: 12- parameters:- <<: *default_parameters+ docker:+ - image: *ruby_image+ - image: cimg/postgres:16.2+ environment:+ POSTGRES_USER: postgresenvironment:<<: *environment- DB: mysql- DB_HOST: 127.0.0.1- DB_USERNAME: root- COVERAGE: true- COVERAGE_DIR: /tmp/workspace/simplecov+ PROJECTS: admin++ tests_storefront:+ <<: *run_testdocker:- image: *ruby_image- - image: cimg/mysql:8.0- command: [--default-authentication-plugin=mysql_native_password]+ - image: cimg/postgres:16.2+ environment:+ POSTGRES_USER: postgres+ environment:+ <<: *environment+ PROJECTS: storefront++ tests_other:+ <<: *run_test+ docker:+ - image: *ruby_image+ - image: cimg/postgres:16.2+ environment:+ POSTGRES_USER: postgres+ environment:+ <<: *environment+ PROJECTS: emails,sample++ # tests_mysql:+ # <<: *run_test+ # parallelism: 12+ # parameters:+ # <<: *default_parameters+ # environment:+ # <<: *environment_mysql+ # docker:+ # - image: *ruby_image+ # - image: cimg/mysql:8.0+ # command: [--default-authentication-plugin=mysql_native_password]workflows:main:@@ -108,43 +148,36 @@ workflows:- run_test:name: buildrun_file_path: ./bin/bundle_ruby.sh- - tests_postgres:- name: tests_rails_postgres+ - tests_core:+ name: tests_rails_postgres_corestore_artefacts: truerun_file_path: ./bin/tests_database_ci.shrequires:- build- - tests_postgres:- name: tests_rails_7_1_postgres- rails_version: '~> 7.1.0'+ - tests_api:+ name: tests_rails_postgres_apistore_artefacts: truerun_file_path: ./bin/tests_database_ci.shrequires:- build- - tests_rails_postgres- - tests_postgres:- name: tests_rails_7_0_postgres- rails_version: '~> 7.0.0'+ - tests_admin:+ name: tests_rails_postgres_adminstore_artefacts: truerun_file_path: ./bin/tests_database_ci.shrequires:- build- - tests_rails_postgres- - tests_postgres:- name: tests_rails_6_1_postgres- rails_version: '~> 6.1.0'+ - tests_storefront:+ name: tests_rails_postgres_storefrontstore_artefacts: truerun_file_path: ./bin/tests_database_ci.shrequires:- build- - tests_rails_postgres- - tests_mysql:- name: tests_rails_mysql+ - tests_other:+ name: tests_rails_postgres_otherstore_artefacts: truerun_file_path: ./bin/tests_database_ci.shrequires:- build- - tests_rails_postgres- run_test:name: brakemanrestore_cache_key_1: spree-brakeman-{{ .Branch }}@@ -153,4 +186,8 @@ workflows:run_file_path: ./bin/brakeman.shrequires:- build- - tests_rails_postgres+ - tests_rails_postgres_core+ - tests_rails_postgres_api+ - tests_rails_postgres_admin+ - tests_rails_postgres_storefront+ - tests_rails_postgres_otherdiff --git a/admin/spec/helpers/spree/admin/currencies_helper_spec.rb b/admin/spec/helpers/spree/admin/currencies_helper_spec.rbindex 26887cc3e8..3a127790ef 100644--- a/admin/spec/helpers/spree/admin/currencies_helper_spec.rb+++ b/admin/spec/helpers/spree/admin/currencies_helper_spec.rb@@ -1,9 +1,10 @@require 'spec_helper'RSpec.describe Spree::Admin::CurrenciesHelper, type: :helper do- let(:store) { create(:store, supported_currencies: 'USD,EUR,GBP') }+ let(:store) { Spree::Store.default }before do+ allow(store).to receive(:supported_currencies).and_return('USD,EUR,GBP')allow(helper).to receive(:current_store).and_return(store)allow(helper).to receive(:current_currency).and_return('USD')enddiff --git a/admin/spec/spec_helper.rb b/admin/spec/spec_helper.rbindex 2ba61f2644..a9925b363c 100644--- a/admin/spec/spec_helper.rb+++ b/admin/spec/spec_helper.rb@@ -61,7 +61,7 @@ RSpec.configure do |config|# If you're not using ActiveRecord, or you'd prefer not to run each of your# examples within a transaction, comment the following line or assign false# instead of true.- config.use_transactional_fixtures = false+ config.use_transactional_fixtures = trueconfig.before(:suite) doCapybara.match = :smart@@ -80,6 +80,7 @@ RSpec.configure do |config|endconfig.before(:each) do+ Spree::Webhooks.disabled = truebeginRails.cache.clearreset_spree_preferences@@ -87,12 +88,6 @@ RSpec.configure do |config|endend- config.around(:each) do |example|- DatabaseCleaner.cleaning do- example.run- end- end-config.include FactoryBot::Syntax::Methodsconfig.include Spree::Admin::TestingSupport::CapybaraUtilsdiff --git a/api/spec/controllers/spree/api/v2/platform/resource_controller_spec.rb b/api/spec/controllers/spree/api/v2/platform/resource_controller_spec.rbindex 86471b3f2a..c816ada2b0 100644--- a/api/spec/controllers/spree/api/v2/platform/resource_controller_spec.rb+++ b/api/spec/controllers/spree/api/v2/platform/resource_controller_spec.rb@@ -41,10 +41,12 @@ describe Spree::Api::V2::Platform::ResourceController, type: :controller doallow(dummy_controller).to receive(:spree_current_user).and_return(nil)end- it { expect(collection.first).to be_instance_of(Spree::Product) }- it { expect(collection.count).to eq(store.products.count) }- it { expect(collection.map(&:id)).to include(product.id) }- it { expect(collection.map(&:id)).not_to include(product_from_another_store.id) }+ it 'returns collection of records from the current store' do+ expect(collection.first).to be_instance_of(Spree::Product)+ expect(collection.count).to eq(store.products.count)+ expect(collection.map(&:id)).to include(product.id)+ expect(collection.map(&:id)).not_to include(product_from_another_store.id)+ endenddescribe '#permitted_resource_params' dodiff --git a/api/spec/controllers/spree/api/v2/resource_controller_spec.rb b/api/spec/controllers/spree/api/v2/resource_controller_spec.rbindex 48c1270300..9613f5a38a 100644--- a/api/spec/controllers/spree/api/v2/resource_controller_spec.rb+++ b/api/spec/controllers/spree/api/v2/resource_controller_spec.rb@@ -65,9 +65,11 @@ describe Spree::Api::V2::ResourceController, type: :controller doallow(dummy_controller).to receive(:spree_current_user).and_return(nil)end- it { expect(collection.first).to be_instance_of(Spree::Product) }- it { expect(collection.count).to eq(store.products.count) }- it { expect(collection.map(&:id)).to include(product.id) }- it { expect(collection.map(&:id)).not_to include(product_from_another_store.id) }+ it 'returns collection of records from the current store' do+ expect(collection.first).to be_instance_of(Spree::Product)+ expect(collection.count).to eq(store.products.count)+ expect(collection.map(&:id)).to include(product.id)+ expect(collection.map(&:id)).not_to include(product_from_another_store.id)+ endendenddiff --git a/api/spec/integration/api/v2/platform/taxonomies_spec.rb b/api/spec/integration/api/v2/platform/taxonomies_spec.rbindex 6c59ebc740..a40556aa33 100644--- a/api/spec/integration/api/v2/platform/taxonomies_spec.rb+++ b/api/spec/integration/api/v2/platform/taxonomies_spec.rb@@ -9,7 +9,7 @@ describe 'Taxonomies API', swagger: true dofilter_examples: [{ name: 'filter[name_eq]', example: 'Categories' }]}- let(:id) { create(:taxonomy, store: store).id }+ let(:id) { store.taxonomies.first.id }let(:records_list) { create_list(:taxonomy, 2) }let(:valid_create_param_value) do{diff --git a/api/spec/requests/spree/api/v2/errors_spec.rb b/api/spec/requests/spree/api/v2/errors_spec.rbindex 7a4555b48e..f8bee3b198 100644--- a/api/spec/requests/spree/api/v2/errors_spec.rb+++ b/api/spec/requests/spree/api/v2/errors_spec.rb@@ -4,9 +4,8 @@ describe 'API v2 Errors spec', type: :request docontext 'record not found' dobefore { get '/api/v2/storefront/products/product-that-doesn-t-exist' }- it_behaves_like 'returns 404 HTTP status'-it 'returns proper error message' do+ expect(response.status).to eq(404)expect(json_response['error']).to eq('The resource you were looking for could not be found.')endend@@ -23,9 +22,8 @@ describe 'API v2 Errors spec', type: :request dopatch '/api/v2/storefront/cart/empty', headers: headers_bearerend- it_behaves_like 'returns 403 HTTP status'-it 'returns proper error message' do+ expect(response.status).to eq(403)expect(json_response['error']).to eq('You are not authorized to access this page.')enddiff --git a/api/spec/requests/spree/api/v2/platform/cms_sections_spec.rb b/api/spec/requests/spree/api/v2/platform/cms_sections_spec.rbindex 1f9f11ca91..fb43ea0821 100644--- a/api/spec/requests/spree/api/v2/platform/cms_sections_spec.rb+++ b/api/spec/requests/spree/api/v2/platform/cms_sections_spec.rb@@ -28,8 +28,6 @@ describe 'Platform API v2 CmsSections', type: :request dopatch "/api/v2/platform/cms_sections/#{resource_a.id}", headers: bearer_token, params: paramsend- it_behaves_like 'returns 200 HTTP status'-it 'moves resource_a from position 1 to position 5 and updates the positions of its siblings accordingly' doreload_sections@@ -56,8 +54,6 @@ describe 'Platform API v2 CmsSections', type: :request dopatch "/api/v2/platform/cms_sections/#{resource_d.id}", headers: bearer_token, params: paramsend- it_behaves_like 'returns 200 HTTP status'-it 'moves resource_d from position 4 to position 1, and updates the name' doreload_sectionsexpect(resource_d.position).to eq(1)diff --git a/api/spec/requests/spree/api/v2/platform/line_items_spec.rb b/api/spec/requests/spree/api/v2/platform/line_items_spec.rbindex 6436ee690d..dd8fee0f4c 100644--- a/api/spec/requests/spree/api/v2/platform/line_items_spec.rb+++ b/api/spec/requests/spree/api/v2/platform/line_items_spec.rb@@ -11,30 +11,12 @@ describe 'API V2 Platform Line Items Spec' docontext 'with no params' dobefore { get '/api/v2/platform/line_items', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns all line_items' doexpect(json_response['data'].count).to eq store.line_items.countexpect(json_response['data'].first).to have_type('line_item')endend- context 'current store' do- let(:store_2) { create(:store) }- let(:order_2) { create(:order, store: store_2) }- let!(:line_item_from_another_store) { create(:line_item, order: order_2) }-- before { get '/api/v2/platform/line_items', headers: bearer_token }-- it 'returns line items from this store only' do- expect(json_response['data'].count).to eq store.line_items.count- line_item_ids = json_response['data'].pluck(:id)-- expect(line_item_ids).not_to include(line_item_from_another_store.id)- expect(line_item_ids).to match_array(store.line_items.ids.map(&:to_s))- end- end-context 'filtering' docontext 'by order_id' dolet(:order) { create(:order, store: store) }@@ -76,8 +58,6 @@ describe 'API V2 Platform Line Items Spec' docontext 'ascending order' dobefore { get '/api/v2/platform/line_items?sort=price', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns line items sorted by price' doexpect(json_response['data'].count).to eq store.line_items.countexpect(json_response['data'].pluck(:id)).to eq store.line_items.order(price: :asc).map(&:id).map(&:to_s)@@ -87,8 +67,6 @@ describe 'API V2 Platform Line Items Spec' docontext 'descending order' dobefore { get '/api/v2/platform/line_items?sort=-price', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns line items sorted by price with descending order' doexpect(json_response['data'].count).to eq store.line_items.countexpect(json_response['data'].pluck(:id)).to eq store.line_items.order(price: :desc).map(&:id).map(&:to_s)@@ -100,8 +78,6 @@ describe 'API V2 Platform Line Items Spec' docontext 'ascending order' dobefore { get '/api/v2/platform/line_items?sort=updated_at', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns line items sorted by updated_at' doexpect(json_response['data'].count).to eq store.line_items.countexpect(json_response['data'].pluck(:id)).to eq store.line_items.order(:updated_at).map(&:id).map(&:to_s)@@ -111,8 +87,6 @@ describe 'API V2 Platform Line Items Spec' docontext 'descending order' dobefore { get '/api/v2/platform/line_items?sort=-updated_at', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns line items sorted by updated_at with descending order' doexpect(json_response['data'].count).to eq store.line_items.countexpect(json_response['data'].pluck(:id)).to eq store.line_items.order(updated_at: :desc).map(&:id).map(&:to_s)@@ -124,8 +98,6 @@ describe 'API V2 Platform Line Items Spec' docontext 'ascending order' dobefore { get '/api/v2/platform/line_items?sort=created_at', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns line items sorted by created_at' doexpect(json_response['data'].count).to eq store.line_items.countexpect(json_response['data'].pluck(:id)).to eq store.line_items.order(:created_at).map(&:id).map(&:to_s)@@ -135,8 +107,6 @@ describe 'API V2 Platform Line Items Spec' docontext 'descending order' dobefore { get '/api/v2/platform/line_items?sort=-created_at', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns line items sorted by created_at with descending order' doexpect(json_response['data'].count).to eq store.line_items.countexpect(json_response['data'].pluck(:id)).to eq store.line_items.order(created_at: :desc).map(&:id).map(&:to_s)@@ -150,18 +120,10 @@ describe 'API V2 Platform Line Items Spec' docontext 'when per_page is between 1 and default value' dobefore { get '/api/v2/platform/line_items?page=1&per_page=2', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns the default number of line items' doexpect(json_response['data'].count).to eq 2- end-- it 'returns proper meta data' doexpect(json_response['meta']['count']).to eq 2expect(json_response['meta']['total_count']).to eq store.line_items.count- end-- it 'returns proper links data' doexpect(json_response['links']['self']).to include('/api/v2/platform/line_items?page=1&per_page=2')expect(json_response['links']['next']).to include('/api/v2/platform/line_items?page=2&per_page=2')expect(json_response['links']['prev']).to include('/api/v2/platform/line_items?page=1&per_page=2')@@ -172,18 +134,10 @@ describe 'API V2 Platform Line Items Spec' docontext 'without specified pagination params' dobefore { get '/api/v2/platform/line_items', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns specified amount line items' doexpect(json_response['data'].count).to eq store.line_items.count- end-- it 'returns proper meta data' doexpect(json_response['meta']['count']).to eq json_response['data'].countexpect(json_response['meta']['total_count']).to eq store.line_items.count- end-- it 'returns proper links data' doexpect(json_response['links']['self']).to include('/api/v2/platform/line_items')expect(json_response['links']['next']).to include('/api/v2/platform/line_items?page=1')expect(json_response['links']['prev']).to include('/api/v2/platform/line_items?page=1')diff --git a/api/spec/requests/spree/api/v2/platform/products_spec.rb b/api/spec/requests/spree/api/v2/platform/products_spec.rbindex 2808ae5063..784de6b99b 100644--- a/api/spec/requests/spree/api/v2/platform/products_spec.rb+++ b/api/spec/requests/spree/api/v2/platform/products_spec.rb@@ -31,8 +31,6 @@ describe 'API V2 Platform Products Spec' docontext 'with no params' dobefore { get '/api/v2/platform/products', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns all products' doexpect(json_response['data'].count).to eq store.products.countexpect(json_response['data'].first).to have_type('product')@@ -79,8 +77,6 @@ describe 'API V2 Platform Products Spec' docontext 'ascending order' dobefore { get '/api/v2/platform/products?sort=price', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by price' doexpect(json_response['data'].count).to eq store.products.countexpect(json_response['data'].pluck(:id)).to eq store.products.joins(master: :prices).select("#{store.products.table_name}.*, #{Spree::Price.table_name}.amount").distinct.order("#{Spree::Price.table_name}.amount").map(&:id).map(&:to_s)@@ -90,8 +86,6 @@ describe 'API V2 Platform Products Spec' docontext 'descending order' dobefore { get '/api/v2/platform/products?sort=-price', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by price with descending order' doexpect(json_response['data'].count).to eq store.products.countexpect(json_response['data'].pluck(:id)).to eq store.products.joins(master: :prices).select("#{store.products.table_name}.*, #{Spree::Price.table_name}.amount").distinct.order("#{Spree::Price.table_name}.amount DESC").map(&:id).map(&:to_s)@@ -103,8 +97,6 @@ describe 'API V2 Platform Products Spec' docontext 'A-Z' dobefore { get '/api/v2/platform/products?sort=name', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by name' doexpect(json_response['data'].count).to eq store.products.countexpect(json_response['data'].pluck(:id)).to eq store.products.order(:name).map(&:id).map(&:to_s)@@ -114,8 +106,6 @@ describe 'API V2 Platform Products Spec' docontext 'Z-A' dobefore { get '/api/v2/platform/products?sort=-name', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by name with descending order' doexpect(json_response['data'].count).to eq store.products.countexpect(json_response['data'].pluck(:id)).to eq store.products.order(name: :desc).map(&:id).map(&:to_s)@@ -127,8 +117,6 @@ describe 'API V2 Platform Products Spec' docontext 'ascending order' dobefore { get '/api/v2/platform/products?sort=updated_at', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by updated_at' doexpect(json_response['data'].count).to eq store.products.countexpect(json_response['data'].pluck(:id)).to eq store.products.order(:updated_at).map(&:id).map(&:to_s)@@ -138,8 +126,6 @@ describe 'API V2 Platform Products Spec' docontext 'descending order' dobefore { get '/api/v2/platform/products?sort=-updated_at', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by updated_at with descending order' doexpect(json_response['data'].count).to eq store.products.countexpect(json_response['data'].pluck(:id)).to eq store.products.order(updated_at: :desc).map(&:id).map(&:to_s)@@ -151,8 +137,6 @@ describe 'API V2 Platform Products Spec' docontext 'ascending order' dobefore { get '/api/v2/platform/products?sort=created_at', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by created_at' doexpect(json_response['data'].count).to eq store.products.countexpect(json_response['data'].pluck(:id)).to eq store.products.order(:created_at).map(&:id).map(&:to_s)@@ -162,8 +146,6 @@ describe 'API V2 Platform Products Spec' docontext 'descending order' dobefore { get '/api/v2/platform/products?sort=-created_at', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by created_at with descending order' doexpect(json_response['data'].count).to eq store.products.countexpect(json_response['data'].pluck(:id)).to eq store.products.order(created_at: :desc).map(&:id).map(&:to_s)@@ -177,8 +159,6 @@ describe 'API V2 Platform Products Spec' docontext 'ascending order' dobefore { get '/api/v2/platform/products?sort=available_on', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by available_on' doexpect(json_response['data'].count).to eq store.products.countexpect(json_response['data'].pluck(:id)).to eq store.products.order(:available_on).map(&:id).map(&:to_s)@@ -188,8 +168,6 @@ describe 'API V2 Platform Products Spec' docontext 'descending order' dobefore { get '/api/v2/platform/products?sort=-available_on', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by available_on with descending order' doexpect(json_response['data'].count).to eq store.products.countexpect(json_response['data'].pluck(:id)).to eq store.products.order(available_on: :desc).map(&:id).map(&:to_s)@@ -203,8 +181,6 @@ describe 'API V2 Platform Products Spec' docontext 'ascending order' dobefore { get '/api/v2/platform/products?sort=make_active_at', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by make_active_at' doexpect(json_response['data'].count).to eq store.products.countexpect(json_response['data'].pluck(:id)).to eq store.products.order(:make_active_at).map(&:id).map(&:to_s)@@ -214,8 +190,6 @@ describe 'API V2 Platform Products Spec' docontext 'descending order' dobefore { get '/api/v2/platform/products?sort=-make_active_at', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by make_active_at with descending order' doexpect(json_response['data'].count).to eq store.products.countexpect(json_response['data'].pluck(:id)).to eq store.products.order(make_active_at: :desc).map(&:id).map(&:to_s)@@ -229,8 +203,6 @@ describe 'API V2 Platform Products Spec' docontext 'when per_page is between 1 and default value' dobefore { get '/api/v2/platform/products?page=1&per_page=2', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns the default number of products' doexpect(json_response['data'].count).to eq 2end@@ -275,8 +247,6 @@ describe 'API V2 Platform Products Spec' docontext 'without specified pagination params' dobefore { get '/api/v2/platform/products', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns specified amount products' doexpect(json_response['data'].count).to eq store.products.countend@@ -335,7 +305,6 @@ describe 'API V2 Platform Products Spec' docontext 'when no image transformation params are passed' dolet(:image_transformation_params) { '' }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns product image data'it 'returns product image' do@@ -346,7 +315,6 @@ describe 'API V2 Platform Products Spec' docontext 'when product image json returned' dolet(:image_transformation_params) { '&image_transformation[size]=100x50&image_transformation[quality]=50' }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns product image data'it 'returns product image' dodiff --git a/api/spec/requests/spree/api/v2/platform/promotions_spec.rb b/api/spec/requests/spree/api/v2/platform/promotions_spec.rbindex df52f56484..227d849f65 100644--- a/api/spec/requests/spree/api/v2/platform/promotions_spec.rb+++ b/api/spec/requests/spree/api/v2/platform/promotions_spec.rb@@ -6,8 +6,8 @@ describe 'Promotion API v2 spec', type: :request dolet(:bearer_token) { { 'Authorization' => valid_authorization } }let!(:store) { Spree::Store.default }- let!(:second_store) { create(:store) }- let!(:third_store) { create(:store) }+ let(:second_store) { create(:store) }+ let(:third_store) { create(:store) }let(:promotion_rule) { create(:promotion_rule) }let(:existing_promotion) { create(:promotion_with_item_adjustment, promotion_rules: [promotion_rule]) }diff --git a/api/spec/requests/spree/api/v2/platform/resources_spec.rb b/api/spec/requests/spree/api/v2/platform/resources_spec.rbindex 933ed100f3..0cc5a411dc 100644--- a/api/spec/requests/spree/api/v2/platform/resources_spec.rb+++ b/api/spec/requests/spree/api/v2/platform/resources_spec.rb@@ -5,8 +5,8 @@ describe 'Platform API v2 Resources spec', type: :request doinclude_context 'Platform API v2'let!(:store) { Spree::Store.default }- let!(:store_two) { create(:store) }- let!(:store_three) { create(:store) }+ let(:store_two) { create(:store) }+ let(:store_three) { create(:store) }let(:bearer_token) { { 'Authorization' => valid_authorization } }let(:resource_params) { {} }@@ -16,7 +16,6 @@ describe 'Platform API v2 Resources spec', type: :request dolet(:user) { create(:user) }let(:resource) { create(:address, state: state, country: country, user: user) }let(:id) { resource.id }- let(:valid_http_status) { 200 }shared_examples 'returns auth token errors' docontext 'with missing authorization token' do@@ -61,8 +60,6 @@ describe 'Platform API v2 Resources spec', type: :request doshared_examples 'valid request' dobefore { execute }- it_behaves_like 'returns 200 HTTP status'-it 'returns valid JSON' doexpect(json_response['data'][0]).to have_type(resource.class.json_api_type)expect(json_response['data'].count).to eq(resources_count)@@ -80,8 +77,6 @@ describe 'Platform API v2 Resources spec', type: :request dobefore { execute }- it_behaves_like 'returns 200 HTTP status'-it 'returns proper resources' doexpect(json_response['data'][0]).to have_type(resource.class.json_api_type)expect(json_response['data'].count).to eq(2)@@ -98,8 +93,6 @@ describe 'Platform API v2 Resources spec', type: :request doexecuteend- it_behaves_like 'returns 200 HTTP status'-it 'returns proper resources' doexpect(json_response['data'][0]).to have_type(resource.class.json_api_type)expect(json_response['data'].count).to eq(1)@@ -114,8 +107,6 @@ describe 'Platform API v2 Resources spec', type: :request dobefore { execute }- it_behaves_like 'returns 200 HTTP status'-it 'returns proper resource count' doexpect(json_response['data'].count).to eq 2end@@ -166,8 +157,6 @@ describe 'Platform API v2 Resources spec', type: :request docontext 'without specified pagination params' dobefore { execute }- it_behaves_like 'returns 200 HTTP status'-it 'returns specified amount resources' doexpect(json_response['data'].count).to eq resources.countend@@ -216,8 +205,6 @@ describe 'Platform API v2 Resources spec', type: :request doshared_examples 'valid request' dobefore { execute }- it_behaves_like 'returns 200 HTTP status'-it 'returns valid JSON' doexpect(json_response['data']).to have_attribute(:firstname).with_value(resource.firstname)expect(json_response['data']).to have_attribute(:lastname).with_value(resource.lastname)@@ -416,8 +403,6 @@ describe 'Platform API v2 Resources spec', type: :request doexpect(json_response['data']).to have_relationship(:state).with_data({ 'id' => another_state.id.to_s, 'type' => 'state' })end-- it_behaves_like 'returns 200 HTTP status'endcontext 'application with full access token' do@@ -496,8 +481,6 @@ describe 'Platform API v2 Resources spec', type: :request dobefore { execute_payment_method }- it_behaves_like 'returns 200 HTTP status'-it 'will not let you remove the current store from the resource' dopayment_method.reloadexpect(payment_method.stores).to match_array([store])@@ -521,8 +504,6 @@ describe 'Platform API v2 Resources spec', type: :request dobefore { execute_payment_method }- it_behaves_like 'returns 200 HTTP status'-it 'will add the stores passed in' dopayment_method.reloadexpect(payment_method.stores).to match_array([store, store_two, store_three])diff --git a/api/spec/requests/spree/api/v2/platform/taxons_spec.rb b/api/spec/requests/spree/api/v2/platform/taxons_spec.rbindex a9d7eb902e..c4f2815a51 100644--- a/api/spec/requests/spree/api/v2/platform/taxons_spec.rb+++ b/api/spec/requests/spree/api/v2/platform/taxons_spec.rb@@ -60,7 +60,6 @@ describe 'Platform API v2 Taxons API' docontext 'when no image transformation params are passed' dolet(:taxon_image_transformation_params) { '' }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns taxon image data'it 'returns taxon image' do@@ -71,7 +70,6 @@ describe 'Platform API v2 Taxons API' docontext 'when taxon image json returned' dolet(:taxon_image_transformation_params) { '&taxon_image_transformation[size]=100x50&taxon_image_transformation[quality]=50' }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns taxon image data'it 'returns taxon image' dodiff --git a/api/spec/requests/spree/api/v2/platform/variants_spec.rb b/api/spec/requests/spree/api/v2/platform/variants_spec.rbindex cbf6f86521..6f9b2fb86a 100644--- a/api/spec/requests/spree/api/v2/platform/variants_spec.rb+++ b/api/spec/requests/spree/api/v2/platform/variants_spec.rb@@ -12,8 +12,6 @@ describe 'API V2 Platform Variants Spec' docontext 'with no params' dobefore { get '/api/v2/platform/variants', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns all variants' doexpect(json_response['data'].count).to eq store.variants.countexpect(json_response['data'].first).to have_type('variant')@@ -66,8 +64,6 @@ describe 'API V2 Platform Variants Spec' docontext 'ascending order' dobefore { get '/api/v2/platform/variants?sort=updated_at', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns variants sorted by updated_at' doexpect(json_response['data'].count).to eq store.variants.countexpect(json_response['data'].pluck(:id)).to eq store.variants.order(:updated_at).map(&:id).map(&:to_s)@@ -77,8 +73,6 @@ describe 'API V2 Platform Variants Spec' docontext 'descending order' dobefore { get '/api/v2/platform/variants?sort=-updated_at', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns variants sorted by updated_at with descending order' doexpect(json_response['data'].count).to eq store.variants.countexpect(json_response['data'].pluck(:id)).to eq store.variants.order(updated_at: :desc).map(&:id).map(&:to_s)@@ -90,8 +84,6 @@ describe 'API V2 Platform Variants Spec' docontext 'ascending order' dobefore { get '/api/v2/platform/variants?sort=created_at', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns variants sorted by created_at' doexpect(json_response['data'].count).to eq store.variants.countexpect(json_response['data'].pluck(:id)).to eq store.variants.order(:created_at).map(&:id).map(&:to_s)@@ -101,8 +93,6 @@ describe 'API V2 Platform Variants Spec' docontext 'descending order' dobefore { get '/api/v2/platform/variants?sort=-created_at', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-it 'returns variants sorted by created_at with descending order' doexpect(json_response['data'].count).to eq store.variants.countexpect(json_response['data'].pluck(:id)).to eq store.variants.order(created_at: :desc).map(&:id).map(&:to_s)@@ -116,18 +106,10 @@ describe 'API V2 Platform Variants Spec' docontext 'when per_page is between 1 and default value' dobefore { get '/api/v2/platform/variants?page=1&per_page=2', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-- it 'returns the default number of variants' do+ it 'returns proper pagination data' doexpect(json_response['data'].count).to eq 2- end-- it 'returns proper meta data' doexpect(json_response['meta']['count']).to eq 2expect(json_response['meta']['total_count']).to eq store.variants.count- end-- it 'returns proper links data' doexpect(json_response['links']['self']).to include('/api/v2/platform/variants?page=1&per_page=2')expect(json_response['links']['next']).to include('/api/v2/platform/variants?page=2&per_page=2')expect(json_response['links']['prev']).to include('/api/v2/platform/variants?page=1&per_page=2')@@ -138,18 +120,10 @@ describe 'API V2 Platform Variants Spec' docontext 'without specified pagination params' dobefore { get '/api/v2/platform/variants', headers: bearer_token }- it_behaves_like 'returns 200 HTTP status'-- it 'returns specified amount variants' do+ it 'returns proper pagination data' doexpect(json_response['data'].count).to eq store.variants.count- end-- it 'returns proper meta data' doexpect(json_response['meta']['count']).to eq json_response['data'].countexpect(json_response['meta']['total_count']).to eq store.variants.count- end-- it 'returns proper links data' doexpect(json_response['links']['self']).to include('/api/v2/platform/variants')expect(json_response['links']['next']).to include('/api/v2/platform/variants?page=1')expect(json_response['links']['prev']).to include('/api/v2/platform/variants?page=1')diff --git a/api/spec/requests/spree/api/v2/platform/webhooks/events_spec.rb b/api/spec/requests/spree/api/v2/platform/webhooks/events_spec.rbindex 959b4ebd36..55e2d78255 100644--- a/api/spec/requests/spree/api/v2/platform/webhooks/events_spec.rb+++ b/api/spec/requests/spree/api/v2/platform/webhooks/events_spec.rb@@ -9,7 +9,7 @@ describe 'Platform API v2 Webhooks Events spec', type: :request dodescribe '#index' docontext 'filtering' do- let(:data_ids) { json_response['data'].pluck(:id) }+ let(:data_ids) { json_response['data'].pluck(:id) }context 'with no params' dobefore do@@ -17,8 +17,6 @@ describe 'Platform API v2 Webhooks Events spec', type: :request doget "/api/v2/platform/webhooks/events", headers: bearer_tokenend- it_behaves_like 'returns 200 HTTP status'-it 'returns all events' doexpect(json_response['data'].count).to eq(2)expect(json_response['data'].first).to have_type(type)diff --git a/api/spec/requests/spree/api/v2/platform/webhooks/subscribers_spec.rb b/api/spec/requests/spree/api/v2/platform/webhooks/subscribers_spec.rbindex a3664c7b68..c2f2973b94 100644--- a/api/spec/requests/spree/api/v2/platform/webhooks/subscribers_spec.rb+++ b/api/spec/requests/spree/api/v2/platform/webhooks/subscribers_spec.rb@@ -18,8 +18,6 @@ describe 'Platform API v2 Webhooks Subscribers spec', type: :request doget "/api/v2/platform/webhooks/subscribers", headers: bearer_tokenend- it_behaves_like 'returns 200 HTTP status'-it 'returns all subscribers' doexpect(json_response['data'].count).to eq(2)expect(json_response['data'].first).to have_type(type)diff --git a/api/spec/requests/spree/api/v2/storefront/account/orders_spec.rb b/api/spec/requests/spree/api/v2/storefront/account/orders_spec.rbindex 876b2b3324..a1ca0295a0 100644--- a/api/spec/requests/spree/api/v2/storefront/account/orders_spec.rb+++ b/api/spec/requests/spree/api/v2/storefront/account/orders_spec.rb@@ -66,8 +66,6 @@ describe 'Storefront API v2 Orders spec', type: :request docontext 'with specified pagination params' dobefore { get '/api/v2/storefront/account/orders?page=1&per_page=2', headers: headers_bearer }- it_behaves_like 'returns 200 HTTP status'-it 'returns specified amount orders' doexpect(json_response['data'].count).to eq 2end@@ -112,8 +110,6 @@ describe 'Storefront API v2 Orders spec', type: :request docontext 'without specified pagination params' dobefore { get '/api/v2/storefront/account/orders', headers: headers_bearer }- it_behaves_like 'returns 200 HTTP status'-it 'returns specified amount orders' doexpect(json_response['data'].count).to eq Spree::Order.countend@@ -140,8 +136,6 @@ describe 'Storefront API v2 Orders spec', type: :request docontext 'ascending order' dobefore { get '/api/v2/storefront/account/orders?sort=completed_at', headers: headers_bearer }- it_behaves_like 'returns 200 HTTP status'-it 'returns orders sorted by completed_at' doexpect(json_response['data'].count).to eq store.orders.countexpect(json_response['data'].pluck(:id)).to eq store.orders.select('*').order(completed_at: :asc).pluck(:id).map(&:to_s)@@ -151,8 +145,6 @@ describe 'Storefront API v2 Orders spec', type: :request docontext 'descending order' dobefore { get '/api/v2/storefront/account/orders?sort=-completed_at', headers: headers_bearer }- it_behaves_like 'returns 200 HTTP status'-it 'returns orders sorted by completed_at' doexpect(json_response['data'].count).to eq store.orders.countexpect(json_response['data'].pluck(:id)).to eq store.orders.select('*').order(completed_at: :desc).pluck(:id).map(&:to_s)@@ -166,8 +158,6 @@ describe 'Storefront API v2 Orders spec', type: :request dobefore { get '/api/v2/storefront/account/orders', headers: headers_bearer }- it_behaves_like 'returns 200 HTTP status'-it 'returns orders sorted by completed_at' doexpect(json_response['data'].count).to eq 1expect(json_response['data'].pluck(:id)).not_to include(order_2.id.to_s)diff --git a/api/spec/requests/spree/api/v2/storefront/account_spec.rb b/api/spec/requests/spree/api/v2/storefront/account_spec.rbindex 3e207e550e..98488b2f70 100644--- a/api/spec/requests/spree/api/v2/storefront/account_spec.rb+++ b/api/spec/requests/spree/api/v2/storefront/account_spec.rb@@ -40,8 +40,6 @@ describe 'Storefront API v2 Account spec', type: :request doget '/api/v2/storefront/account', headers: headersend- it_behaves_like 'returns 200 HTTP status'-it 'return JSON API payload of User and associations (default billing and shipping address)' doexpect(json_response['data']).to have_id(user.id.to_s)expect(json_response['data']).to have_type('user')@@ -111,8 +109,6 @@ describe 'Storefront API v2 Account spec', type: :request dobefore { post "/api/v2/storefront/account", params: params }context 'valid request' do- it_behaves_like 'returns 200 HTTP status'-it 'creates and returns user' docreated_user = Spree.user_class.lastexpect(json_response['data']['id']).to eq created_user.id.to_s@@ -186,8 +182,6 @@ describe 'Storefront API v2 Account spec', type: :request dobefore { patch "/api/v2/storefront/account", params: params, headers: headers }- it_behaves_like 'returns 200 HTTP status'-it 'updates and returns user' doexpect(json_response['data']).to have_id(user.id.to_s)expect(json_response['data']).to have_attribute(:email).with_value(new_attributes[:email])@@ -210,8 +204,6 @@ describe 'Storefront API v2 Account spec', type: :request dobefore { patch "/api/v2/storefront/account", params: params, headers: headers }- it_behaves_like 'returns 200 HTTP status'-it 'updates only email' doexpect(json_response['data']).to have_id(user.id.to_s)expect(json_response['data']).to have_attribute(:email).with_value(new_attributes[:email])diff --git a/api/spec/requests/spree/api/v2/storefront/cart_spec.rb b/api/spec/requests/spree/api/v2/storefront/cart_spec.rbindex 84c8875cf6..c3813eda0e 100644--- a/api/spec/requests/spree/api/v2/storefront/cart_spec.rb+++ b/api/spec/requests/spree/api/v2/storefront/cart_spec.rb@@ -11,9 +11,8 @@ describe 'API V2 Storefront Cart Spec', type: :request doinclude_context 'API v2 tokens'shared_examples 'coupon code error' do- it_behaves_like 'returns 422 HTTP status'-it 'returns an error' do+ expect(response.status).to eq(422)expect(json_response[:error]).to eq("The coupon code you entered doesn't exist. Please try again.")endend@@ -183,7 +182,6 @@ describe 'API V2 Storefront Cart Spec', type: :request doshared_examples 'adds item' dobefore { execute }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'with success' do@@ -215,9 +213,8 @@ describe 'API V2 Storefront Cart Spec', type: :request doexecuteend- it_behaves_like 'returns 422 HTTP status'-it 'returns an error' do+ expect(response.status).to eq(422)expect(json_response[:error]).to eq("Quantity selected of \"#{variant.name} (#{variant.options_text})\" is not available.")endend@@ -228,9 +225,8 @@ describe 'API V2 Storefront Cart Spec', type: :request doexecuteend- it_behaves_like 'returns 404 HTTP status'-it 'returns an error' do+ expect(response.status).to eq(404)expect(json_response[:error]).to eq('The resource you were looking for could not be found.')endend@@ -241,9 +237,8 @@ describe 'API V2 Storefront Cart Spec', type: :request doexecuteend- it_behaves_like 'returns 404 HTTP status'-it 'returns an error' do+ expect(response.status).to eq(404)expect(json_response[:error]).to eq('The resource you were looking for could not be found.')endend@@ -254,9 +249,8 @@ describe 'API V2 Storefront Cart Spec', type: :request doexecuteend- it_behaves_like 'returns 422 HTTP status'-it 'return an error' do+ expect(response.status).to eq(422)expect(json_response[:error]).to eq(I18n.t(:invalid_params, scope: 'spree.api.v2.metadata'))endend@@ -322,7 +316,6 @@ describe 'API V2 Storefront Cart Spec', type: :request docontext 'containing line item' dolet!(:line_item) { create(:line_item, order: order) }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'removes line item from the cart' do@@ -358,7 +351,6 @@ describe 'API V2 Storefront Cart Spec', type: :request doshared_examples 'emptying the order' dobefore { execute }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'empties the order' do@@ -429,9 +421,8 @@ describe 'API V2 Storefront Cart Spec', type: :request dolet(:execute) { patch '/api/v2/storefront/cart/set_quantity', params: params, headers: headers }shared_examples 'wrong quantity parameter' do- it_behaves_like 'returns 422 HTTP status'-it 'returns an error' do+ expect(response.status).to eq(422)expect(json_response[:error]).to eq('Quantity has to be greater than 0')endend@@ -452,9 +443,8 @@ describe 'API V2 Storefront Cart Spec', type: :request doexecuteend- it_behaves_like 'returns 422 HTTP status'-it 'returns an error' do+ expect(response.status).to eq(422)expect(json_response[:error]).to eq("Quantity selected of \"#{line_item.name}\" is not available.")endend@@ -462,7 +452,6 @@ describe 'API V2 Storefront Cart Spec', type: :request docontext 'changes the quantity of line item' dobefore { execute }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'successfully changes the quantity' do@@ -512,7 +501,6 @@ describe 'API V2 Storefront Cart Spec', type: :request doget '/api/v2/storefront/cart', headers: headers, params: paramsend- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'end@@ -661,7 +649,6 @@ describe 'API V2 Storefront Cart Spec', type: :request dolet(:adjustment_value_in_money) { Spree::Money.new(adjustment_value, currency: order.currency) }context 'applies coupon code correctly' do- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'changes the adjustment total' do@@ -735,7 +722,6 @@ describe 'API V2 Storefront Cart Spec', type: :request docontext 'removes coupon code correctly' dobefore { execute }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'changes the adjustment total to 0.0' do@@ -816,7 +802,6 @@ describe 'API V2 Storefront Cart Spec', type: :request dobefore { execute }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'changes the adjustment total to 0.0' do@@ -930,8 +915,6 @@ describe 'API V2 Storefront Cart Spec', type: :request doexecuteend- it_behaves_like 'returns 200 HTTP status'-it 'returns valid shipments JSON' do[{ shipping_method: shipping_method, shipping_rate: shipping_rate }, { shipping_method: shipping_method_2, shipping_rate: shipping_rate_2 }].each do |shipping|expect(json_response['data']).to include(have_type('shipping_rate').and(have_attribute(:name).with_value(shipping[:shipping_method].name)))diff --git a/api/spec/requests/spree/api/v2/storefront/checkout_spec.rb b/api/spec/requests/spree/api/v2/storefront/checkout_spec.rbindex e6fe99d256..6568717a6e 100644--- a/api/spec/requests/spree/api/v2/storefront/checkout_spec.rb+++ b/api/spec/requests/spree/api/v2/storefront/checkout_spec.rb@@ -58,9 +58,8 @@ describe 'API V2 Storefront Checkout Spec', type: :request doexecuteend- it_behaves_like 'returns 422 HTTP status'-it 'cannot transition to address without a line item' do+ expect(response.status).to eq(422)expect(json_response['error']).to include(I18n.t('spree.there_are_no_items_for_this_order'))endend@@ -68,7 +67,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request docontext 'with line_items and email' dobefore { execute }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'can transition an order to the next state' do@@ -83,9 +81,8 @@ describe 'API V2 Storefront Checkout Spec', type: :request doexecuteend- it_behaves_like 'returns 422 HTTP status'-it 'returns an error' do+ expect(response.status).to eq(422)expect(json_response['error']).to include(I18n.t('spree.no_payment_found'))end@@ -121,7 +118,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request doexecuteend- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'advances an order till complete or confirm step' do@@ -138,7 +134,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request doexecuteend- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'advances up to the payment state' do@@ -151,9 +146,8 @@ describe 'API V2 Storefront Checkout Spec', type: :request dobefore { execute }- it_behaves_like 'returns 422 HTTP status'-it 'advances up to the payment state' do+ expect(response.status).to eq(422)expect(order.reload.state).to eq('payment')end@@ -165,13 +159,12 @@ describe 'API V2 Storefront Checkout Spec', type: :request docontext 'when on payment state' dolet(:order_state) { 'payment' }- it_behaves_like 'returns 422 HTTP status'-it 'advances up to the payment state' doexpect(order.reload.state).to eq('payment')endit 'responds with an error' do+ expect(response.status).to eq(422)expect(json_response['error']).to eq(Spree.t(:no_payment_found))endend@@ -232,7 +225,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request doexecuteend- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'completes an order' do@@ -245,16 +237,10 @@ describe 'API V2 Storefront Checkout Spec', type: :request docontext 'without payment data' dobefore { execute }- it_behaves_like 'returns 422 HTTP status'-it 'returns an error' do+ expect(response.status).to eq(422)expect(json_response['error']).to include(I18n.t('spree.no_payment_found'))end-- it 'doesnt completes an order' do- expect(order.reload.state).not_to eq('complete')- expect(order.completed_at).to be_nil- endendit_behaves_like 'no current order'@@ -310,7 +296,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request dobefore { execute }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'updates addresses' do@@ -350,7 +335,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request doexecuteend- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'updates shipment' do@@ -378,7 +362,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request dobefore { execute }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'updates payment method' do@@ -392,7 +375,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request dobefore { execute }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'updates payment method with source' do@@ -425,7 +407,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request dobefore { execute }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'updates the special instructions' do@@ -448,7 +429,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request dobefore { execute }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'it 'updates email' do@@ -474,9 +454,8 @@ describe 'API V2 Storefront Checkout Spec', type: :request doexecuteend- it_behaves_like 'returns 422 HTTP status'-it 'returns an error' do+ expect(response.status).to eq(422)expect(json_response['error']).to eq('Email is invalid')end@@ -536,7 +515,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request doendcontext 'with no amount param' do- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'valid payload', 500.0end@@ -544,7 +522,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request dolet(:requested_amount) { 300.0 }let(:params) { { order_token: order.token, amount: requested_amount } }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'valid payload', 300.0end@@ -597,8 +574,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request doexecuteend- it_behaves_like 'returns 200 HTTP status'-it 'returns no valid StoreCredit payment' doexpect(json_response['included'].empty?).to eq trueend@@ -612,8 +587,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request doshared_examples 'returns a list of available payment methods' dobefore { execute }- it_behaves_like 'returns 200 HTTP status'-it 'returns valid payment methods JSON' doexpect(json_response['data']).not_to be_emptyexpect(json_response['data'][0]).to have_id(payment_method.id.to_s)@@ -661,9 +634,8 @@ describe 'API V2 Storefront Checkout Spec', type: :request doshared_examples 'creates a payment' dobefore { execute }- it_behaves_like 'returns 201 HTTP status'-it 'returns new payment' do+ expect(response.status).to eq(201)expect(json_response['data']).to have_relationship(:payments).with_data([{ 'id' => payment.id.to_s, 'type' => 'payment' }])expect(json_response['included'][0]).to have_id(payment.id.to_s)expect(json_response['included'][0]).to have_type('payment')@@ -671,10 +643,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request doexpect(json_response['included'][0]).to have_jsonapi_attributes(:amount, :response_code, :number, :cvv_response_code, :cvv_response_message, :payment_method_id, :payment_method_name, :state)expect(json_response['included'][0]).to have_relationship(:payment_method).with_data({ 'id' => payment_method.id.to_s, 'type' => 'payment_method' })end-- it 'creates new payment record' do- expect { change(order.payments, :count).by(1) }- endendshared_examples 'creates a payment source' do@@ -761,8 +729,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request doorder.reloadend- it_behaves_like 'returns 200 HTTP status'-it 'returns valid shipments JSON' doexpect(json_response['data']).not_to be_emptyexpect(json_response['data'].size).to eq(order.shipments.count)@@ -849,8 +815,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request docontext 'valid shipping method' dobefore { execute }- it_behaves_like 'returns 200 HTTP status'-it 'sets selected shipping method for shipment' doexpect(json_response['included'][0]).to have_id(shipment.id.to_s)expect(json_response['included'][0]).to have_type('shipment')@@ -1056,7 +1020,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request dopost '/api/v2/storefront/checkout/validate_order_for_payment', headers: headersend- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'enddiff --git a/api/spec/requests/spree/api/v2/storefront/cms_pages_spec.rb b/api/spec/requests/spree/api/v2/storefront/cms_pages_spec.rbindex 7da3a3d078..a7a06d6007 100644--- a/api/spec/requests/spree/api/v2/storefront/cms_pages_spec.rb+++ b/api/spec/requests/spree/api/v2/storefront/cms_pages_spec.rb@@ -35,7 +35,6 @@ describe 'Storefront API v2 CMS Pages spec', type: :request docontext 'with no params' dobefore { get '/api/v2/storefront/cms_pages' }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns proper JSON structure'it 'returns all pages for the current store and locale' do@@ -48,7 +47,6 @@ describe 'Storefront API v2 CMS Pages spec', type: :request dobefore { get '/api/v2/storefront/cms_pages?locale=fr' }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns proper JSON structure'it 'returns all pages for the current store and specified locale' do@@ -60,8 +58,6 @@ describe 'Storefront API v2 CMS Pages spec', type: :request doshared_examples 'returns proper records' dobefore { get "/api/v2/storefront/cms_pages?filter[type]=#{kind}" }- it_behaves_like 'returns 200 HTTP status'-it 'returns pages for the current store and specified kind' doexpect(json_response['data'].pluck(:id)).to contain_exactly(page.id.to_s)end@@ -91,8 +87,6 @@ describe 'Storefront API v2 CMS Pages spec', type: :request docontext 'non-existing type' dobefore { get '/api/v2/storefront/cms_pages?filter[type]=non-existing' }- it_behaves_like 'returns 200 HTTP status'-it 'returns all records' doexpect(json_response['data'].pluck(:id)).to contain_exactly(home_en.id.to_s, standard_en.id.to_s)end@@ -102,8 +96,6 @@ describe 'Storefront API v2 CMS Pages spec', type: :request docontext 'filtering by title' dobefore { get '/api/v2/storefront/cms_pages?filter[title]=about' }- it_behaves_like 'returns 200 HTTP status'-it 'returns page with title containing the query' doexpect(json_response['data'].pluck(:id)).to contain_exactly(standard_en.id.to_s)end@@ -116,7 +108,6 @@ describe 'Storefront API v2 CMS Pages spec', type: :request dobefore { get '/api/v2/storefront/cms_pages?include=cms_sections.linked_resource' }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns proper JSON structure'it 'returns sections and their associations' do@@ -148,8 +139,6 @@ describe 'Storefront API v2 CMS Pages spec', type: :request dobefore { get "/api/v2/storefront/cms_pages/#{page.id}?include=cms_sections.linked_resource" }- it_behaves_like 'returns 200 HTTP status'-it 'returns page attributes and relationships' doexpect(json_response['data']['id']).to eq(page.id.to_s)expect(json_response['data']['attributes']['title']).to eq page.titlediff --git a/api/spec/requests/spree/api/v2/storefront/countries_spec.rb b/api/spec/requests/spree/api/v2/storefront/countries_spec.rbindex bc1a8d8d87..318dd75a7c 100644--- a/api/spec/requests/spree/api/v2/storefront/countries_spec.rb+++ b/api/spec/requests/spree/api/v2/storefront/countries_spec.rb@@ -29,8 +29,6 @@ describe 'Storefront API v2 Countries spec', type: :request dobefore { get '/api/v2/storefront/countries' }- it_behaves_like 'returns 200 HTTP status'-it 'returns all countries' doexpect(json_response['data'].size).to eq(240)expect(json_response['data'][0]).to have_type('country')@@ -115,27 +113,9 @@ describe 'Storefront API v2 Countries spec', type: :request doendend- context 'when different current store' do- let!(:second_country) { create(:country) }- let!(:second_store) { create(:store, name: 'Second Store', default_country: second_country) }-- before do- allow_any_instance_of(Spree::Api::V2::Storefront::CountriesController).to receive(:current_store).and_return(second_store)- get '/api/v2/storefront/countries/default'- end-- it 'should return second_country' do- expect(json_response['data']).to have_id(second_country.id.to_s)- expect(json_response['data']).to have_attribute(:iso).with_value(second_country.iso)- expect(json_response['data']).to have_attribute(:default).with_value(true)- end- end-context 'with specified options' dobefore { get "/api/v2/storefront/countries/#{country.iso}?include=states" }- it_behaves_like 'returns 200 HTTP status'-it 'returns country with included states' doexpect(json_response['data']).to have_id(country.id.to_s)expect(json_response['included']).to include(have_type('state').and(have_attribute(:abbr).with_value(states.first.abbr)))diff --git a/api/spec/requests/spree/api/v2/storefront/menus_spec.rb b/api/spec/requests/spree/api/v2/storefront/menus_spec.rbindex 2b8ff4eca5..997b1c267a 100644--- a/api/spec/requests/spree/api/v2/storefront/menus_spec.rb+++ b/api/spec/requests/spree/api/v2/storefront/menus_spec.rb@@ -29,7 +29,6 @@ describe 'Storefront API v2 Menus spec', type: :request docontext 'with no params' dobefore { get '/api/v2/storefront/menus' }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns proper JSON structure'it 'returns all menus for the current store and locale' do@@ -42,7 +41,6 @@ describe 'Storefront API v2 Menus spec', type: :request dobefore { get '/api/v2/storefront/menus?locale=fr' }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns proper JSON structure'it 'returns all menus for the current store and specified locale' do@@ -66,7 +64,6 @@ describe 'Storefront API v2 Menus spec', type: :request dobefore { get '/api/v2/storefront/menus?include=menu_items.linked_resource' }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns proper JSON structure'it 'returns menu items and their associations' do@@ -84,8 +81,6 @@ describe 'Storefront API v2 Menus spec', type: :request docontext 'filtering by location' dobefore { get '/api/v2/storefront/menus?filter[location]=header' }- it_behaves_like 'returns 200 HTTP status'-it 'returns menus for the current store and specified location' doexpect(json_response['data'].pluck(:id)).to contain_exactly(header_en.id.to_s)end@@ -102,8 +97,6 @@ describe 'Storefront API v2 Menus spec', type: :request dobefore { get "/api/v2/storefront/menus/#{menu.id}?include=menu_items.linked_resource" }- it_behaves_like 'returns 200 HTTP status'-it 'returns menu attributes and relationships' doexpect(json_response['data']['id']).to eq(menu.id.to_s)expect(json_response['data']['attributes']['name']).to eq menu.namediff --git a/api/spec/requests/spree/api/v2/storefront/order_status_spec.rb b/api/spec/requests/spree/api/v2/storefront/order_status_spec.rbindex 77398e91b9..baaac43eed 100644--- a/api/spec/requests/spree/api/v2/storefront/order_status_spec.rb+++ b/api/spec/requests/spree/api/v2/storefront/order_status_spec.rb@@ -35,7 +35,6 @@ describe 'Storefront API v2 OrderStatus spec', type: :request docontext 'as a guest user with valid token' dobefore { get "/api/v2/storefront/order_status/#{order.number}", headers: headers_order_token }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns valid cart JSON'endenddiff --git a/api/spec/requests/spree/api/v2/storefront/products_spec.rb b/api/spec/requests/spree/api/v2/storefront/products_spec.rbindex 1dd5c1f7e7..2d8084ad06 100644--- a/api/spec/requests/spree/api/v2/storefront/products_spec.rb+++ b/api/spec/requests/spree/api/v2/storefront/products_spec.rb@@ -36,8 +36,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'with no params' dobefore { get '/api/v2/storefront/products' }- it_behaves_like 'returns 200 HTTP status'-it 'returns all products' doexpect(json_response['data'].count).to eq store.products.available.countexpect(json_response['data'].first).to have_type('product')@@ -105,8 +103,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'with specified ids' dobefore { get "/api/v2/storefront/products?filter[ids]=#{products.first.id}" }- it_behaves_like 'returns 200 HTTP status'-it 'returns products with specified ids' doexpect(json_response['data'].count).to eq 1expect(json_response['data'].first).to have_id(products.first.id.to_s)@@ -116,8 +112,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'with specified skus' dobefore { get "/api/v2/storefront/products?filter[skus]=#{products.first.default_variant.sku}" }- it_behaves_like 'returns 200 HTTP status'-it 'returns products with specified ids' doexpect(json_response['data'].count).to eq 1expect(json_response['data'].first).to have_id(products.first.id.to_s)@@ -127,8 +121,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'with specified price range' dobefore { get "/api/v2/storefront/products?filter[price]=#{product_with_price.price.to_f},#{product_with_price.price.to_f + 0.04}" }- it_behaves_like 'returns 200 HTTP status'-it 'returns products with specified price' doexpect(json_response['data'].first).to have_id(product_with_price.id.to_s)expect(json_response['data'].first).to have_attribute(:price).with_value(product_with_price.price.to_f.to_s)@@ -138,8 +130,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'with specified taxon_ids' dobefore { get "/api/v2/storefront/products?filter[taxons]=#{product_with_taxon.taxons.first.id}" }- it_behaves_like 'returns 200 HTTP status'-it 'returns products with specified taxons' doexpect(json_response['data'].first).to have_id(product_with_taxon.id.to_s)end@@ -148,8 +138,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'with specified name' dobefore { get "/api/v2/storefront/products?filter[name]=#{product_with_name.name}" }- it_behaves_like 'returns 200 HTTP status'-it 'returns products with specified name' doexpect(json_response['data'].first).to have_id(product_with_name.id.to_s)expect(json_response['data'].first).to have_attribute(:name).with_value(product_with_name.name)@@ -162,8 +150,6 @@ describe 'API V2 Storefront Products Spec', type: :request doget "/api/v2/storefront/products?filter[options][#{option_type.name}]=#{option_value.name}&include=option_types,variants.option_values"end- it_behaves_like 'returns 200 HTTP status'-it 'returns products with specified options' doexpect(json_response['data'].first).to have_id(product_with_option.id.to_s)expect(json_response['included']).to include(have_type('option_type').and(have_attribute(:name).with_value(option_type.name)))@@ -250,8 +236,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'when filtering by tag_1/tag_2 tags' dolet(:tags_list) { 'tag_1,tag_2' }- it_behaves_like 'returns 200 HTTP status'-it 'returns products with specified tags' doexpect(json_response['data']).to include(have_id(product_1.id.to_s))expect(json_response['data']).to include(have_id(product_2.id.to_s))@@ -262,8 +246,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'when filtering by tag_2/tag_3 tags' dolet(:tags_list) { 'tag_2,tag_3' }- it_behaves_like 'returns 200 HTTP status'-it 'returns products with specified tags' doexpect(json_response['data']).to include(have_id(product_1.id.to_s))expect(json_response['data']).to include(have_id(product_2.id.to_s))@@ -274,8 +256,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'when filtering by tag_3 tags' dolet(:tags_list) { 'tag_3' }- it_behaves_like 'returns 200 HTTP status'-it 'returns products with specified tags' doexpect(json_response['data']).not_to include(have_id(product_1.id.to_s))expect(json_response['data']).not_to include(have_id(product_2.id.to_s))@@ -286,8 +266,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'when filtering by non-existent tags' dolet(:tags_list) { 'tag_4,tag5' }- it_behaves_like 'returns 200 HTTP status'-it 'returns products with specified tags' doexpect(json_response['data']).not_to include(have_id(product_1.id.to_s))expect(json_response['data']).not_to include(have_id(product_2.id.to_s))@@ -322,8 +300,6 @@ describe 'API V2 Storefront Products Spec', type: :request dobefore { get "/api/v2/storefront/products?#{options_filter}&include=option_types,variants.option_values" }- it_behaves_like 'returns 200 HTTP status'-it 'returns products with specified options' doexpect(json_response['data']).to include(have_id(product_1.id.to_s))expect(json_response['data']).not_to include(have_id(product_2.id.to_s))@@ -346,8 +322,6 @@ describe 'API V2 Storefront Products Spec', type: :request dobefore { get "/api/v2/storefront/products?#{options_filter}&include=option_types,variants.option_values" }- it_behaves_like 'returns 200 HTTP status'-it 'returns no products' doexpect(json_response['data']).to be_emptyend@@ -359,8 +333,6 @@ describe 'API V2 Storefront Products Spec', type: :request doxcontext 'using proper filter params' dobefore { get "/api/v2/storefront/products?filter[properties][#{property.filter_param}]=#{product_property.filter_param}&include=product_properties" }- it_behaves_like 'returns 200 HTTP status'-it 'returns products with specified properties' doexpect(json_response['data'].first).to have_id(product_with_property.id.to_s)expect(json_response['included']).to include(have_type('product_property').and(have_attribute(:name).with_value(property.name)))@@ -374,8 +346,6 @@ describe 'API V2 Storefront Products Spec', type: :request doxcontext 'using property names and values' dobefore { get "/api/v2/storefront/products?filter[properties][#{property.name}]=#{product_property.value}&include=product_properties" }- it_behaves_like 'returns 200 HTTP status'-it 'returns products with specified properties' doexpect(json_response['data'].first).to have_id(product_with_property.id.to_s)end@@ -439,8 +409,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'with specified multiple filters' dobefore { get "/api/v2/storefront/products?filter[name]=#{product_with_name.name}&filter[price]=#{product_with_name.price.to_f - 0.02},#{product_with_name.price.to_f + 0.02}" }- it_behaves_like 'returns 200 HTTP status'-it 'returns products with specified name and price' doexpect(json_response['data'].count).to eq 1expect(json_response['data'].first).to have_id(product_with_name.id.to_s)@@ -450,8 +418,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'with included deleted' dobefore { get '/api/v2/storefront/products?filter[show_deleted]=true' }- it_behaves_like 'returns 200 HTTP status'-it 'returns products with deleted products' doexpect(json_response['data'].count).to eq 10expect(json_response['data'].pluck(:id)).to include(deleted_product.id.to_s)@@ -461,8 +427,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'with included discontinued' dobefore { get '/api/v2/storefront/products?filter[show_discontinued]=true' }- it_behaves_like 'returns 200 HTTP status'-it 'returns products with discontinued products' doexpect(json_response['data'].count).to eq 11expect(json_response['data'].pluck(:id)).to include(discontinued_product.id.to_s)@@ -474,8 +438,6 @@ describe 'API V2 Storefront Products Spec', type: :request doget '/api/v2/storefront/products?filter[show_deleted]=true&filter[show_discontinued]=true'end- it_behaves_like 'returns 200 HTTP status'-it 'returns available, deleted and discontinued products' doexpect(json_response['data'].count).to eq 12expect(json_response['data'].pluck(:id)).to include(deleted_product.id.to_s, discontinued_product.id.to_s)@@ -487,8 +449,6 @@ describe 'API V2 Storefront Products Spec', type: :request doget '/api/v2/storefront/products?filter[in_stock]=true'end- it_behaves_like 'returns 200 HTTP status'-it 'returns products in stock' doexpect(json_response['data'].count).to eq 2expect(json_response['data'].pluck(:id)).to include(in_stock_product.id.to_s, not_backorderable_product.id.to_s)@@ -500,8 +460,6 @@ describe 'API V2 Storefront Products Spec', type: :request doget '/api/v2/storefront/products?filter[backorderable]=true'end- it_behaves_like 'returns 200 HTTP status'-it 'returns products in stock' doexpect(json_response['data'].count).to eq 8expect(json_response['data'].pluck(:id)).not_to include(not_backorderable_product.id.to_s)@@ -513,8 +471,6 @@ describe 'API V2 Storefront Products Spec', type: :request doget '/api/v2/storefront/products?filter[purchasable]=true'end- it_behaves_like 'returns 200 HTTP status'-it 'returns only purchasable products' doexpect(json_response['data'].count).to eq 9expect(json_response['data'].pluck(:id)).to include(in_stock_product.id.to_s, not_backorderable_product.id.to_s)@@ -526,8 +482,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'ascending order' dobefore { get '/api/v2/storefront/products?sort=price' }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by price' doexpect(json_response['data'].count).to eq store.products.available.countexpect(json_response['data'].pluck(:id)).to eq store.products.available.joins(master: :prices).select("#{store.products.table_name}.*, #{Spree::Price.table_name}.amount").distinct.order("#{Spree::Price.table_name}.amount").map(&:id).map(&:to_s)@@ -537,8 +491,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'descending order' dobefore { get '/api/v2/storefront/products?sort=-price' }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by price with descending order' doexpect(json_response['data'].count).to eq store.products.available.countexpect(json_response['data'].pluck(:id)).to eq store.products.available.joins(master: :prices).select("#{store.products.table_name}.*, #{Spree::Price.table_name}.amount").distinct.order("#{Spree::Price.table_name}.amount DESC").map(&:id).map(&:to_s)@@ -555,8 +507,6 @@ describe 'API V2 Storefront Products Spec', type: :request dobefore { get request_path }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by name' doexpect(json_response['data'].count).to eq store.products.available.countexpect(json_response['data'].pluck(:id)).to eq store.products.i18n.available.order(:name).map(&:id).map(&:to_s)@@ -565,8 +515,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'when using another locale' dolet(:request_path) { '/api/v2/storefront/products?sort=name&locale=pl' }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by name' doexpect(json_response['data'].count).to eq store.products.available.countexpect(json_response['data'].pluck(:id)).to eq store.products.i18n.available.@@ -581,8 +529,6 @@ describe 'API V2 Storefront Products Spec', type: :request dobefore { get request_path }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by name with descending order' doexpect(json_response['data'].count).to eq store.products.available.countexpect(json_response['data'].pluck(:id)).to eq store.products.available.order(name: :desc).map(&:id).map(&:to_s)@@ -591,8 +537,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'when using another locale' dolet(:request_path) { '/api/v2/storefront/products?sort=-name&locale=pl' }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by name' doexpect(json_response['data'].count).to eq store.products.available.countexpect(json_response['data'].pluck(:id)).to eq store.products.available.@@ -607,8 +551,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'ascending order' dobefore { get '/api/v2/storefront/products?sort=updated_at' }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by updated_at' doexpect(json_response['data'].count).to eq store.products.available.countexpect(json_response['data'].pluck(:id)).to eq store.products.available.order(:updated_at).map(&:id).map(&:to_s)@@ -618,8 +560,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'descending order' dobefore { get '/api/v2/storefront/products?sort=-updated_at' }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by updated_at with descending order' doexpect(json_response['data'].count).to eq store.products.available.countexpect(json_response['data'].pluck(:id)).to eq store.products.available.order(updated_at: :desc).map(&:id).map(&:to_s)@@ -631,8 +571,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'ascending order' dobefore { get '/api/v2/storefront/products?sort=created_at' }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by created_at' doexpect(json_response['data'].count).to eq store.products.available.countexpect(json_response['data'].pluck(:id)).to eq store.products.available.order(:created_at).map(&:id).map(&:to_s)@@ -642,8 +580,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'descending order' dobefore { get '/api/v2/storefront/products?sort=-created_at' }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by created_at with descending order' doexpect(json_response['data'].count).to eq store.products.available.countexpect(json_response['data'].pluck(:id)).to eq store.products.available.order(created_at: :desc).map(&:id).map(&:to_s)@@ -657,8 +593,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'ascending order' dobefore { get '/api/v2/storefront/products?sort=available_on' }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by available_on' doexpect(json_response['data'].count).to eq store.products.available.countexpect(json_response['data'].pluck(:id)).to eq store.products.available.order(:available_on).map(&:id).map(&:to_s)@@ -668,8 +602,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'descending order' dobefore { get '/api/v2/storefront/products?sort=-available_on' }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by available_on with descending order' doexpect(json_response['data'].count).to eq store.products.available.countexpect(json_response['data'].pluck(:id)).to eq store.products.available.order(available_on: :desc).map(&:id).map(&:to_s)@@ -681,8 +613,6 @@ describe 'API V2 Storefront Products Spec', type: :request doshared_examples 'returning products in ascending sku order' dobefore { get "/api/v2/storefront/products?sort=sku#{params}" }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by master variant sku' doexpect(skus_array).to eq(skus_array.sort)expect(json_response['data'].count).to eq(store.products.available.count)@@ -693,8 +623,6 @@ describe 'API V2 Storefront Products Spec', type: :request doshared_examples 'returning products in descending sku order' dobefore { get "/api/v2/storefront/products?sort=-sku#{params}" }- it_behaves_like 'returns 200 HTTP status'-it 'returns products sorted by master variant sku with descending order' doexpect(skus_array).to eq(skus_array.sort.reverse)expect(json_response['data'].count).to eq(store.products.available.count)@@ -740,14 +668,14 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'when sku sort order direction is ascending' dobefore { get "/api/v2/storefront/products?sort=sku#{params}" }- it_behaves_like 'returns 200 HTTP status'+it_behaves_like 'returns products in ascending updated_at order'endcontext 'when sku sort order direction is descending' dobefore { get "/api/v2/storefront/products?sort=-sku#{params}" }- it_behaves_like 'returns 200 HTTP status'+it_behaves_like 'returns products in ascending updated_at order'endend@@ -759,8 +687,6 @@ describe 'API V2 Storefront Products Spec', type: :request dobefore { get '/api/v2/storefront/products?sort=-sku,price' }- it_behaves_like 'returns 200 HTTP status'-it doexpect(skus_array).to eq(skus_array.sort.reverse)expect(json_response['data'].count).to eq(store.products.available.count)@@ -773,8 +699,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'when per_page is between 1 and default value' dobefore { get '/api/v2/storefront/products?page=1&per_page=2' }- it_behaves_like 'returns 200 HTTP status'-it 'returns the default number of products' doexpect(json_response['data'].count).to eq 2end@@ -819,8 +743,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'without specified pagination params' dobefore { get '/api/v2/storefront/products' }- it_behaves_like 'returns 200 HTTP status'-it 'returns specified amount products' doexpect(json_response['data'].count).to eq store.products.available.countend@@ -1074,7 +996,7 @@ describe 'API V2 Storefront Products Spec', type: :request do'&sort=-updated_at,price,-name,created_at,-available_on,sku'end- it_behaves_like 'returns 200 HTTP status'+endend@@ -1082,7 +1004,7 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'with supported currency param' dobefore { get "/api/v2/storefront/products/#{product.slug}?currency=USD" }- it_behaves_like 'returns 200 HTTP status'+it 'return product with supported currency' doexpect(json_response['data']).not_to be_empty@@ -1097,8 +1019,6 @@ describe 'API V2 Storefront Products Spec', type: :request doget "/api/v2/storefront/products/#{product.slug}?currency=EUR&include=default_variant"end- it_behaves_like 'returns 200 HTTP status'-it 'returns empty prices' doexpect(json_response['data']).not_to be_emptyexpect(json_response['data']['id']).to eq(product.id.to_s)@@ -1136,8 +1056,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'with existing product' dobefore { get "/api/v2/storefront/products/#{product.slug}" }- it_behaves_like 'returns 200 HTTP status'-it 'returns a valid JSON response' doexpect(json_response['data']).to have_id(product.id.to_s)@@ -1238,8 +1156,6 @@ describe 'API V2 Storefront Products Spec', type: :request doget "/api/v2/storefront/products/#{old_slug}"end- it_behaves_like 'returns 200 HTTP status'-it 'still finds the product' doexpect(json_response['data']['id']).to eq(product.id.to_s)end@@ -1262,7 +1178,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'when no image transformation params are passed' dolet(:image_transformation_params) { '' }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns product image data'it 'returns product image' do@@ -1273,7 +1188,6 @@ describe 'API V2 Storefront Products Spec', type: :request docontext 'when product image json returned' dolet(:image_transformation_params) { '&image_transformation[size]=100x50&image_transformation[quality]=50' }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns product image data'it 'returns product image' dodiff --git a/api/spec/requests/spree/api/v2/storefront/taxons_spec.rb b/api/spec/requests/spree/api/v2/storefront/taxons_spec.rbindex c77aafa007..835b1991b1 100644--- a/api/spec/requests/spree/api/v2/storefront/taxons_spec.rb+++ b/api/spec/requests/spree/api/v2/storefront/taxons_spec.rb@@ -5,9 +5,6 @@ describe 'Taxons Spec', type: :request dolet!(:taxonomy) { store.taxonomies.first }let!(:taxons) { create_list(:taxon, 2, taxonomy: taxonomy, parent: taxonomy.root) }- let(:store2) { create(:store)}- let!(:taxonomy2) { create(:taxonomy, store: store2) }-before dostore.update_column(:supported_locales, 'en,pl,es')Spree::Api::Config[:api_v2_per_page_limit] = 2@@ -28,18 +25,12 @@ describe 'Taxons Spec', type: :request docontext 'with no params' dobefore { get '/api/v2/storefront/taxons' }- it_behaves_like 'returns 200 HTTP status'-it 'returns all taxons' doexpect(json_response['data'].size).to eq(store.taxons.count)expect(json_response['data'][0]).to have_type('taxon')expect(json_response['data'][0]).to have_relationships(:parent, :taxonomy, :children, :image)expect(json_response['data'][0]).not_to have_relationships(:produts)end-- it 'should return only default store taxons' do- expect(json_response['data'].map{ |t| t['id'] }).to contain_exactly(*store.taxons.pluck(:id).map(&:to_s))- endendcontext 'with locale set to pl' do@@ -76,8 +67,6 @@ describe 'Taxons Spec', type: :request dobefore { get '/api/v2/storefront/taxons?locale=pl' }- it_behaves_like 'returns 200 HTTP status'-# FIXME: this test fails on CI but works locallyxit 'returns all taxons' doexpect(json_response['data'].size).to eq(3)@@ -99,8 +88,6 @@ describe 'Taxons Spec', type: :request docontext 'by roots' dobefore { get '/api/v2/storefront/taxons?filter[roots]=true' }- it_behaves_like 'returns 200 HTTP status'-it 'returns taxons by roots' doexpect(json_response['data'].size).to eq(store.taxons.where(parent: nil).count)expect(json_response['data'][0]).to have_type('taxon')@@ -113,8 +100,6 @@ describe 'Taxons Spec', type: :request docontext 'by parent' dobefore { get "/api/v2/storefront/taxons?filter[parent_id]=#{taxonomy.root.id}" }- it_behaves_like 'returns 200 HTTP status'-it 'returns children taxons by parent' doexpect(json_response['data'].size).to eq(2)expect(json_response['data'][0]).to have_relationship(:parent).with_data('id' => taxonomy.root.id.to_s, 'type' => 'taxon')@@ -142,8 +127,6 @@ describe 'Taxons Spec', type: :request doget request_pathend- it_behaves_like 'returns 200 HTTP status'-it 'returns children taxons by parent' doexpect(json_response['data'].size).to eq(2)expect(json_response['data'][0]).to have_relationship(:parent).with_data('id' => taxonomy.root.id.to_s, 'type' => 'taxon')@@ -153,8 +136,6 @@ describe 'Taxons Spec', type: :request docontext 'with another locale' dolet(:request_path) { "/api/v2/storefront/taxons?filter[parent_permalink]=#{taxonomy.root.permalink_pl}&locale=pl" }- it_behaves_like 'returns 200 HTTP status'-it 'returns children taxons by parent' doexpect(json_response['data'].size).to eq(2)@@ -170,8 +151,6 @@ describe 'Taxons Spec', type: :request docontext 'by taxonomy' dobefore { get "/api/v2/storefront/taxons?filter[taxonomy_id]=#{taxonomy.id}" }- it_behaves_like 'returns 200 HTTP status'-it 'returns taxons by taxonomy' doexpect(json_response['data'].size).to eq(taxonomy.taxons.count)expect(json_response['data'][0]).to have_relationship(:taxonomy).with_data('id' => taxonomy.id.to_s, 'type' => 'taxonomy')@@ -183,8 +162,6 @@ describe 'Taxons Spec', type: :request docontext 'by ids' dobefore { get "/api/v2/storefront/taxons?filter[ids]=#{taxons.map(&:id).join(',')}" }- it_behaves_like 'returns 200 HTTP status'-it 'returns taxons by ids' doexpect(json_response['data'].size).to eq(2)expect(json_response['data'].pluck(:id).sort).to eq(taxons.map(&:id).map(&:to_s).sort)@@ -194,8 +171,6 @@ describe 'Taxons Spec', type: :request docontext 'by name' dobefore { get "/api/v2/storefront/taxons?filter[name]=#{taxons.last.name}" }- it_behaves_like 'returns 200 HTTP status'-it 'returns taxons by name' doexpect(json_response['data'].size).to eq(1)expect(json_response['data'].last['attributes']['name']).to eq(taxons.last.name)@@ -306,7 +281,6 @@ describe 'Taxons Spec', type: :request docontext 'when no image transformation params are passed' dolet(:taxon_image_transformation_params) { '' }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns taxon image data'it 'returns taxon image' do@@ -317,7 +291,6 @@ describe 'Taxons Spec', type: :request docontext 'when taxon image json returned' dolet(:taxon_image_transformation_params) { '&taxon_image_transformation[size]=100x50&taxon_image_transformation[quality]=50' }- it_behaves_like 'returns 200 HTTP status'it_behaves_like 'returns taxon image data'it 'returns taxon image' dodiff --git a/api/spec/requests/spree/api/v2/storefront/variants_spec.rb b/api/spec/requests/spree/api/v2/storefront/variants_spec.rbindex d8b57c43c3..34ac1f5693 100644--- a/api/spec/requests/spree/api/v2/storefront/variants_spec.rb+++ b/api/spec/requests/spree/api/v2/storefront/variants_spec.rb@@ -25,8 +25,6 @@ RSpec.describe 'API V2 Storefront Variants Spec', type: :request docontext 'with no params' dobefore { get "/api/v2/storefront/products/#{product.id}/variants" }- it_behaves_like 'returns 200 HTTP status'-it 'returns all product variants including master' doexpect(json_response['data'].count).to eq(5)@@ -41,8 +39,6 @@ RSpec.describe 'API V2 Storefront Variants Spec', type: :request docontext 'with specified option name and value' dobefore { get "/api/v2/storefront/products/#{product.id}/variants?filter[options][color]=white" }- it_behaves_like 'returns 200 HTTP status'-it 'returns product variants with the specified option' doexpect(json_response['data'].count).to eq(2)@@ -54,8 +50,6 @@ RSpec.describe 'API V2 Storefront Variants Spec', type: :request docontext 'with multiple options' dobefore { get "/api/v2/storefront/products/#{product.id}/variants?filter[options][color]=white&filter[options][size]=m" }- it_behaves_like 'returns 200 HTTP status'-it 'returns product variants with the specified options' doexpect(json_response['data'].count).to eq(1)expect(json_response['data']).to include(have_type('variant').and(have_id(variant_4.id.to_s)))diff --git a/api/spec/requests/spree/api/v2/storefront/wishlists_spec.rb b/api/spec/requests/spree/api/v2/storefront/wishlists_spec.rbindex f25750161c..6bc671524a 100644--- a/api/spec/requests/spree/api/v2/storefront/wishlists_spec.rb+++ b/api/spec/requests/spree/api/v2/storefront/wishlists_spec.rb@@ -352,8 +352,6 @@ RSpec.describe Spree::Api::V2::Storefront::WishlistsController, type: :request d}end- it_behaves_like 'returns 200 HTTP status'-it 'returns wishlist in response' doexpect(json_response['data']['type']).to eql ('wishlist')expect(json_response['data']['id']).to eql wishlist.id.to_s@@ -463,13 +461,12 @@ RSpec.describe Spree::Api::V2::Storefront::WishlistsController, type: :request d}end- it_behaves_like 'returns 422 HTTP status'-it 'does not create wished item' doexpect(user.wishlists.reload.first.wished_items.count).to eq 1endit 'returns error message' do+ expect(response.status).to eq(422)expect(json_response['error']).to eq 'Quantity must be greater than 0'endend@@ -506,10 +503,6 @@ RSpec.describe Spree::Api::V2::Storefront::WishlistsController, type: :request dit 'does not create wished item' doexpect(user.wishlists.reload.first.wished_items).to be_emptyend-- it 'does not create wished item' do- expect(user.wishlists.reload.first.wished_items).to be_empty- endendcontext 'when passed quantity is 0' do@@ -521,13 +514,12 @@ RSpec.describe Spree::Api::V2::Storefront::WishlistsController, type: :request d}end- it_behaves_like 'returns 422 HTTP status'-it 'does not create wished item' doexpect(user.wishlists.reload.first.wished_items).to be_emptyendit 'returns error message' do+ expect(response.status).to eq(422)expect(json_response['error']).to eq 'Quantity must be greater than 0'endenddiff --git a/api/spec/serializers/spree/api/v2/platform/cms_page_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/cms_page_serializer_spec.rbindex bb06259ae7..a63a99108b 100644--- a/api/spec/serializers/spree/api/v2/platform/cms_page_serializer_spec.rb+++ b/api/spec/serializers/spree/api/v2/platform/cms_page_serializer_spec.rb@@ -5,8 +5,6 @@ describe Spree::Api::V2::Platform::CmsPageSerializer dolet(:cms_page) { create(:cms_feature_page, cms_sections: create_list(:cms_hero_image_section, 2)) }- it { expect(subject).to be_kind_of(Hash) }-it doexpect(subject).to eq({diff --git a/api/spec/serializers/spree/api/v2/platform/digital_link_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/digital_link_serializer_spec.rbindex 0fe1654a16..7dd799d42f 100644--- a/api/spec/serializers/spree/api/v2/platform/digital_link_serializer_spec.rb+++ b/api/spec/serializers/spree/api/v2/platform/digital_link_serializer_spec.rb@@ -5,8 +5,6 @@ describe Spree::Api::V2::Platform::DigitalLinkSerializer dolet(:digital_link) { create(:digital_link) }- it { expect(subject).to be_kind_of(Hash) }-it doexpect(subject).to eq({diff --git a/api/spec/serializers/spree/api/v2/platform/digital_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/digital_serializer_spec.rbindex 3b8e7a9467..29fe754504 100644--- a/api/spec/serializers/spree/api/v2/platform/digital_serializer_spec.rb+++ b/api/spec/serializers/spree/api/v2/platform/digital_serializer_spec.rb@@ -5,8 +5,6 @@ describe Spree::Api::V2::Platform::DigitalSerializer dolet(:digital) { create(:digital) }- it { expect(subject).to be_kind_of(Hash) }-it doexpect(subject).to eq({diff --git a/api/spec/serializers/spree/api/v2/platform/menu_item_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/menu_item_serializer_spec.rbindex 33a4f76466..1bd0b20853 100644--- a/api/spec/serializers/spree/api/v2/platform/menu_item_serializer_spec.rb+++ b/api/spec/serializers/spree/api/v2/platform/menu_item_serializer_spec.rb@@ -12,8 +12,6 @@ describe Spree::Api::V2::Platform::MenuItemSerializer do]end- it { expect(subject).to be_kind_of(Hash) }-it doexpect(subject).to eq({diff --git a/api/spec/serializers/spree/api/v2/platform/menu_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/menu_serializer_spec.rbindex 2b3752519d..d199b75e72 100644--- a/api/spec/serializers/spree/api/v2/platform/menu_serializer_spec.rb+++ b/api/spec/serializers/spree/api/v2/platform/menu_serializer_spec.rb@@ -5,8 +5,6 @@ describe Spree::Api::V2::Platform::MenuSerializer dolet(:menu) { create(:menu) }- it { expect(subject).to be_kind_of(Hash) }-it doexpect(subject).to eq({diff --git a/api/spec/serializers/spree/api/v2/platform/option_type_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/option_type_serializer_spec.rbindex dc347eef3b..83324f5ff3 100644--- a/api/spec/serializers/spree/api/v2/platform/option_type_serializer_spec.rb+++ b/api/spec/serializers/spree/api/v2/platform/option_type_serializer_spec.rb@@ -5,8 +5,6 @@ describe Spree::Api::V2::Platform::OptionTypeSerializer dolet(:option_type) { create(:option_type, option_values: create_list(:option_value, 2)) }- it { expect(subject).to be_kind_of(Hash) }-it doexpect(subject).to eq({diff --git a/api/spec/serializers/spree/api/v2/platform/option_value_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/option_value_serializer_spec.rbindex f243c0dc82..d49849eb82 100644--- a/api/spec/serializers/spree/api/v2/platform/option_value_serializer_spec.rb+++ b/api/spec/serializers/spree/api/v2/platform/option_value_serializer_spec.rb@@ -5,8 +5,6 @@ describe Spree::Api::V2::Platform::OptionValueSerializer dolet(:option_value) { create(:option_value) }- it { expect(subject).to be_kind_of(Hash) }-it doexpect(subject).to eq({diff --git a/api/spec/serializers/spree/api/v2/platform/product_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/product_serializer_spec.rbindex bc1137a000..c4e73aab94 100644--- a/api/spec/serializers/spree/api/v2/platform/product_serializer_spec.rb+++ b/api/spec/serializers/spree/api/v2/platform/product_serializer_spec.rb@@ -5,6 +5,8 @@ describe Spree::Api::V2::Platform::ProductSerializer dosubject { described_class.new(product, params: serializer_params).serializable_hash }+ let(:store) { Spree::Store.default }+ let(:taxonomy) { store.taxonomies.first }let!(:images) { create_list(:image, 2) }let(:product) docreate(:product_in_stock,@@ -14,8 +16,9 @@ describe Spree::Api::V2::Platform::ProductSerializer dovariants_including_master: [create(:variant, images: images), create(:variant)],option_types: create_list(:option_type, 2),product_properties: create_list(:product_property, 2),- taxons: create_list(:taxon, 2),- tax_category: create(:tax_category))+ taxons: create_list(:taxon, 2, taxonomy: taxonomy),+ tax_category: create(:tax_category),+ stores: [store])endlet(:serializable_hash) do{@@ -141,8 +144,6 @@ describe Spree::Api::V2::Platform::ProductSerializer doendend- it { expect(subject).to be_kind_of(Hash) }-it { expect(subject).to eq(serializable_hash) }it_behaves_like 'an ActiveJob serializable hash'diff --git a/api/spec/serializers/spree/api/v2/platform/promotion_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/promotion_serializer_spec.rbindex 98e83bd702..dc4b316059 100644--- a/api/spec/serializers/spree/api/v2/platform/promotion_serializer_spec.rb+++ b/api/spec/serializers/spree/api/v2/platform/promotion_serializer_spec.rb@@ -8,8 +8,6 @@ describe Spree::Api::V2::Platform::PromotionSerializer dolet(:promotion_rule) { create(:promotion_rule) }let(:resource) { create(:promotion_with_item_adjustment, promotion_category: promotion_category, promotion_rules: [promotion_rule]) }- it { expect(subject).to be_kind_of(Hash) }-it doexpect(subject).to eq({diff --git a/api/spec/serializers/spree/api/v2/platform/refund_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/refund_serializer_spec.rbindex f68428903e..231f1c190e 100644--- a/api/spec/serializers/spree/api/v2/platform/refund_serializer_spec.rb+++ b/api/spec/serializers/spree/api/v2/platform/refund_serializer_spec.rb@@ -7,8 +7,6 @@ describe Spree::Api::V2::Platform::RefundSerializer dolet(:resource) { create(:refund, amount: 5.0, refunder: create(:user)) }- it { expect(subject).to be_kind_of(Hash) }-it_behaves_like 'an ActiveJob serializable hash'context 'with included relationships' dodiff --git a/api/spec/serializers/spree/api/v2/platform/shipping_method_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/shipping_method_serializer_spec.rbindex ee337d8a07..9878d82117 100644--- a/api/spec/serializers/spree/api/v2/platform/shipping_method_serializer_spec.rb+++ b/api/spec/serializers/spree/api/v2/platform/shipping_method_serializer_spec.rb@@ -10,8 +10,6 @@ describe Spree::Api::V2::Platform::ShippingMethodSerializer dolet(:resource) { create(:shipping_method, shipping_categories: [shipping_category], tax_category: tax_category) }- it { expect(subject).to be_kind_of(Hash) }-it doexpect(subject).to eq({diff --git a/api/spec/serializers/spree/api/v2/platform/store_credit_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/store_credit_serializer_spec.rbindex be0b7a7236..cfb6dcf99a 100644--- a/api/spec/serializers/spree/api/v2/platform/store_credit_serializer_spec.rb+++ b/api/spec/serializers/spree/api/v2/platform/store_credit_serializer_spec.rb@@ -7,8 +7,6 @@ describe Spree::Api::V2::Platform::StoreCreditSerializer dolet(:resource) { create(:store_credit) }- it { expect(subject).to be_kind_of(Hash) }-it_behaves_like 'an ActiveJob serializable hash'context 'with included relationships' dodiff --git a/api/spec/serializers/spree/api/v2/platform/store_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/store_serializer_spec.rbindex 381858a0f6..2be4657bd7 100644--- a/api/spec/serializers/spree/api/v2/platform/store_serializer_spec.rb+++ b/api/spec/serializers/spree/api/v2/platform/store_serializer_spec.rb@@ -12,8 +12,6 @@ describe Spree::Api::V2::Platform::StoreSerializer doendlet(:url_helpers) { Rails.application.routes.url_helpers }- it { expect(subject).to be_kind_of(Hash) }-it 'generates the correct serialization' doexpect(subject).to eq({diff --git a/api/spec/serializers/spree/api/v2/platform/taxon_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/taxon_serializer_spec.rbindex 28ead6aa4a..2fa80cc459 100644--- a/api/spec/serializers/spree/api/v2/platform/taxon_serializer_spec.rb+++ b/api/spec/serializers/spree/api/v2/platform/taxon_serializer_spec.rb@@ -9,8 +9,6 @@ describe Spree::Api::V2::Platform::TaxonSerializer dolet(:taxon) { create(:taxon, :with_description, taxonomy: taxonomy, products: create_list(:product, 2, stores: [store])) }let!(:children) { create_list(:taxon, 2, taxonomy: taxonomy, parent: taxon) }- it { expect(subject).to be_kind_of(Hash) }-context 'without products' doit doexpect(subject).to match(diff --git a/api/spec/serializers/spree/api/v2/platform/variant_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/variant_serializer_spec.rbindex 7966fb171b..5a23ad6bf0 100644--- a/api/spec/serializers/spree/api/v2/platform/variant_serializer_spec.rb+++ b/api/spec/serializers/spree/api/v2/platform/variant_serializer_spec.rb@@ -8,8 +8,6 @@ describe Spree::Api::V2::Platform::VariantSerializer dolet!(:variant) { create(:variant, price: 10, compare_at_price: 15, images: create_list(:image, 2), tax_category: create(:tax_category)) }let!(:digital) { create(:digital, variant: variant) }- it { expect(subject).to be_kind_of(Hash) }-it doexpect(subject).to eq({diff --git a/api/spec/serializers/spree/v2/storefront/wished_item_serializer_spec.rb b/api/spec/serializers/spree/v2/storefront/wished_item_serializer_spec.rbindex 0d96d58883..69998a7d13 100644--- a/api/spec/serializers/spree/v2/storefront/wished_item_serializer_spec.rb+++ b/api/spec/serializers/spree/v2/storefront/wished_item_serializer_spec.rb@@ -6,8 +6,6 @@ describe Spree::V2::Storefront::WishedItemSerializer dolet!(:wishlist) { create(:wishlist) }let!(:wished_item) { create(:wished_item, wishlist: wishlist, variant: create(:variant), quantity: 5) }- it { expect(subject).to be_kind_of(Hash) }-it doexpect(subject).to eq({diff --git a/api/spec/serializers/spree/v2/storefront/wishlist_serializer_spec.rb b/api/spec/serializers/spree/v2/storefront/wishlist_serializer_spec.rbindex e0a1cc8c61..1eb869f49c 100644--- a/api/spec/serializers/spree/v2/storefront/wishlist_serializer_spec.rb+++ b/api/spec/serializers/spree/v2/storefront/wishlist_serializer_spec.rb@@ -6,8 +6,6 @@ describe Spree::V2::Storefront::WishlistSerializer dolet!(:wishlist) { create(:wishlist) }let!(:wished_item) { create(:wished_item, wishlist: wishlist, variant: create(:variant), quantity: 1) }- it { expect(subject).to be_kind_of(Hash) }-it doexpect(subject).to eq({diff --git a/api/spec/spec_helper.rb b/api/spec/spec_helper.rbindex e0dfa39543..eedd94a747 100644--- a/api/spec/spec_helper.rb+++ b/api/spec/spec_helper.rb@@ -76,6 +76,12 @@ RSpec.configure do |config|config.include Spree::TestingSupport::Preferencesconfig.include Spree::TestingSupport::ImageHelpers+ config.before(:suite) do+ # Clean out the database state before the tests run+ DatabaseCleaner.strategy = :transaction+ DatabaseCleaner.clean_with(:truncation)+ end+config.before doSpree::Webhooks.disabled = true@@ -87,6 +93,12 @@ RSpec.configure do |config|I18n.locale = :enend+ config.around(:each) do |example|+ DatabaseCleaner.cleaning do+ example.run+ end+ end+config.order = :randomKernel.srand config.seedenddiff --git a/api/spec/support/database_cleaner.rb b/api/spec/support/database_cleaner.rbdeleted file mode 100644index 2c2d42763e..0000000000--- a/api/spec/support/database_cleaner.rb+++ /dev/null@@ -1,14 +0,0 @@-RSpec.configure do |config|- config.before(:suite) do- DatabaseCleaner.strategy = :transaction- DatabaseCleaner.clean_with(:truncation)- end-- config.before do- DatabaseCleaner.start- end-- config.append_after do- DatabaseCleaner.clean- end-enddiff --git a/bin/build-ci.rb b/bin/build-ci.rbindex e385a018cd..7942db6318 100755--- a/bin/build-ci.rb+++ b/bin/build-ci.rb@@ -21,7 +21,7 @@ class Project@name = nameend- ALL = %w[emails api core sample admin storefront].map(&method(:new)).freeze+ ALL = %w[emails api core sample admin storefront].freezeCORE_GEMS = %w[api core].freeze# Install subproject@@ -168,7 +168,7 @@ class Project## @return [Array<Project>]def self.current_projects- ALL+ ENV.fetch('PROJECTS', ALL.join(',')).split(',').map(&method(:new))endprivate_class_method :current_projectsdiff --git a/bin/tests_database_ci.sh b/bin/tests_database_ci.shindex 7901979e26..9295b8adea 100644--- a/bin/tests_database_ci.sh+++ b/bin/tests_database_ci.sh@@ -2,13 +2,6 @@set -euxo pipefail-if [$DB -eq "mysql"]-then- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B-fi--ls -l /tmp-sudo apt-get update && sudo apt-get install libvips42bundle install./bin/build-ci.rb installdiff --git a/core/db/migrate/20250120094216_create_page_builder_models.rb b/core/db/migrate/20250120094216_create_page_builder_models.rbindex 280388d69a..8ab0c2b06f 100644--- a/core/db/migrate/20250120094216_create_page_builder_models.rb+++ b/core/db/migrate/20250120094216_create_page_builder_models.rb@@ -16,9 +16,7 @@ class CreatePageBuilderModels < ActiveRecord::Migration[6.1]t.index ['deleted_at'], name: 'index_spree_themes_on_deleted_at't.index ['store_id', 'default'], name: 'index_spree_themes_on_store_id_and_default', unique: true, where: "((deleted_at IS NULL) AND (\"default\" = true))"end- end- if !table_exists?(:spree_pages)create_table :spree_pages do |t|t.references :pageable, polymorphic: true, null: falset.string :type, null: false@@ -38,9 +36,7 @@ class CreatePageBuilderModels < ActiveRecord::Migration[6.1]t.index ['pageable_id', 'pageable_type', 'type'], name: 'index_spree_pages_on_pageable_id_and_pageable_type_and_type't.index ['pageable_id', 'pageable_type'], name: 'index_spree_pages_on_pageable_id_and_pageable_type'end- end- if !table_exists?(:spree_page_sections)create_table :spree_page_sections do |t|t.references :pageable, polymorphic: true, null: false, index: truet.string :type, null: false@@ -54,9 +50,7 @@ class CreatePageBuilderModels < ActiveRecord::Migration[6.1]t.index ['pageable_id', 'pageable_type', 'position'], name: 'index_spree_page_sections_on_pageable_w_position'end- end- if !table_exists?(:spree_page_blocks)create_table :spree_page_blocks do |t|t.references :section, null: false, index: truet.string :name, null: false@@ -70,9 +64,7 @@ class CreatePageBuilderModels < ActiveRecord::Migration[6.1]t.index ['section_id', 'position'], name: 'index_spree_page_blocks_on_section_w_position'end- end- if !table_exists?(:spree_page_links)create_table :spree_page_links do |t|t.references :parent, polymorphic: true, index: truet.references :linkable, polymorphic: true, index: true@@ -82,8 +74,6 @@ class CreatePageBuilderModels < ActiveRecord::Migration[6.1]t.integer :position, default: 1, null: falset.timestamps-- t.index ['parent_id'], name: 'index_spree_page_links_on_parent_id'endendenddiff --git a/core/lib/generators/spree/dummy/templates/rails/database.yml b/core/lib/generators/spree/dummy/templates/rails/database.ymlindex d2d172e942..6b492c55fb 100644--- a/core/lib/generators/spree/dummy/templates/rails/database.yml+++ b/core/lib/generators/spree/dummy/templates/rails/database.yml@@ -57,6 +57,7 @@ postgres: &postgreshost: <%= db_host %><% end %>min_messages: warning+ pool: <%= ENV["DB_POOL"] || 50 %>development:<<: *postgresdiff --git a/core/lib/generators/spree/install/install_generator.rb b/core/lib/generators/spree/install/install_generator.rbindex 534526a6d1..80621ed63c 100644--- a/core/lib/generators/spree/install/install_generator.rb+++ b/core/lib/generators/spree/install/install_generator.rb@@ -70,7 +70,7 @@ module Spreedef install_storefrontif @install_storefront && Spree::Core::Engine.frontend_available?- generate 'spree:frontend:install'+ generate 'spree:storefront:install'endend@@ -82,7 +82,7 @@ module Spreedef copy_storefrontif @copy_storefront && Spree::Core::Engine.frontend_available?- generate 'spree:frontend:copy_storefront'+ generate 'spree:storefront:copy_storefront'endenddiff --git a/core/lib/spree/testing_support/common_rake.rb b/core/lib/spree/testing_support/common_rake.rbindex 72177ca940..c2b6a18686 100644--- a/core/lib/spree/testing_support/common_rake.rb+++ b/core/lib/spree/testing_support/common_rake.rb@@ -14,16 +14,21 @@ namespace :common doENV['RAILS_ENV'] = 'test'Rails.env = 'test'- Spree::DummyGenerator.start ["--lib_name=#{ENV['LIB_NAME']}"]+ skip_javascript = ['spree/api', 'spree/core', 'spree/sample', 'spree/emails'].include?(ENV['LIB_NAME'])++ Spree::DummyGenerator.start [+ "--lib_name=#{ENV['LIB_NAME']}",+ "--skip_javascript=#{skip_javascript}"+ ]# install frontend libraries- unless ['spree/api', 'spree/core', 'spree/sample', 'spree/emails'].include?(ENV['LIB_NAME'])+ unless skip_javascriptsystem('bin/rails importmap:install')system('bin/rails turbo:install')system('bin/rails stimulus:install')end- system('bin/rake acts_as_taggable_on_engine:install:migrations')+ system('bin/rake acts_as_taggable_on_engine:install:migrations > /dev/null 2>&1')Spree::InstallGenerator.start ["--lib_name=#{ENV['LIB_NAME']}",@@ -41,7 +46,7 @@ namespace :common dosystem('bin/rails db:environment:set RAILS_ENV=test > /dev/null 2>&1')system('bundle exec rake db:drop db:create > /dev/null 2>&1')Spree::DummyModelGenerator.start- system('bundle exec rake db:migrate')+ system('bundle exec rake db:migrate > /dev/null 2>&1')beginrequire "generators/#{ENV['LIB_NAME']}/install/install_generator"@@ -51,9 +56,7 @@ namespace :common doputs 'Skipping installation no generator to run...'end- unless ['spree/api', 'spree/core', 'spree/sample'].include?(ENV['LIB_NAME'])- system('bundle exec rake assets:precompile > /dev/null 2>&1')- end+ system('bundle exec rake assets:precompile > /dev/null 2>&1') if !skip_javascript || ENV['LIB_NAME'] == 'spree/emails'endtask :seed do |_t|diff --git a/core/spec/models/spree/order/finalizing_spec.rb b/core/spec/models/spree/order/finalizing_spec.rbindex f5800ef14c..1b42b8007a 100644--- a/core/spec/models/spree/order/finalizing_spec.rb+++ b/core/spec/models/spree/order/finalizing_spec.rb@@ -1,9 +1,9 @@require 'spec_helper'describe Spree::Order, type: :model do- let(:order) { create(:order) }+ let(:order) { create(:order, store: store) }- before { create(:store) }+ before { Spree::Store.default }context '#finalize!' dolet(:order) { Spree::Order.create(email: '[email protected]') }diff --git a/core/spec/models/spree/page_spec.rb b/core/spec/models/spree/page_spec.rbindex 15772e3e88..ef5b250a35 100644--- a/core/spec/models/spree/page_spec.rb+++ b/core/spec/models/spree/page_spec.rb@@ -1,8 +1,8 @@require 'spec_helper'describe Spree::Page, type: :model do- let(:store) { create(:store) }- let(:theme) { create(:theme, store: store) }+ let(:store) { Spree::Store.default }+ let(:theme) { store.default_theme }let(:page) { theme.pages.first }context 'slugs' dodiff --git a/core/spec/models/spree/reimbursement_spec.rb b/core/spec/models/spree/reimbursement_spec.rbindex c07c2f8595..462e2f896f 100644--- a/core/spec/models/spree/reimbursement_spec.rb+++ b/core/spec/models/spree/reimbursement_spec.rb@@ -1,12 +1,14 @@require 'spec_helper'describe Spree::Reimbursement, type: :model do+ let(:store) { Spree::Store.default }+describe '#display_total' dosubject { reimbursement.display_total }let(:total) { 100.50 }let(:currency) { 'USD' }- let(:order) { build(:order) }+ let(:order) { build(:order, store: store, currency: currency) }let(:reimbursement) { described_class.new(total: total, order: order) }it 'returns the value as a Spree::Money instance' do@@ -23,7 +25,6 @@ describe Spree::Reimbursement, type: :model dolet(:total) { 100.50 }let(:currency) { 'USD' }- let(:store) { create(:store) }let(:order) { build(:order, store: store, currency: currency) }let(:reimbursement) { described_class.new(total: total, order: order) }@@ -174,7 +175,7 @@ describe Spree::Reimbursement, type: :model dodescribe '.build_from_customer_return' dosubject { Spree::Reimbursement.build_from_customer_return(customer_return) }- let(:customer_return) { create(:customer_return, line_items_count: 5) }+ let(:customer_return) { create(:customer_return, line_items_count: 5, store: store) }let!(:pending_return_item) { customer_return.return_items.first.tap { |ri| ri.update!(acceptance_status: 'pending') } }let!(:accepted_return_item) { customer_return.return_items.second.tap(&:accept!) }@@ -184,15 +185,9 @@ describe Spree::Reimbursement, type: :model dolet!(:previous_reimbursement) { create(:reimbursement, order: customer_return.order, return_items: [already_reimbursed_return_item]) }- it 'connects to the accepted return items' do+ it 'connects data' doexpect(subject.return_items.to_a).to eq [accepted_return_item]- end-- it 'connects to the order' doexpect(subject.order).to eq customer_return.order- end-- it 'connects to the customer_return' doexpect(subject.customer_return).to eq customer_returnendenddiff --git a/core/spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb b/core/spec/models/spree/return_item/eligibility_validator/rma_required_spec.rbindex 74b81f021f..10332f0e7d 100644--- a/core/spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb+++ b/core/spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb@@ -16,12 +16,8 @@ describe Spree::ReturnItem::EligibilityValidator::RMARequired, type: :model docontext 'there is no rma on the return item' dobefore { allow(return_item).to receive(:return_authorization).and_return(nil) }- it 'returns false' do+ it 'returns false abd error' doexpect(subject).to be false- end-- it 'sets an error' do- subjectexpect(validator.errors[:rma_required]).to eq Spree.t('return_item_rma_ineligible')endenddiff --git a/core/spec/models/spree/theme_spec.rb b/core/spec/models/spree/theme_spec.rbindex ee867cdb97..9237067501 100644--- a/core/spec/models/spree/theme_spec.rb+++ b/core/spec/models/spree/theme_spec.rb@@ -1,7 +1,7 @@require 'spec_helper'describe Spree::Theme, type: :model do- let(:store) { create(:store) }+ let(:store) { Spree::Store.default }let(:theme) { create(:theme, store: store) }context 'Callbacks' dodiff --git a/core/spec/spec_helper.rb b/core/spec/spec_helper.rbindex 81cafcf768..d7d70ef8dc 100644--- a/core/spec/spec_helper.rb+++ b/core/spec/spec_helper.rb@@ -62,7 +62,7 @@ RSpec.configure do |config|# If you're not using ActiveRecord, or you'd prefer not to run each of your# examples within a transaction, comment the following line or assign false# instead of true.- config.use_transactional_fixtures = false+ config.use_transactional_fixtures = trueconfig.before(:suite) do# Clean out the database state before the tests run@@ -88,11 +88,6 @@ RSpec.configure do |config|config.include Spree::TestingSupport::Preferencesconfig.include Spree::TestingSupport::Kernel- config.before(:suite) do- # Clean out the database state before the tests run- DatabaseCleaner.clean_with(:truncation)- end-config.order = :randomKernel.srand config.seedenddiff --git a/sample/spec/spec_helper.rb b/sample/spec/spec_helper.rbindex 93001e01fd..3b1d0a7f40 100644--- a/sample/spec/spec_helper.rb+++ b/sample/spec/spec_helper.rb@@ -42,10 +42,6 @@ RSpec.configure do |config|DatabaseCleaner.clean_with(:truncation)end- config.before(:suite) do- DatabaseCleaner.start- end-config.append_after doDatabaseCleaner.cleanenddiff --git a/storefront/spec/spec_helper.rb b/storefront/spec/spec_helper.rbindex 7cff22cbde..cac6e11401 100644--- a/storefront/spec/spec_helper.rb+++ b/storefront/spec/spec_helper.rb@@ -61,7 +61,7 @@ RSpec.configure do |config|# If you're not using ActiveRecord, or you'd prefer not to run each of your# examples within a transaction, comment the following line or assign false# instead of true.- config.use_transactional_fixtures = false+ config.use_transactional_fixtures = trueconfig.before(:suite) doCapybara.match = :smart@@ -80,6 +80,7 @@ RSpec.configure do |config|endconfig.before(:each) do+ Spree::Webhooks.disabled = truebeginRails.cache.clearreset_spree_preferences@@ -87,12 +88,6 @@ RSpec.configure do |config|endend- config.around(:each) do |example|- DatabaseCleaner.cleaning do- example.run- end- end-config.include FactoryBot::Syntax::Methodsconfig.include Spree::Storefront::TestingSupport::CapybaraUtils