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
Restore the spec blocks both branches added around the same lines
Łukasz Adamczykd410e27f1101
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/orders_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/orders_controller_spec.rbindex 487ab25864..558ab7bed4 100644--- a/spree/api/spec/controllers/spree/api/v3/admin/orders_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/admin/orders_controller_spec.rb@@ -423,6 +423,28 @@ RSpec.describe Spree::Api::V3::Admin::OrdersController, type: :controller doexpect(json_response['email']).to eq('[email protected]')end+ # The admin order edit screen submits every row it shows in one request:+ # changed quantities as their new value, struck-out rows as zero.+ context 'with a whole edited order in one request' do+ let(:order) { create(:order_with_line_items, store: store, line_items_count: 2) }+ let(:kept) { order.line_items.first }+ let(:removed) { order.line_items.last }++ it 'applies the quantity changes and the removals together' do+ patch :update, params: {+ id: order.prefixed_id,+ items: [+ { variant_id: kept.variant.prefixed_id, quantity: 3 },+ { variant_id: removed.variant.prefixed_id, quantity: 0 }+ ]+ }, as: :json++ expect(response).to have_http_status(:ok)+ expect(order.reload.line_items).to contain_exactly(kept)+ expect(kept.reload.quantity).to eq(3)+ end+ end+# Staff assigning the business an order is for — the only route to an# exemption for a buyer who acts for several companies, until session-level# selection is settled with channels and catalogs.@@ -455,25 +477,6 @@ RSpec.describe Spree::Api::V3::Admin::OrdersController, type: :controller doexpect(response).to have_http_status(:ok)expect(order.reload.company_location_id).to be_nil- # The admin order edit screen submits every row it shows in one request:- # changed quantities as their new value, struck-out rows as zero.- context 'with a whole edited order in one request' do- let(:order) { create(:order_with_line_items, store: store, line_items_count: 2) }- let(:kept) { order.line_items.first }- let(:removed) { order.line_items.last }-- it 'applies the quantity changes and the removals together' do- patch :update, params: {- id: order.prefixed_id,- items: [- { variant_id: kept.variant.prefixed_id, quantity: 3 },- { variant_id: removed.variant.prefixed_id, quantity: 0 }- ]- }, as: :json-- expect(response).to have_http_status(:ok)- expect(order.reload.line_items).to contain_exactly(kept)- expect(kept.reload.quantity).to eq(3)endenddiff --git a/spree/core/spec/lib/tasks/six_zero_data_migrations_spec.rb b/spree/core/spec/lib/tasks/six_zero_data_migrations_spec.rbindex b83bf8123a..0afbc7d5ea 100644--- a/spree/core/spec/lib/tasks/six_zero_data_migrations_spec.rb+++ b/spree/core/spec/lib/tasks/six_zero_data_migrations_spec.rb@@ -11,8 +11,8 @@ describe '6.0 data migration tasks' doload Spree::Core::Engine.root.join('lib', 'tasks', 'products.rake')load Spree::Core::Engine.root.join('lib', 'tasks', 'order_market_backfill.rake')load Spree::Core::Engine.root.join('lib', 'tasks', 'store_binding_migration.rake')- load Spree::Core::Engine.root.join('lib', 'tasks', 'tax_zones_migration.rake')load Spree::Core::Engine.root.join('lib', 'tasks', 'fulfillment_statuses_migration.rake')+ load Spree::Core::Engine.root.join('lib', 'tasks', 'tax_zones_migration.rake')endlet(:store) { @default_store }@@ -112,6 +112,78 @@ describe '6.0 data migration tasks' doendend+ describe 'spree:migrate_delivery_profiles' do+ # 5.x rows arrive store-less and kind-less; the legacy method↔category+ # m:n is read straight from the surviving table.+ let(:method_categories) { Class.new(ActiveRecord::Base) { self.table_name = 'spree_shipping_method_categories' } }++ def legacy_category!(name)+ profile = Spree::DeliveryProfiles::Shipping.create!(store: store, name: name)+ profile.update_columns(store_id: nil, type: nil)+ profile+ end++ it 'folds a non-narrowing category into the store default profile' do+ category = legacy_category!('Default Category')+ method = create(:shipping_method, store: store)+ method_categories.create!(shipping_method_id: method.id, shipping_category_id: category.id)+ Spree::DeliveryMethod.unscoped.where(store: store).find_each do |delivery_method|+ method_categories.find_or_create_by!(shipping_method_id: delivery_method.id, shipping_category_id: category.id)+ end+ product = create(:product, store: store)+ product.update_columns(delivery_profile_id: category.id)++ run_task('spree:migrate_delivery_profiles')++ expect(product.reload.delivery_profile).to eq(store.default_delivery_profile)+ expect(Spree::DeliveryProfile.exists?(category.id)).to be(false)+ end++ it 'keeps a narrowing category as a profile and moves its solely-linked method in' do+ category = legacy_category!('Oversized')+ oversized_method = create(:shipping_method, store: store, name: 'Freight')+ create(:shipping_method, store: store, name: 'Regular')+ method_categories.create!(shipping_method_id: oversized_method.id, shipping_category_id: category.id)+ product = create(:product, store: store)+ product.update_columns(delivery_profile_id: category.id)++ run_task('spree:migrate_delivery_profiles')++ profile = Spree::DeliveryProfile.find(category.id)+ expect(profile.store).to eq(store)+ expect(profile).to be_a(Spree::DeliveryProfiles::Shipping)+ expect(oversized_method.reload.delivery_profile_id).to eq(profile.id)+ expect(product.reload.delivery_profile_id).to eq(profile.id)+ end++ it 'detects a digital-only category as a Digital profile' do+ category = legacy_category!('Digital Goods')+ digital_method = create(:digital_delivery_method, store: store)+ create(:shipping_method, store: store)+ method_categories.create!(shipping_method_id: digital_method.id, shipping_category_id: category.id)+ product = create(:product, store: store)+ product.update_columns(delivery_profile_id: category.id)++ run_task('spree:migrate_delivery_profiles')++ profile = Spree::DeliveryProfile.find(category.id)+ expect(profile).to be_a(Spree::DeliveryProfiles::Digital)+ expect(product.reload.delivery_profile_id).to eq(profile.id)+ end++ it 'is idempotent' do+ category = legacy_category!('Oversized')+ method = create(:shipping_method, store: store, name: 'Freight')+ create(:shipping_method, store: store, name: 'Regular')+ method_categories.create!(shipping_method_id: method.id, shipping_category_id: category.id)+ product = create(:product, store: store)+ product.update_columns(delivery_profile_id: category.id)++ run_task('spree:migrate_delivery_profiles')+ expect { run_task('spree:migrate_delivery_profiles') }.not_to change(Spree::DeliveryProfile, :count)+ end+ end+describe 'spree:backfill_tax_store_ids' doit 'assigns the default store to unbound rows and skips bound ones' doother_store = create(:store)@@ -258,75 +330,6 @@ describe '6.0 data migration tasks' doexpect(rule.reload.preferred_country_ids).to be_emptyexpect(rule.preferences).not_to have_key(:zone_ids)end- describe 'spree:migrate_delivery_profiles' do- # 5.x rows arrive store-less and kind-less; the legacy method↔category- # m:n is read straight from the surviving table.- let(:method_categories) { Class.new(ActiveRecord::Base) { self.table_name = 'spree_shipping_method_categories' } }-- def legacy_category!(name)- profile = Spree::DeliveryProfiles::Shipping.create!(store: store, name: name)- profile.update_columns(store_id: nil, type: nil)- profile- end-- it 'folds a non-narrowing category into the store default profile' do- category = legacy_category!('Default Category')- method = create(:shipping_method, store: store)- method_categories.create!(shipping_method_id: method.id, shipping_category_id: category.id)- Spree::DeliveryMethod.unscoped.where(store: store).find_each do |delivery_method|- method_categories.find_or_create_by!(shipping_method_id: delivery_method.id, shipping_category_id: category.id)- end- product = create(:product, store: store)- product.update_columns(delivery_profile_id: category.id)-- run_task('spree:migrate_delivery_profiles')-- expect(product.reload.delivery_profile).to eq(store.default_delivery_profile)- expect(Spree::DeliveryProfile.exists?(category.id)).to be(false)- end-- it 'keeps a narrowing category as a profile and moves its solely-linked method in' do- category = legacy_category!('Oversized')- oversized_method = create(:shipping_method, store: store, name: 'Freight')- create(:shipping_method, store: store, name: 'Regular')- method_categories.create!(shipping_method_id: oversized_method.id, shipping_category_id: category.id)- product = create(:product, store: store)- product.update_columns(delivery_profile_id: category.id)-- run_task('spree:migrate_delivery_profiles')-- profile = Spree::DeliveryProfile.find(category.id)- expect(profile.store).to eq(store)- expect(profile).to be_a(Spree::DeliveryProfiles::Shipping)- expect(oversized_method.reload.delivery_profile_id).to eq(profile.id)- expect(product.reload.delivery_profile_id).to eq(profile.id)- end-- it 'detects a digital-only category as a Digital profile' do- category = legacy_category!('Digital Goods')- digital_method = create(:digital_delivery_method, store: store)- create(:shipping_method, store: store)- method_categories.create!(shipping_method_id: digital_method.id, shipping_category_id: category.id)- product = create(:product, store: store)- product.update_columns(delivery_profile_id: category.id)-- run_task('spree:migrate_delivery_profiles')-- profile = Spree::DeliveryProfile.find(category.id)- expect(profile).to be_a(Spree::DeliveryProfiles::Digital)- expect(product.reload.delivery_profile_id).to eq(profile.id)- end-- it 'is idempotent' do- category = legacy_category!('Oversized')- method = create(:shipping_method, store: store, name: 'Freight')- create(:shipping_method, store: store, name: 'Regular')- method_categories.create!(shipping_method_id: method.id, shipping_category_id: category.id)- product = create(:product, store: store)- product.update_columns(delivery_profile_id: category.id)-- run_task('spree:migrate_delivery_profiles')- expect { run_task('spree:migrate_delivery_profiles') }.not_to change(Spree::DeliveryProfile, :count)endend