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
Removed redundant specs, fixed specs that could never fail and deprecation warnings in specs (#14868)
Damian Legawiec26541b089137
diff --git a/spree/core/lib/generators/spree/dummy/templates/rails/test.rb b/spree/core/lib/generators/spree/dummy/templates/rails/test.rbindex 1c47088354..7ae3d63ccd 100644--- a/spree/core/lib/generators/spree/dummy/templates/rails/test.rb+++ b/spree/core/lib/generators/spree/dummy/templates/rails/test.rb@@ -42,9 +42,28 @@ Dummy::Application.configure do# Print deprecation notices to the stderrconfig.active_support.deprecation = :stderr- # Spree's own code must not call the deprecated Spree.t.+ # Spree's own code and specs must not call these deprecated APIs. A spec+ # covering one on purpose stubs Spree::Deprecation.warn or silences it.config.active_support.disallowed_deprecation = :raise- config.active_support.disallowed_deprecation_warnings = [/Spree\.t is deprecated/]+ config.active_support.disallowed_deprecation_warnings = [+ /Spree\.t is deprecated/,+ /Spree::Product#(master|variants_including_master) is deprecated/,+ /Spree::(Order|Cart)#(shipment_total|promo_total|item_count|shipping_discount) is deprecated/,+ /Spree::Order#finalize! is deprecated/,+ /Spree::Payment#state=? is deprecated/,+ /Spree::Payment#(process|authorize|purchase|capture|void_transaction)! is deprecated/,+ /Spree::(Category|Product)#classifications is deprecated/,+ /Spree::Product#taxons=? is deprecated/,+ /Spree::Promotion::Rules::Category#taxon/,+ /Spree::Fulfillment#(add_)?shipping_method is deprecated/,+ /Spree::Stock::Package#shipping_methods is deprecated/,+ /Calling Spree::(Carts::AddItem|StockReservations::(Reserve|Extend)) with order: is deprecated/,+ /Spree::Config\[:admin_url\] is deprecated/,+ /private_metadata=? is deprecated/,+ /Spree::Pricing::Resolver is deprecated/,+ /Spree::Invitation#accept! is deprecated/,+ /`preference :\w+, in:` is deprecated/+ ]config.active_job.queue_adapter = :testdiff --git a/spree/core/spec/jobs/spree/price_lists/sync_currencies_job_spec.rb b/spree/core/spec/jobs/spree/price_lists/sync_currencies_job_spec.rbindex 4bd8ef5390..312fd2625a 100644--- a/spree/core/spec/jobs/spree/price_lists/sync_currencies_job_spec.rb+++ b/spree/core/spec/jobs/spree/price_lists/sync_currencies_job_spec.rb@@ -20,7 +20,7 @@ describe Spree::PriceLists::SyncCurrenciesJob, type: :job doit 'adds the missing currency\'s placeholder rows and leaves the rest alone' dousd_before = price_list.prices.where(currency: 'USD').pluck(:id, :amount)- expect { subject }.to change { price_list.prices.where(currency: 'EUR').count }.from(0).to(product.variants_including_master.count)+ expect { subject }.to change { price_list.prices.where(currency: 'EUR').count }.from(0).to(product.variants.count)expect(price_list.prices.where(currency: 'EUR').pluck(:amount).uniq).to eq([nil])expect(price_list.prices.where(currency: 'USD').pluck(:id, :amount)).to match_array(usd_before)@@ -70,7 +70,7 @@ describe Spree::PriceLists::SyncCurrenciesJob, type: :job doperform_enqueued_jobs- expect(second_list.prices.where(currency: 'EUR').count).to eq(other_product.variants_including_master.count)+ expect(second_list.prices.where(currency: 'EUR').count).to eq(other_product.variants.count)endendenddiff --git a/spree/core/spec/lib/spree/core/pricing/catalog_pricing_spec.rb b/spree/core/spec/lib/spree/core/pricing/catalog_pricing_spec.rbindex ec0c7e48eb..7cbece5aac 100644--- a/spree/core/spec/lib/spree/core/pricing/catalog_pricing_spec.rb+++ b/spree/core/spec/lib/spree/core/pricing/catalog_pricing_spec.rb@@ -150,7 +150,7 @@ describe 'catalog-aware pricing' docontext = Spree::Pricing::Context.new(variant: variant, currency: 'USD', store: store,channel: channel)- expect(Spree::Pricing::Resolver.new(context).resolve.amount).to eq(95)+ expect(Spree::Pricing::PriceResolution.call(context).amount).to eq(95)end# An inactive catalog is off, and its owned list goes dormant WITH it: thediff --git a/spree/core/spec/lib/spree/core_spec.rb b/spree/core/spec/lib/spree/core_spec.rbindex b0392a9a79..1f51e88d86 100644--- a/spree/core/spec/lib/spree/core_spec.rb+++ b/spree/core/spec/lib/spree/core_spec.rb@@ -45,6 +45,9 @@ describe Spree doendit 'delegates reads and writes to customer_class' do+ expect(Spree::Deprecation).to receive(:warn).with(/Spree.user_class= is deprecated/)+ expect(Spree::Deprecation).to receive(:warn).with(/Spree.user_class is deprecated/)+described_class.user_class = 'Spree::Customer'expect(described_class.user_class).to eq(Spree::Customer)diff --git a/spree/core/spec/lib/tasks/single_store_associations_spec.rb b/spree/core/spec/lib/tasks/single_store_associations_spec.rbindex c65717af83..912cfd4471 100644--- a/spree/core/spec/lib/tasks/single_store_associations_spec.rb+++ b/spree/core/spec/lib/tasks/single_store_associations_spec.rb@@ -45,6 +45,8 @@ describe 'spree:upgrade:populate_single_store_associations' doendit 'assigns the earliest store and reports the shared record' do+ expect(Spree::Deprecation).to receive(:warn).with(/Promotion \S+ was shared across 2 stores/)+expect { subject.invoke }.to output(/shared across stores/).to_stdout.and change { promotion.reload.store_id }.from(nil).to(default_store.id)@@ -79,6 +81,8 @@ describe 'spree:upgrade:populate_single_store_associations' do# No timestamps on the join — the lowest store_id is the deterministic owner.it 'assigns the lowest store_id' do+ expect(Spree::Deprecation).to receive(:warn).with(/PaymentMethod \S+ was shared across 2 stores/)+subject.invokeexpect(payment_method.reload.store_id).to eq([default_store.id, other_store.id].min)enddiff --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 bbd87cdb86..393504536a 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@@ -472,7 +472,7 @@ describe '6.0 data migration tasks' doexpect(fee.kind).to eq('surcharge')expect(order.reload.attributes.slice('total', 'discount_total', 'additional_tax_total')).to eq(totals_before)- expect(order.private_metadata['typed_adjustments_frozen']).to be_nil+ expect(order.metadata['typed_adjustments_frozen']).to be_nilendit 'freezes orders whose typed sums do not reconcile' do@@ -483,7 +483,7 @@ describe '6.0 data migration tasks' dorun_task('spree:migrate_adjustments_to_typed_rows')- expect(order.reload.private_metadata['typed_adjustments_frozen']).to eq('totals_do_not_reconcile')+ expect(order.reload.metadata['typed_adjustments_frozen']).to eq('totals_do_not_reconcile')endit 'skips orders that already carry typed rows' dodiff --git a/spree/core/spec/mailers/spree/invitation_mailer_spec.rb b/spree/core/spec/mailers/spree/invitation_mailer_spec.rbindex 92055ee4e6..7970c50df8 100644--- a/spree/core/spec/mailers/spree/invitation_mailer_spec.rb+++ b/spree/core/spec/mailers/spree/invitation_mailer_spec.rb@@ -70,11 +70,11 @@ RSpec.describe Spree::InvitationMailer, type: :mailer dobefore doallow(spree).to receive(:respond_to?).and_call_originalallow(spree).to receive(:respond_to?).with(:admin_invitation_url).and_return(false)- Spree::Config[:admin_url] = 'https://admin.example.com'+ Spree::Config[:dashboard_url] = 'https://admin.example.com'endafter do- Spree::Config[:admin_url] = nil+ Spree::Config[:dashboard_url] = nilendit 'uses the admin_invitation_acceptance helper for the accept link' do@@ -83,7 +83,7 @@ RSpec.describe Spree::InvitationMailer, type: :mailer doexpect(email_body(mail)).not_to include(legacy_admin_url)end- it 'honors Spree::Config[:admin_url] in the rendered URL' do+ it 'honors Spree::Config[:dashboard_url] in the rendered URL' doexpect(email_body(mail)).to include("https://admin.example.com/accept-invitation/#{invitation.prefixed_id}")@@ -122,7 +122,7 @@ RSpec.describe Spree::InvitationMailer, type: :mailer doendend- context 'when neither the legacy gem nor admin_url is configured' do+ context 'when neither the legacy gem nor dashboard_url is configured' dobefore doallow(spree).to receive(:respond_to?).and_call_originalallow(spree).to receive(:respond_to?).with(:admin_invitation_url).and_return(false)diff --git a/spree/core/spec/models/concerns/spree/acted_by_spec.rb b/spree/core/spec/models/concerns/spree/acted_by_spec.rbindex 519ab00d19..0a897b3455 100644--- a/spree/core/spec/models/concerns/spree/acted_by_spec.rb+++ b/spree/core/spec/models/concerns/spree/acted_by_spec.rb@@ -13,17 +13,6 @@ RSpec.describe Spree::ActedBy doexpect(Spree::Refund.acted_by_associations).to eq([:refunder])expect(Spree::StockReceipt.acted_by_associations).to eq([:received_by])end-- it 'is polymorphic and optional' do- association = Spree::Order.reflect_on_association(:canceler)-- expect(association).to be_polymorphic- expect(association.options[:optional]).to be(true)- end-- it 'does not leak one model\'s names into another' do- expect(Spree::Refund.acted_by_associations).not_to include(:canceler)- endenddescribe 'accepting each registered actor kind' do@@ -74,6 +63,7 @@ RSpec.describe Spree::ActedBy doendit 'resolves through the admin user class' do+ allow(Spree::Deprecation).to receive(:warn)expect(order.reload.canceler).to eq(admin_user)end@@ -104,6 +94,7 @@ RSpec.describe Spree::ActedBy docountend+ allow(Spree::Deprecation).to receive(:warn)3.times { create(:order, store: store, canceler: admin_user) }read_page = -> { Spree::Order.preload_associations_lazily.last(3).each(&:canceler) }@@ -115,6 +106,7 @@ RSpec.describe Spree::ActedBy doendit 'names the type in memory only, never saving it' do+ allow(Spree::Deprecation).to receive(:warn)order.reload.cancelerexpect(Spree::Order.where(id: order.id).pick(:canceler_type)).to be_nildiff --git a/spree/core/spec/models/concerns/spree/has_custom_fields_spec.rb b/spree/core/spec/models/concerns/spree/has_custom_fields_spec.rbindex b29d1974ba..527829009f 100644--- a/spree/core/spec/models/concerns/spree/has_custom_fields_spec.rb+++ b/spree/core/spec/models/concerns/spree/has_custom_fields_spec.rb@@ -3,16 +3,6 @@ require 'spec_helper'RSpec.describe Spree::HasCustomFields, type: :concern dolet(:product) { create(:product) }- describe 'associations' do- it 'has many custom_fields' do- expect(product).to respond_to(:custom_fields)- end-- it 'has many storefront_custom_fields' do- expect(product).to respond_to(:storefront_custom_fields)- end- end-describe '.with_custom_field_key' dolet!(:definition) { create(:custom_field_definition, namespace: 'custom', key: 'foo', resource_type: 'Spree::Product') }let!(:custom_field) { create(:custom_field, resource: product, custom_field_definition: definition) }@@ -190,15 +180,6 @@ RSpec.describe Spree::HasCustomFields, type: :concern do}.not_to change { Spree::CustomField.count }endend-- it 'accepts a definition owned by the record\'s own store' do- definition = create(:custom_field_definition, store: product.store, namespace: 'custom',- key: 'material', resource_type: 'Spree::Product')-- product.set_custom_field(definition, 'wool')-- expect(product.get_custom_field('custom.material').value).to eq('wool')- endenddescribe '#has_custom_field?' do@@ -285,22 +266,6 @@ RSpec.describe Spree::HasCustomFields, type: :concern dovalue: 'initial value', type: definition.field_type_class_name)end- it 'destroys existing custom_field when value is set to empty string' do- attrs = {- custom_fields_attributes: [- {- id: custom_field.id,- custom_field_definition_id: definition.id,- value: '',- type: definition.field_type_class_name- }- ]- }- expect {- product.update(attrs)- }.to change { product.custom_fields.count }.by(-1)- end-it 'destroys existing custom_field when value is set to nil' doattrs = {custom_fields_attributes: [@@ -317,23 +282,6 @@ RSpec.describe Spree::HasCustomFields, type: :concern do}.to change { product.custom_fields.count }.by(-1)end- it 'updates existing custom_field when value is not empty' do- attrs = {- custom_fields_attributes: [- {- id: custom_field.id,- custom_field_definition_id: definition.id,- value: 'updated value',- type: definition.field_type_class_name- }- ]- }- expect {- product.update(attrs)- }.not_to change { product.custom_fields.count }- expect(custom_field.reload.value).to eq('updated value')- end-it 'handles multiple custom_fields correctly' doother_definition = create(:custom_field_definition, namespace: 'custom', key: 'bar', resource_type: 'Spree::Product')other_custom_field = create(:custom_field, resource: product, custom_field_definition: other_definition,@@ -367,6 +315,8 @@ RSpec.describe Spree::HasCustomFields, type: :concern dodescribe '#metafields_attributes=' dolet(:definition) { create(:custom_field_definition, namespace: 'custom', key: 'legacy', resource_type: 'Spree::Product') }+ before { allow(Spree::Deprecation).to receive(:warn) }+# Legacy payloads name the foreign key `metafield_definition_id`, which the# current writer would otherwise reject and silently drop.it 'accepts the legacy definition key' do@@ -376,6 +326,7 @@ RSpec.describe Spree::HasCustomFields, type: :concern do}.to change { product.custom_fields.count }.by(1)expect(product.get_custom_field('custom.legacy').value).to eq('legacy value')+ expect(Spree::Deprecation).to have_received(:warn).with(/metafields_attributes= is deprecated/)endit 'still accepts the current definition key' dodiff --git a/spree/core/spec/models/concerns/spree/publishable_spec.rb b/spree/core/spec/models/concerns/spree/publishable_spec.rbindex b395c65323..6b5b4811ca 100644--- a/spree/core/spec/models/concerns/spree/publishable_spec.rb+++ b/spree/core/spec/models/concerns/spree/publishable_spec.rb@@ -164,25 +164,6 @@ RSpec.describe Spree::Publishable, events: true doendend- context 'with model override' do- let(:override_class) do- serializer = v3_serializer_class- Class.new(Spree::Base) do- self.table_name = 'spree_products'- include Spree::Publishable-- define_method(:event_serializer_class) { serializer }- end- end-- it 'uses the overridden serializer' do- stub_const('Spree::CustomModel', override_class)- instance = override_class.new(id: 1)-- expect(instance.event_serializer_class).to eq(v3_serializer_class)- end- end-context 'with anonymous class' doit 'returns nil' doanon_class = Class.new(Spree::Base) do@@ -258,10 +239,6 @@ RSpec.describe Spree::Publishable, events: true dostub_const('Spree::TestProduct', lifecycle_class)end- it 'enables lifecycle events' do- expect(lifecycle_class.lifecycle_events_enabled).to be true- end-# Note: These specs use ApplicationRecord directly to test Publishable in isolation# since Spree::Base now has lifecycle events enabled by defaultcontext 'with only option' do@@ -277,7 +254,7 @@ RSpec.describe Spree::Publishable, events: true doit 'only registers specified callbacks' doexpect(limited_class._commit_callbacks.map(&:filter)).to include(:publish_create_event)expect(limited_class._commit_callbacks.map(&:filter)).not_to include(:publish_update_event)- expect(limited_class._commit_callbacks.map(&:filter)).not_to include(:publish_destroy_event)+ expect(limited_class._commit_callbacks.map(&:filter)).not_to include(:publish_delete_event)endend@@ -366,11 +343,5 @@ RSpec.describe Spree::Publishable, events: true doit 'derives from model name' doexpect(Spree::OrderLineItem.event_prefix).to eq('order_line_item')end-- it 'can be customized' do- stub_const('Spree::CustomModel', publishable_class)- Spree::CustomModel.event_prefix = 'custom'- expect(Spree::CustomModel.event_prefix).to eq('custom')- endendenddiff --git a/spree/core/spec/models/concerns/spree/purchase/addresses_spec.rb b/spree/core/spec/models/concerns/spree/purchase/addresses_spec.rbindex 69f9fd6032..b538ef068b 100644--- a/spree/core/spec/models/concerns/spree/purchase/addresses_spec.rb+++ b/spree/core/spec/models/concerns/spree/purchase/addresses_spec.rb@@ -389,6 +389,7 @@ RSpec.describe Spree::Purchase::Addresses dolet(:order) { build(:order) }before do+ allow(Spree::Deprecation).to receive(:warn)order.bill_address = create(:address)order.ship_address = nilend@@ -410,6 +411,7 @@ RSpec.describe Spree::Purchase::Addresses doit 'does not clone the bill address to the shipping' doorder.valid?expect(order.ship_address).to be_nil+ expect(Spree::Deprecation).to have_received(:warn).with(/use_billing is deprecated/)endenddiff --git a/spree/core/spec/models/concerns/spree/purchase/digital_items_spec.rb b/spree/core/spec/models/concerns/spree/purchase/digital_items_spec.rbindex ca49924467..60b05bfe8c 100644--- a/spree/core/spec/models/concerns/spree/purchase/digital_items_spec.rb+++ b/spree/core/spec/models/concerns/spree/purchase/digital_items_spec.rb@@ -8,19 +8,6 @@ RSpec.shared_examples 'a digital items host' doendcontext 'line_item analysis' do- it 'understands that all products are digital' do- 3.times { add_line_item(record, digital_variant, 1) }- expect(record.digital?).to be true-- add_line_item(record, digital_variant, 4)- expect(record.digital?).to be true- end-- it 'understands that no products are digital' do- 3.times { add_line_item(record, create(:variant), 1) }- expect(record.digital?).to be false- end-it 'understands that an empty record is not digital' doexpect(record.digital?).to be falseend@@ -75,11 +62,13 @@ RSpec.shared_examples 'a digital items host' doit 'correctly loads the links' dodigital_assets.each { |digital_asset| add_line_item(record, create(:variant, digital_assets: [digital_asset]), 1) }add_line_item(record, create(:variant), 1)+ expected_links = record.digital_line_items.map do |line_item|+ create(:digital_link, line_item: line_item, digital_asset: line_item.variant.digital_assets.first)+ end+ create(:digital_link)- links = record.digital_links- links_from_digitals = digital_assets.map(&:reload).map(&:digital_links).flatten- expect(links.size).to eq(links_from_digitals.size)- links.each { |link| expect(links_from_digitals).to include(link) }+ expect(expected_links.size).to eq(2)+ expect(record.digital_links).to match_array(expected_links)endenddiff --git a/spree/core/spec/models/concerns/spree/purchase/line_item_currencies_spec.rb b/spree/core/spec/models/concerns/spree/purchase/line_item_currencies_spec.rbindex 9e61c60d24..8b96191f17 100644--- a/spree/core/spec/models/concerns/spree/purchase/line_item_currencies_spec.rb+++ b/spree/core/spec/models/concerns/spree/purchase/line_item_currencies_spec.rb@@ -5,10 +5,6 @@ RSpec.shared_examples 'a line item currencies host' dolet!(:euro_price) { create(:price, variant: line_item.variant, amount: 8, currency: 'EUR') }describe '#homogenize_line_item_currencies' do- it 'succeeds without error' do- expect { record.update!(currency: 'EUR') }.not_to raise_error- end-it 'changes the line_item currencies' doexpect { record.update!(currency: 'EUR') }.to change { line_item.reload.currency }.from('USD').to('EUR')enddiff --git a/spree/core/spec/models/concerns/spree/purchase/store_credits_spec.rb b/spree/core/spec/models/concerns/spree/purchase/store_credits_spec.rbindex f38925f78f..1f22bf4466 100644--- a/spree/core/spec/models/concerns/spree/purchase/store_credits_spec.rb+++ b/spree/core/spec/models/concerns/spree/purchase/store_credits_spec.rb@@ -134,14 +134,15 @@ RSpec.shared_examples 'a store credits host' docontext 'when the record is complete' dolet(:record) { completed_record_with_store_credit_payment }- let(:store_credit_payments) { record.payments.checkout.store_credits }- before do+ it 'leaves the store credit payments untouched' do+ store_credit_payments = record.payments.store_credits.map { |payment| [payment.id, payment.status] }+ expect(store_credit_payments).not_to be_empty+subject- record.reload- end- it { expect(record.payments.checkout.store_credits).to eq store_credit_payments }+ expect(record.reload.payments.store_credits.map { |payment| [payment.id, payment.status] }).to eq(store_credit_payments)+ endendenddiff --git a/spree/core/spec/models/concerns/spree/webhook_payload_redaction_spec.rb b/spree/core/spec/models/concerns/spree/webhook_payload_redaction_spec.rbindex 3e159e8f7f..956d4bc6f5 100644--- a/spree/core/spec/models/concerns/spree/webhook_payload_redaction_spec.rb+++ b/spree/core/spec/models/concerns/spree/webhook_payload_redaction_spec.rb@@ -189,16 +189,6 @@ describe Spree::WebhookPayloadRedaction doexpect(described_class.split('data' => nil)).to eq([{ 'data' => nil }, {}])end- it 'redacts both data hashes when the payload carries :data and "data"' do- payload, _secrets = described_class.split(- :data => { 'reset_token' => 'sym-side' },- 'data' => { 'reset_token' => 'str-side' }- )-- expect(payload[:data]['reset_token']).to eq(placeholder)- expect(payload['data']['reset_token']).to eq(placeholder)- end-it 'redacts every form of a sensitive key present in the same data hash' dopayload, secrets = described_class.split('data' => { :reset_token => 'sym-tok', 'reset_token' => 'str-tok' }@@ -220,15 +210,6 @@ describe Spree::WebhookPayloadRedaction doenddescribe '.merge' do- it 'restores extracted secrets' do- redacted = { 'data' => { 'email' => '[email protected]', 'reset_token' => placeholder } }-- restored = described_class.merge(redacted, 'reset_token' => 'live-token')-- expect(restored['data']['reset_token']).to eq('live-token')- expect(restored['data']['email']).to eq('[email protected]')- end-it 'leaves the payload redacted when no secrets are held' doredacted = { 'data' => { 'reset_token' => placeholder } }@@ -262,10 +243,4 @@ describe Spree::WebhookPayloadRedaction doexpect(restored['data']['child']['reset_token']).to eq(placeholder)endend-- it 'round-trips to the original payload' do- original = { 'data' => { 'email' => '[email protected]', 'reset_token' => 'live-token' } }-- expect(described_class.merge(*described_class.split(original))).to eq(original)- endenddiff --git a/spree/core/spec/models/spree/ability_spec.rb b/spree/core/spec/models/spree/ability_spec.rbindex f4f0f63acb..dd7c26f5e3 100644--- a/spree/core/spec/models/spree/ability_spec.rb+++ b/spree/core/spec/models/spree/ability_spec.rb@@ -17,11 +17,6 @@ describe Spree::Ability, type: :model doit_behaves_like 'access granted'it_behaves_like 'index allowed'end-- context 'with customer' do- it_behaves_like 'access denied'- it_behaves_like 'no index allowed'- endendcontext 'for admin protected resources' do@@ -63,13 +58,6 @@ describe Spree::Ability, type: :model doendcontext 'with customer' do- it 'is not able to admin' do- expect(ability).not_to be_able_to :admin, resource- expect(ability).not_to be_able_to :admin, resource_order- expect(ability).not_to be_able_to :admin, resource_product- expect(ability).not_to be_able_to :admin, resource_user- end-it 'is not able to admin even with an admin role assignment' douser.save!user.spree_roles << Spree::Role.default_admin_role@@ -277,22 +265,6 @@ describe Spree::Ability, type: :model doendend- # A role belongs to one store, so "the same role on two stores" is two- # roles. Holding both grants each store's keys on that store alone.- context 'with a same-named role on two stores' do- let(:store_b) { create(:store) }-- before do- admin.role_users.create!(role: create(:role, name: 'shared', permissions: %w[write_orders], resource: store))- admin.role_users.create!(role: create(:role, name: 'shared', permissions: %w[write_products], resource: store_b))- end-- it 'grants each store only its own role keys' do- expect(staff_ability.permission_keys).to eq(%w[read_orders write_orders])- expect(Spree::Ability.new(admin, store: store_b).permission_keys).to eq(%w[read_products write_products])- end- end-# A marketplace seller's staff hold roles owned by the seller. Store-admin# authority must come only from the store's own roles, or a seller picker# would inherit the whole store — including, for an `admin`-named seller@@ -383,24 +355,4 @@ describe Spree::Ability, type: :model doendendend-- context 'role resolution uses the store of a role user' do- let(:admin) { create(:admin_user, :without_admin_role) }- let(:store_a) { @default_store }- let(:store_b) { create(:store) }-- before do- admin.role_users.create!(role: Spree::Role.default_admin_role(store_a))- end-- it "grants authority on the role assignment's store" do- ability = Spree::Ability.new(admin, store: store_a)- expect(ability).to be_able_to :manage, Spree::Product.new- end-- it 'does not grant authority on a different store' do- ability = Spree::Ability.new(admin, store: store_b)- expect(ability).not_to be_able_to :manage, Spree::Product.new- end- endenddiff --git a/spree/core/spec/models/spree/address_spec.rb b/spree/core/spec/models/spree/address_spec.rbindex 4592e5e043..d7ecc8dd61 100644--- a/spree/core/spec/models/spree/address_spec.rb+++ b/spree/core/spec/models/spree/address_spec.rb@@ -95,24 +95,6 @@ describe Spree::Address, type: :model dolet(:country) { @default_store.default_country }let(:address) { create(:address, country: country) }- context '#country_name' do- it 'return proper country_iso_name' do- expect(address.country_name).to eq 'United States'- end- end-- context '#country_iso_name' do- it 'return proper country_iso_name' do- expect(address.country_iso_name).to eq 'UNITED STATES OF AMERICA'- end- end-- context '#country_code' do- it 'return proper country_iso_name' do- expect(address.country_code).to eq 'US'- end- end-context '#country_iso3' doit 'return proper country_iso_name' doexpect(address.country_iso3).to eq 'USA'@@ -121,20 +103,6 @@ describe Spree::Address, type: :model doendend- context 'aliased attributes' do- let(:address) { Spree::Address.new }-- it 'first_name' do- address.first_name = 'Ryan'- expect(address.first_name).to eq('Ryan')- end-- it 'last_name' do- address.last_name = 'Bigg'- expect(address.last_name).to eq('Bigg')- end- end-context 'validation' do# Countries and subdivisions are reference data now, so these are real# places rather than invented ones: Maryland is a subdivision of the US,@@ -218,12 +186,6 @@ describe Spree::Address, type: :model doexpect(address).to be_validend- it 'does not require phone' do- address.state_code = state.abbr- address.phone = ''- expect(address).to be_valid- end-context 'when phone is required' dobefore { @default_store.update!(preferred_address_requires_phone: true) }@@ -342,16 +304,6 @@ describe Spree::Address, type: :model doendend- context 'phone not required' do- before { allow(address).to receive_messages require_phone?: false }-- it 'shows no errors when phone is blank' do- address.phone = ''- address.valid?- expect(address.errors[:phone].size).to eq 0- end- end-context 'postal code not required' dobefore { allow(address).to receive_messages require_postal_code?: false }@@ -417,26 +369,6 @@ describe Spree::Address, type: :model doendend- describe '#country_code' do- let(:address) { build(:address, country: country) }- let(:country) { Spree::Country.by_iso('US') }-- it 'returns the country iso' do- expect(address.country_code).to eq('US')- end-- it 'returns nil if the country is nil' do- address.country_code = nil- expect(address.country_code).to be_nil- end- end-- context 'defines require_phone? helper method' do- let(:address) { create(:address) }-- specify { expect(address.instance_eval { require_phone? }).to be(false) }- end-context '#clear_state' dolet (:address) { create(:address) }@@ -594,6 +526,8 @@ describe Spree::Address, type: :model doendit 'can be deleted when there is an incomplete associated order' do+ create(:order, customer: user, bill_address: address3)+expect(address3).to be_can_be_deletedend@@ -602,12 +536,6 @@ describe Spree::Address, type: :model doexpect(Spree::Address.where(['id = (?)', address.id])).to be_emptyend- it 'is destroyed deleted timestamp' do- address2.destroy- expect(Spree::Address.where(['id = (?)', address2.id])).not_to be_empty- expect(Spree::Address.not_deleted.where(['id = (?)', address2.id])).to be_empty- end-context 'when an incomplete order references the address' dolet!(:incomplete_order) docreate(:order, customer: user, bill_address: address, ship_address: address, state: 'delivery')@@ -880,15 +808,6 @@ describe Spree::Address, type: :model doaddress.valid?expect(address.country).to be_nilend-- it 'clears the input after normalization' do- address = build(:address, country: nil)- address.country_code = 'US'- address.valid?- # The input should be cleared so it doesn't re-run on next validation- address.valid?- expect(address.country).to eq(country)- endenddescribe '#state_code=' dodiff --git a/spree/core/spec/models/spree/adjusters/promotion_spec.rb b/spree/core/spec/models/spree/adjusters/promotion_spec.rbindex d17347d9fe..2c46a92cb9 100644--- a/spree/core/spec/models/spree/adjusters/promotion_spec.rb+++ b/spree/core/spec/models/spree/adjusters/promotion_spec.rb@@ -61,16 +61,17 @@ describe Spree::Adjusters::Promotion, type: :model doit 'clamps so a line never goes below zero' dopromo = create(:promotion, kind: :automatic, code: nil, store: store)- action = Spree::Promotion::Actions::CreateItemAdjustments.create!(+ Spree::Promotion::Actions::CreateItemAdjustments.create!(promotion: promo,calculator: Spree::Calculator::FlatRate.new(preferred_amount: 999))promo.activate(order: order)- order.discounts.reload.each do |row|+ rows = order.discounts.reload+ expect(rows.size).to eq(2)+ rows.each do |row|expect(row.amount).to eq(-row.line_item.amount)end- expect(action.reload).to be_presentenddescribe 'order-level distribution' dodiff --git a/spree/core/spec/models/spree/admin_user_spec.rb b/spree/core/spec/models/spree/admin_user_spec.rbindex eb105e60f8..a2d64ad26a 100644--- a/spree/core/spec/models/spree/admin_user_spec.rb+++ b/spree/core/spec/models/spree/admin_user_spec.rb@@ -18,15 +18,6 @@ describe Spree.admin_user_class, type: :model doadmin_user.update!(password: 'new-secret-123', password_confirmation: 'new-secret-123')expect(described_class.find_by_password_reset_token(token)).to be_nilend-- # The token payload keys off the password salt/digest so it invalidates- # when the password changes. has_secure_password provides #password_salt- # (derived from password_digest); the generator also falls back through- # encrypted_password for a legacy bcrypt column on a custom model without a- # password_salt, so it never raises NameError.- it 'generates a password reset token from the password digest' do- expect(admin_user.generate_token_for(:password_reset)).to be_present- endenddescribe '#can_be_deleted?' dodiff --git a/spree/core/spec/models/spree/allowed_origin_spec.rb b/spree/core/spec/models/spree/allowed_origin_spec.rbindex 50057a9203..25a70458e7 100644--- a/spree/core/spec/models/spree/allowed_origin_spec.rb+++ b/spree/core/spec/models/spree/allowed_origin_spec.rb@@ -13,13 +13,9 @@ RSpec.describe Spree::AllowedOrigin, type: :model doduplicate = build(:allowed_origin, store: store, origin: 'https://example.com')expect(duplicate).not_to be_validexpect(duplicate.errors[:origin]).to include('has already been taken')- end- it 'allows same origin for different stores' doother_store = create(:store, code: 'other')- create(:allowed_origin, store: store, origin: 'https://example.com')- other = build(:allowed_origin, store: other_store, origin: 'https://example.com')- expect(other).to be_valid+ expect(build(:allowed_origin, store: other_store, origin: 'https://example.com')).to be_validendend@@ -169,20 +165,4 @@ RSpec.describe Spree::AllowedOrigin, type: :model doendendend-- describe 'SingleStoreResource' do- it 'prevents changing store after creation' do- origin = create(:allowed_origin, store: store)- other_store = create(:store, code: 'other2')- origin.store = other_store- expect(origin).not_to be_valid- end- end-- describe 'prefix_id' do- it 'generates ao_ prefixed id' do- origin = create(:allowed_origin, store: store)- expect(origin.prefixed_id).to start_with('ao_')- end- endenddiff --git a/spree/core/spec/models/spree/api_key_spec.rb b/spree/core/spec/models/spree/api_key_spec.rbindex 05081be4fc..86169363c7 100644--- a/spree/core/spec/models/spree/api_key_spec.rb+++ b/spree/core/spec/models/spree/api_key_spec.rb@@ -5,16 +5,6 @@ RSpec.describe Spree::ApiKey, type: :model dolet(:api_key) { create(:api_key, store: store) }describe 'validations' do- it 'is valid with valid attributes' do- expect(api_key).to be_valid- end-- it 'requires a name' do- api_key.name = nil- expect(api_key).not_to be_valid- expect(api_key.errors[:name]).to be_present- end-it 'requires a name unique among the store\'s active keys' dostore = create(:store)existing = create(:api_key, name: 'Storefront', store: store)@@ -36,23 +26,12 @@ RSpec.describe Spree::ApiKey, type: :model doexpect(older.reload.revoked_at).to be_presentend- it 'requires a key_type' do- api_key.key_type = nil- expect(api_key).not_to be_valid- expect(api_key.errors[:key_type]).to be_present- end-it 'requires key_type to be publishable or secret' doapi_key.key_type = 'invalid'expect(api_key).not_to be_validexpect(api_key.errors[:key_type]).to be_presentend- it 'requires a store' do- api_key.store = nil- expect(api_key).not_to be_valid- end-it 'requires unique token for publishable keys' doduplicate = build(:api_key, :publishable, store: store, token: api_key.token)expect(duplicate).not_to be_valid@@ -223,11 +202,6 @@ RSpec.describe Spree::ApiKey, type: :model doapi_key.revoke!(user)expect(api_key.revoked_by).to eq(user)end-- it 'marks key as inactive' do- api_key.revoke!- expect(api_key.active?).to be false- endenddescribe '.find_by_secret_token' do@@ -260,24 +234,6 @@ RSpec.describe Spree::ApiKey, type: :model doendend- describe 'associations' do- it 'belongs to store' do- expect(api_key.store).to eq(store)- end-- it 'can have created_by' do- user = create(:user)- key = create(:api_key, store: store, created_by: user)- expect(key.created_by).to eq(user)- end-- it 'can have revoked_by' do- user = create(:user)- api_key.revoke!(user)- expect(api_key.revoked_by).to eq(user)- end- end-describe 'channel binding' dolet(:channel) { create(:channel, store: store) }diff --git a/spree/core/spec/models/spree/app_dependencies_spec.rb b/spree/core/spec/models/spree/app_dependencies_spec.rbindex d2c5ae0002..25ffdf9ef9 100644--- a/spree/core/spec/models/spree/app_dependencies_spec.rb+++ b/spree/core/spec/models/spree/app_dependencies_spec.rb@@ -23,10 +23,6 @@ describe Spree::Core::Dependencies, type: :model dodeps.cart_add_item_workflow = 'MyCustomAddItemService'expect(deps.cart_add_item_workflow).to eq 'MyCustomAddItemService'end-- it 'works with constantize for string values' do- expect(deps.cart_add_item_workflow.constantize).to eq Spree::Carts::AddItem- endenddescribe '#<dependency>_class' do@@ -34,20 +30,10 @@ describe Spree::Core::Dependencies, type: :model doexpect(deps.cart_add_item_workflow_class).to eq Spree::Carts::AddItemend- it 'returns the class directly when set as class' do- deps.cart_add_item_workflow = MyCustomAddItemService- expect(deps.cart_add_item_workflow_class).to eq MyCustomAddItemService- end-- it 'memoizes the resolved class' do- deps.cart_add_item_workflow_class- expect(deps.instance_variable_get(:@cart_add_item_workflow_resolved)).to eq Spree::Carts::AddItem- end-- it 'clears memoization when value changes' do+ it 'returns the class directly when set as class, even after resolving the previous value' dodeps.cart_add_item_workflow_classdeps.cart_add_item_workflow = MyCustomAddItemService- expect(deps.instance_variable_defined?(:@cart_add_item_workflow_resolved)).to be false+ expect(deps.cart_add_item_workflow_class).to eq MyCustomAddItemServiceendend@@ -56,11 +42,6 @@ describe Spree::Core::Dependencies, type: :model doexpect(deps.overrides).to eq({})end- it 'tracks overridden dependencies' do- deps.cart_add_item_workflow = MyCustomAddItemService- expect(deps.overrides).to have_key(:cart_add_item_workflow)- end-it 'includes override metadata' dodeps.cart_add_item_workflow = MyCustomAddItemServiceoverride = deps.overrides[:cart_add_item_workflow]@@ -136,14 +117,6 @@ describe Spree::Core::Dependencies, type: :model doit 'returns nil for non-overridden dependencies' doexpect(deps.override_info(:cart_add_item_workflow)).to be_nilend-- it 'returns override info for overridden dependencies' do- deps.cart_add_item_workflow = MyCustomAddItemService- info = deps.override_info(:cart_add_item_workflow)-- expect(info[:value]).to eq MyCustomAddItemService- expect(info[:source]).to include('app_dependencies_spec.rb')- endenddescribe '#current_values' do@@ -217,10 +190,6 @@ describe 'Spree module dependency accessors' doit 'sets the dependency via Spree module' doSpree.cart_add_item_workflow = MyCustomAddItemServiceexpect(Spree::Dependencies.cart_add_item_workflow).to eq MyCustomAddItemService- end-- it 'returns the new class via Spree module' do- Spree.cart_add_item_workflow = MyCustomAddItemServiceexpect(Spree.cart_add_item_workflow).to eq MyCustomAddItemServiceenddiff --git a/spree/core/spec/models/spree/authentication/strategies/base_strategy_spec.rb b/spree/core/spec/models/spree/authentication/strategies/base_strategy_spec.rbindex 12772a1711..652469610d 100644--- a/spree/core/spec/models/spree/authentication/strategies/base_strategy_spec.rb+++ b/spree/core/spec/models/spree/authentication/strategies/base_strategy_spec.rb@@ -10,18 +10,6 @@ describe Spree::Authentication::Strategies::BaseStrategy doenddescribe '#initialize' do- it 'sets params' do- expect(strategy.params).to eq(params)- end-- it 'sets request_env' do- expect(strategy.request_env).to eq(request_env)- end-- it 'sets user_class' do- expect(strategy.user_class).to eq(user_class)- end-context 'when user_class is not provided' dosubject(:strategy) dodescribed_class.new(params: params, request_env: request_env)@@ -45,30 +33,6 @@ describe Spree::Authentication::Strategies::BaseStrategy doendend- describe '#success' do- let(:user) { create(:user) }-- it 'returns a successful Result' do- result = strategy.send(:success, user)-- expect(result).to be_a(Spree::ServiceModule::Result)- expect(result).to be_success- expect(result.value).to eq(user)- end- end-- describe '#failure' do- let(:message) { 'Authentication failed' }-- it 'returns a failed Result' do- result = strategy.send(:failure, message)-- expect(result).to be_a(Spree::ServiceModule::Result)- expect(result).not_to be_success- expect(result.error).to eq(message)- end- end-describe '#find_user_by_email' dolet!(:user) { create(:user, email: '[email protected]') }@@ -92,11 +56,8 @@ describe Spree::Authentication::Strategies::BaseStrategy docontext 'when the stored email is capitalized' dolet!(:user) { create(:user, email: '[email protected]') }- it 'finds the user from a lowercase email' do- expect(strategy.send(:find_user_by_email, '[email protected]')).to eq(user)- end-it 'finds the user from a differently-cased email' do+ expect(strategy.send(:find_user_by_email, '[email protected]')).to eq(user)expect(strategy.send(:find_user_by_email, '[email protected]')).to eq(user)endend@@ -123,24 +84,5 @@ describe Spree::Authentication::Strategies::BaseStrategy doinfo: info,tokens: tokens)end-- it 'passes the user_class' do- admin_user_class = Spree.admin_user_class- admin_strategy = described_class.new(- params: params,- request_env: request_env,- user_class: admin_user_class- )-- expect(Spree::UserIdentity).to receive(:find_or_create_from_oauth).with(- hash_including(user_class: admin_user_class)- )-- admin_strategy.send(:find_or_create_user_from_oauth,- provider: provider,- uid: uid,- info: info,- tokens: tokens)- endendenddiff --git a/spree/core/spec/models/spree/authentication/strategies/email_password_strategy_spec.rb b/spree/core/spec/models/spree/authentication/strategies/email_password_strategy_spec.rbindex a42b07a77b..ad9fb94009 100644--- a/spree/core/spec/models/spree/authentication/strategies/email_password_strategy_spec.rb+++ b/spree/core/spec/models/spree/authentication/strategies/email_password_strategy_spec.rb@@ -191,10 +191,7 @@ describe Spree::Authentication::Strategies::EmailPasswordStrategy doendit 'authenticates with admin user class' do- admin_user # ensure admin user exists- # Mock password validation for admin user- allow(admin_user).to receive(:valid_password?).with('admin123').and_return(true)- allow(strategy).to receive(:find_user_by_email).with('[email protected]').and_return(admin_user)+ admin_userresult = strategy.authenticatediff --git a/spree/core/spec/models/spree/base_spec.rb b/spree/core/spec/models/spree/base_spec.rbindex b8bfd8ac32..7a0354e562 100644--- a/spree/core/spec/models/spree/base_spec.rb+++ b/spree/core/spec/models/spree/base_spec.rb@@ -73,9 +73,6 @@ describe Spree::Base do# Backwards-compatible alias retained for extensions that still call# the old name; must delegate so subclass overrides (e.g.# `Spree::Gateway.api_type`) propagate.- it { expect(Spree::FulfillmentItem.json_api_type).to eq('fulfillment_item') }- it { expect(Spree::Address.json_api_type).to eq('address') }-it 'honors subclass overrides of .api_type' doklass = Class.new(Spree::Base) dodef self.api_type@@ -94,7 +91,6 @@ describe Spree::Base doendit { expect(Spree::Address.json_api_columns).to contain_exactly('address1', 'address2', 'alternative_phone', 'city', 'company', 'country_code', 'created_at', 'deleted_at', 'first_name', 'label', 'last_name', 'phone', 'postal_code', 'state_code', 'state_name', 'updated_at', 'metadata', 'quick_checkout', 'latitude', 'longitude') }- it { expect(Spree::Address.json_api_columns).not_to include('country_id') }enddescribe '.json_api_permitted_attributes' dodiff --git a/spree/core/spec/models/spree/calculator/flat_rate_spec.rb b/spree/core/spec/models/spree/calculator/flat_rate_spec.rbindex 4ed51ea271..8f881e1326 100644--- a/spree/core/spec/models/spree/calculator/flat_rate_spec.rb+++ b/spree/core/spec/models/spree/calculator/flat_rate_spec.rb@@ -7,8 +7,6 @@ describe Spree::Calculator::FlatRate, type: :model dobefore { allow(line_item).to receive_messages quantity: 10 }describe '#compute' do- it { expect(calculator.preferred_apply_only_on_full_priced_items).to be false }-shared_examples 'computing amount correctly' doit "computes the amount as the rate when currency matches the line_item's currency" docalculator.preferred_amount = 25.0diff --git a/spree/core/spec/models/spree/calculator/flexi_rate_spec.rb b/spree/core/spec/models/spree/calculator/flexi_rate_spec.rbindex 5f1d5116e6..2e6333c964 100644--- a/spree/core/spec/models/spree/calculator/flexi_rate_spec.rb+++ b/spree/core/spec/models/spree/calculator/flexi_rate_spec.rb@@ -7,8 +7,6 @@ describe Spree::Calculator::FlexiRate, type: :model dobefore { allow(line_item).to receive_messages quantity: 10 }describe '#compute' do- it { expect(calculator.preferred_apply_only_on_full_priced_items).to be false }-shared_examples 'computes amount correctly' doit 'computes amount correctly when all fees are 0' doexpect(calculator.compute(line_item).round(2)).to eq(0.0)@@ -33,10 +31,6 @@ describe Spree::Calculator::FlexiRate, type: :model doallow(calculator).to receive_messages preferred_first_item: 5.0, preferred_additional_item: 1.0, preferred_max_items: 3expect(calculator.compute(line_item).round(2)).to eq(7.0)end-- it 'allows creation of new object with all the attributes' do- Spree::Calculator::FlexiRate.new(preferred_first_item: 1, preferred_additional_item: 1, preferred_max_items: 1)- endendcontext 'when apply_only_on_full_priced_items is true' dodiff --git a/spree/core/spec/models/spree/calculator/percent_on_line_item_spec.rb b/spree/core/spec/models/spree/calculator/percent_on_line_item_spec.rbindex e988a16f65..39e206343f 100644--- a/spree/core/spec/models/spree/calculator/percent_on_line_item_spec.rb+++ b/spree/core/spec/models/spree/calculator/percent_on_line_item_spec.rb@@ -7,8 +7,6 @@ describe Spree::Calculator::PercentOnLineItem, type: :model dobefore { allow(calculator).to receive_messages preferred_percent: 10 }describe '#compute' do- it { expect(calculator.preferred_apply_only_on_full_priced_items).to be false }-shared_examples 'computing amount correctly' doit 'rounds result correctly' doallow(line_item).to receive_messages amount: 31.08diff --git a/spree/core/spec/models/spree/calculator/price_sack_spec.rb b/spree/core/spec/models/spree/calculator/price_sack_spec.rbindex 78d6f064d4..634973cabd 100644--- a/spree/core/spec/models/spree/calculator/price_sack_spec.rb+++ b/spree/core/spec/models/spree/calculator/price_sack_spec.rb@@ -15,12 +15,12 @@ describe Spree::Calculator::PriceSack, type: :model do# Regression test for #714 and #739it 'computes with an order object' do- calculator.compute(order)+ expect(calculator.compute(order)).to eq(calculator.preferred_normal_amount)end# Regression test for #1156it 'computes with a shipment object' do- calculator.compute(shipment)+ expect(calculator.compute(shipment)).to eq(calculator.preferred_discount_amount)end# Regression test for #2055diff --git a/spree/core/spec/models/spree/calculator/shipping/digital_delivery_spec.rb b/spree/core/spec/models/spree/calculator/shipping/digital_delivery_spec.rbindex b4542a5977..34ee4940bc 100644--- a/spree/core/spec/models/spree/calculator/shipping/digital_delivery_spec.rb+++ b/spree/core/spec/models/spree/calculator/shipping/digital_delivery_spec.rb@@ -3,10 +3,6 @@ require 'spec_helper'RSpec.describe Spree::Calculator::Shipping::DigitalDelivery dosubject { Spree::Calculator::Shipping::DigitalDelivery.new }- it 'has a description for the class' do- expect(Spree::Calculator::Shipping::DigitalDelivery).to respond_to(:description)- end-describe '#compute_package' doit 'quotes the package currency from the per-currency amounts' dosubject.preferred_amounts = { 'EUR' => 3.5 }diff --git a/spree/core/spec/models/spree/calculator/shipping/flat_rate_spec.rb b/spree/core/spec/models/spree/calculator/shipping/flat_rate_spec.rbindex c7aff78567..58ce8bf9e9 100644--- a/spree/core/spec/models/spree/calculator/shipping/flat_rate_spec.rb+++ b/spree/core/spec/models/spree/calculator/shipping/flat_rate_spec.rb@@ -51,6 +51,8 @@ RSpec.describe Spree::Calculator::Shipping::FlatRate, type: :model doendcontext 'with weight constraints' do+ before { allow(Spree::Deprecation).to receive(:warn) }+let(:calculator_1) { described_class.new(preferred_amount: 5, preferred_minimum_weight: 2, preferred_maximum_weight: 4) }let(:calculator_2) { described_class.new(preferred_amount: 5, preferred_minimum_weight: 4, preferred_maximum_weight: 8) }@@ -71,10 +73,13 @@ RSpec.describe Spree::Calculator::Shipping::FlatRate, type: :model doexpect(calculator_5.compute(package)).to eq(5.00)expect(calculator_6.compute(package)).to be_nilexpect(calculator_7.compute(package)).to be_nil+ expect(Spree::Deprecation).to have_received(:warn).with(/`minimum_weight` is deprecated/).at_least(:once)endendcontext 'with price constraints' do+ before { allow(Spree::Deprecation).to receive(:warn) }+let(:calculator_1) { described_class.new(preferred_amount: 5, preferred_minimum_item_total: 20, preferred_maximum_item_total: 35) }let(:calculator_2) { described_class.new(preferred_amount: 5, preferred_minimum_item_total: 35, preferred_maximum_item_total: 80) }@@ -95,10 +100,13 @@ RSpec.describe Spree::Calculator::Shipping::FlatRate, type: :model doexpect(calculator_5.compute(package)).to eq(5.00)expect(calculator_6.compute(package)).to be_nilexpect(calculator_7.compute(package)).to be_nil+ expect(Spree::Deprecation).to have_received(:warn).with(/`minimum_item_total` is deprecated/).at_least(:once)endendcontext 'with both weight and price constraints' do+ before { allow(Spree::Deprecation).to receive(:warn) }+let(:calculator_1) dodescribed_class.new(preferred_amount: 5,diff --git a/spree/core/spec/models/spree/calculator/shipping/flexi_rate_spec.rb b/spree/core/spec/models/spree/calculator/shipping/flexi_rate_spec.rbindex 33c695717f..c06f1a9003 100644--- a/spree/core/spec/models/spree/calculator/shipping/flexi_rate_spec.rb+++ b/spree/core/spec/models/spree/calculator/shipping/flexi_rate_spec.rb@@ -39,14 +39,6 @@ module Spreesubject.preferred_max_items = 3expect(subject.compute(package).round(2)).to eq(7.0)end-- it 'allows creation of new object with all the attributes' do- FlexiRate.new(- preferred_first_item: 1,- preferred_additional_item: 1,- preferred_max_items: 1- )- endendendenddiff --git a/spree/core/spec/models/spree/calculator/shipping/price_sack_spec.rb b/spree/core/spec/models/spree/calculator/shipping/price_sack_spec.rbindex 5451ae7f2c..55e82b9864 100644--- a/spree/core/spec/models/spree/calculator/shipping/price_sack_spec.rb+++ b/spree/core/spec/models/spree/calculator/shipping/price_sack_spec.rb@@ -14,8 +14,6 @@ module Spreelet(:line_item) { build(:line_item, variant: variant, price: variant.amount_in(variant.cost_currency)) }let(:variant) { create(:variant, price: 2) }- let(:inventory_unit1) { }-let(:normal_package) doiu = build(:fulfillment_item, quantity: 2, variant: variant, line_item: line_item)build(:stock_package, contents: [::Spree::Stock::ContentItem.new(iu)])diff --git a/spree/core/spec/models/spree/cart_spec.rb b/spree/core/spec/models/spree/cart_spec.rbindex 8706f56261..c3dbd6a82b 100644--- a/spree/core/spec/models/spree/cart_spec.rb+++ b/spree/core/spec/models/spree/cart_spec.rb@@ -67,14 +67,6 @@ describe Spree::Cart, type: :model doexpect(cart.checkout_steps).to eq(%w(address delivery complete))endend-- context 'when payment required' do- before { allow(cart).to receive_messages payment_required?: true }-- specify do- expect(cart.checkout_steps).to eq(%w(address delivery payment complete))- end- endenddescribe '#current_checkout_step' do@@ -135,14 +127,6 @@ describe Spree::Cart, type: :model doenddescribe 'lifecycle events' do- it 'publishes cart.* lifecycle events' do- expect(described_class.lifecycle_events_enabled).to be true- expect(described_class.event_prefix).to eq('cart')-- registered = described_class._commit_callbacks.map(&:filter)- expect(registered).to include(:publish_create_event, :publish_update_event, :publish_delete_event)- end-# The V3 cart serializer resolves by convention when spree_api is loaded;# core's dummy app only sees the fallback payload.it 'carries the prefixed id in the event payload' do@@ -173,20 +157,6 @@ describe Spree::Cart, type: :model doenddescribe 'lifecycle' do- it 'generates a token on create' do- expect(create(:cart).token).to be_present- end-- it 'is completed when completed_at is set' do- expect(build(:cart, completed_at: Time.current)).to be_completed- expect(build(:cart)).not_to be_completed- end-- it 'is completing while completing_at holds the cart' do- expect(build(:cart, completing_at: Time.current)).to be_completing- expect(build(:cart)).not_to be_completing- end-it 'scopes complete/incomplete on completed_at' doincomplete = create(:cart)complete = create(:cart, completed_at: Time.current)@@ -196,40 +166,6 @@ describe Spree::Cart, type: :model doendend- describe 'line item ownership' do- let(:cart) { create(:cart) }-- it 'owns line items and destroys them with the cart' do- line_item = create(:line_item, order: nil, cart: cart, currency: cart.currency)-- expect(line_item.owner).to eq(cart)- expect { cart.destroy }.to change(Spree::LineItem, :count).by(-1)- end- end-- describe 'order link' do- it 'links to the order completed from it' do- cart = create(:cart, completed_at: Time.current)- order = create(:order, cart: cart)-- expect(cart.order).to eq(order)- end- end-- describe '#warnings' do- let(:cart) { build(:cart) }-- it 'defaults to empty array' do- expect(cart.warnings).to eq([])- end-- it 'is a transient attribute (not persisted)' do- cart.warnings = [{ code: 'test', message: 'test' }]- cart.save!- expect(cart.reload.warnings).to eq([])- end- end-describe '#orderable_variants' dolet(:company) { create(:company, store: store) }let(:catalog) { create(:catalog, store: store) }@@ -327,15 +263,6 @@ describe Spree::Cart, type: :model docart.remove_out_of_stock_items!end-- context 'when cart is empty' do- let(:order) { create(:order, store: store, customer: user) }-- it 'does nothing' do- cart.remove_out_of_stock_items!- expect(cart.warnings).to eq([])- end- endenddescribe '#coupon_code=' dodiff --git a/spree/core/spec/models/spree/catalog_spec.rb b/spree/core/spec/models/spree/catalog_spec.rbindex d7ad398e95..eb9aff1c09 100644--- a/spree/core/spec/models/spree/catalog_spec.rb+++ b/spree/core/spec/models/spree/catalog_spec.rb@@ -22,10 +22,12 @@ describe Spree::Catalog, type: :model doit 'adds store products once, skipping duplicates and foreign rows' doproduct = create(:product, store: store)foreign = create(:product, store: create(:store))+ fresh = create(:product, store: store)catalog.add_products([product.id, foreign.id])expect(catalog.add_products([product.id])).to eq(0)- expect(catalog.products.reload).to contain_exactly(product)+ expect(catalog.add_products([product.id, fresh.id])).to eq(1)+ expect(catalog.products.reload).to contain_exactly(product, fresh)end# An owned list prices the assortment and nothing else, so it follows it@@ -62,15 +64,6 @@ describe Spree::Catalog, type: :model doexpect(catalog.products.reload).to contain_exactly(first, *later)end-- it 'adds a batch alongside an existing row without raising on the duplicate' do- existing = create(:product, store: store)- fresh = create(:product, store: store)- catalog.add_products([existing.id])-- expect(catalog.add_products([existing.id, fresh.id])).to eq(1)- expect(catalog.products.reload).to contain_exactly(existing, fresh)- endenddescribe '.for_company' do@@ -367,17 +360,6 @@ describe Spree::Catalog, type: :model doexpect(Spree::PriceList.with_deleted.find(price_list.id)).to be_presentend- it 'does not leave the destroyed catalog list pricing the store' do- price_list.update!(status: 'active')- catalog = create(:catalog, store: store, price_list: price_list)- Spree::Current.store = store- expect(Spree::Current.price_lists.map(&:id)).not_to include(price_list.id)-- catalog.destroy!-- expect(Spree::Current.price_lists.map(&:id)).not_to include(price_list.id)- end-# The binding is written with update_all, which never touches the# instance the caller holds. Left unsynced, that copy still reads# catalog_id as nil and detaching from the list side looks like a no-op.diff --git a/spree/core/spec/models/spree/category_spec.rb b/spree/core/spec/models/spree/category_spec.rbindex 09245ca115..70fd262d2c 100644--- a/spree/core/spec/models/spree/category_spec.rb+++ b/spree/core/spec/models/spree/category_spec.rb@@ -13,12 +13,6 @@ RSpec.describe Spree::Category, type: :model doexpect(described_class.new(name: 'Shoes', store: other)).to be_validend- it 'rejects a duplicate permalink within the same store' do- described_class.create!(name: 'Shoes', store: store)-- expect(described_class.new(name: 'Shoes', store: store)).not_to be_valid- end-# Guards the index itself, not the validation: top-level categories have# parent_id IS NULL, and the previous (permalink, parent_id, taxonomy_id)# index left them unconstrained because unique indexes treat NULLs as distinct.@@ -141,20 +135,6 @@ RSpec.describe Spree::Category, type: :model doexpect(category.parent).to be_nilexpect(category.store).to eq(store)end-- it 'does not require a taxonomy' do- category = described_class.new(name: 'Kitchen', store: store)- expect(category).to be_valid- expect(category.errors[:taxonomy]).to be_empty- end-- it 'copies the store from its parent' do- parent = described_class.create!(name: 'Kitchen', store: store)- child = described_class.create!(name: 'Pots', parent: parent)-- expect(child.store).to eq(store)- expect(child.taxonomy).to be_nil- endenddescribe 'store auto-resolution (#ensure_store)' do@@ -186,11 +166,6 @@ RSpec.describe Spree::Category, type: :model doenddescribe '.for_store / .for_stores' do- it 'finds categories by store_id' do- category = described_class.create!(name: 'Kitchen', store: store)- expect(described_class.for_store(store)).to include(category)- end-it 'excludes categories owned by another store' doother = create(:store)mine = described_class.create!(name: 'Mine', store: store)@@ -223,7 +198,7 @@ RSpec.describe Spree::Category, type: :model doadd(create(:product, store: store), phones)expect(phones.reload.products_count).to eq(1)- expect(phones.classifications.count).to eq(1) # direct+ expect(phones.product_categories.count).to eq(1) # directendit 'rolls subcategory products up to ancestors' do@@ -231,7 +206,7 @@ RSpec.describe Spree::Category, type: :model doadd(create(:product, store: store), laptops)expect(electronics.reload.products_count).to eq(2) # inclusive- expect(electronics.classifications.count).to eq(0) # nothing direct+ expect(electronics.product_categories.count).to eq(0) # nothing directexpect(phones.reload.products_count).to eq(1)expect(laptops.reload.products_count).to eq(1)end@@ -275,7 +250,6 @@ RSpec.describe Spree::Category, type: :model doexpect(other_root.reload.products_count).to eq(1) # gained itendend- let(:store) { @default_store }let(:category) { build(:category, name: 'Ruby on Rails', parent: nil) }it_behaves_like 'metadata'@@ -370,14 +344,6 @@ RSpec.describe Spree::Category, type: :model doexpect(category.permalink).to eql 'ni-hao'end- it 'stores old slugs in FriendlyIds history' do- # Stub out the unrelated methods that cannot handle a save without an id- allow(subject).to receive(:set_depth!)- expect(subject).to receive(:create_slug)- subject.permalink = 'custom-slug'- subject.run_callbacks :save- end-context 'with parent category' dolet(:parent) { FactoryBot.build(:category, permalink: 'brands') }@@ -456,10 +422,6 @@ RSpec.describe Spree::Category, type: :model doit { expect(described_class.whitelisted_ransackable_associations).not_to include('taxonomy') }end- describe '#cached_self_and_descendants_ids' do- it { expect(category.cached_self_and_descendants_ids).to eq(category.self_and_descendants.ids) }- end-describe '#localized_slugs_for_store' dolet(:store) { create(:store, default_locale: 'fr', supported_locales: 'en,pl,fr') }let!(:root_category) { create(:category, name: 'Categories', store: store) }@@ -655,61 +617,6 @@ RSpec.describe Spree::Category, type: :model doexpect(category.pretty_name).to eq(category.name)endend-- context '2+ lvl deep' do- let(:category_parent) { create(:category, name: 'Parent') }-- before do- category.parent = category_parent- category.save!- end-- it 'returns parent name and category name' do- expect(category.reload.pretty_name).to eq('Parent -> Category#1')- end-- context 'when name is updated' do- before do- category.name = 'New Name'- category.save!- end-- it 'returns the updated pretty name' do- expect(category.reload.pretty_name).to eq('Parent -> New Name')- end- end-- context 'when parent name is updated' do- before do- category_parent.name = 'New Parent'- category_parent.save!- end-- it 'returns the updated pretty name' do- expect(category.reload.pretty_name).to eq('New Parent -> Category#1')- end- end- end-- context 'when `always_use_translations` is disabled' do- before do- allow(Spree::Config).to receive(:always_use_translations).and_return(false)- end-- it 'sets the pretty name' do- expect(category.reload.pretty_name).to eq(category.name)- end- end-- context 'when `always_use_translations` is enabled' do- before do- allow(Spree::Config).to receive(:always_use_translations).and_return(true)- end-- it 'sets the pretty name' do- expect(category.reload.pretty_name).to eq(category.name)- end- endenddescribe '#active_products_with_descendants' do@@ -721,12 +628,6 @@ RSpec.describe Spree::Category, type: :model doit 'returns true' doexpect(root_category.reload.active_products_with_descendants.exists?).to be trueend-- it 'returns true when products aren\'t active' do- product.update(status: 'draft')-- expect(root_category.reload.products.exists?).to be true- endendcontext 'when only children categories have products' dodiff --git a/spree/core/spec/models/spree/channel/gating_spec.rb b/spree/core/spec/models/spree/channel/gating_spec.rbindex dd9bf5f79f..6e582249be 100644--- a/spree/core/spec/models/spree/channel/gating_spec.rb+++ b/spree/core/spec/models/spree/channel/gating_spec.rb@@ -19,12 +19,6 @@ RSpec.describe Spree::Channel::Gating, type: :model doexpect(channel.resolved_storefront_access).to eq('prices_hidden')end- it 'prefers the channel value over the store value' do- store.update!(preferred_storefront_access: 'login_required')- channel.update!(preferred_storefront_access: 'public')- expect(channel.resolved_storefront_access).to eq('public')- end-it 'clears the override (restores inheritance) when written blank' dostore.update!(preferred_storefront_access: 'login_required')channel.update!(preferred_storefront_access: 'public')@@ -40,10 +34,6 @@ RSpec.describe Spree::Channel::Gating, type: :model doenddescribe '#resolved_guest_checkout' do- it 'is nil on the channel by default (inherit)' do- expect(channel.preferred_guest_checkout).to be_nil- end-it 'falls back to the store default (true) when the channel is unset' doexpect(channel.resolved_guest_checkout).to be trueenddiff --git a/spree/core/spec/models/spree/channel_spec.rb b/spree/core/spec/models/spree/channel_spec.rbindex 67befb7a43..1c278f1190 100644--- a/spree/core/spec/models/spree/channel_spec.rb+++ b/spree/core/spec/models/spree/channel_spec.rb@@ -4,18 +4,6 @@ RSpec.describe Spree::Channel, type: :model dolet(:store) { @default_store }describe 'validations' do- it 'requires name' do- channel = described_class.new(store: store, code: 'pos')- expect(channel).not_to be_valid- expect(channel.errors[:name]).to be_present- end-- it 'requires code' do- channel = described_class.new(store: store)- expect(channel).not_to be_valid- expect(channel.errors[:code]).to be_present- end-it 'derives code from name when blank' dochannel = described_class.new(store: store, name: 'Point of Sale')channel.valid?@@ -33,27 +21,14 @@ RSpec.describe Spree::Channel, type: :model doexpect { described_class.find_by(code: ascii8) }.not_to raise_errorend- it 'requires code unique within a store' do+ it 'requires code unique within a store only' dodescribed_class.create!(store: store, name: 'POS', code: 'pos')duplicate = described_class.new(store: store, name: 'POS 2', code: 'pos')expect(duplicate).not_to be_validexpect(duplicate.errors[:code]).to be_present- end-- it 'allows the same code across different stores' do- described_class.create!(store: store, name: 'POS', code: 'pos')- other_store = create(:store)# Auto-seeded 'online' channel is fine; we test the same arbitrary code.- cross = described_class.new(store: other_store, name: 'POS', code: 'pos')-- expect(cross).to be_valid- end- end-- describe 'defaults' do- it 'is active by default' do- expect(described_class.new(store: store).active).to be true+ expect(described_class.new(store: create(:store), name: 'POS', code: 'pos')).to be_validendend@@ -106,13 +81,6 @@ RSpec.describe Spree::Channel, type: :model doendend- describe 'prefixed_id' do- it 'starts with ch_' do- channel = described_class.create!(store: store, name: 'POS', code: 'pos')- expect(channel.prefixed_id).to start_with('ch_')- end- end-describe '#can_be_deleted?' dolet(:fresh_store) { create(:store).tap { |s| s.channels.delete_all } }let!(:default_channel) { described_class.create!(store: fresh_store, name: 'Default', code: 'online', default: true) }diff --git a/spree/core/spec/models/spree/claim_spec.rb b/spree/core/spec/models/spree/claim_spec.rbindex b572ca953f..cd1caf4c53 100644--- a/spree/core/spec/models/spree/claim_spec.rb+++ b/spree/core/spec/models/spree/claim_spec.rb@@ -10,19 +10,7 @@ RSpec.describe Spree::Claim doexpect(claim).to be_openend- it 'is reachable from its order' do- claim = create(:claim, store: store)-- expect(claim.order.reload.claims).to include(claim)- end-describe 'reason' do- it 'records the merchant-owned reason' do- reason = create(:claim_reason, store: store, name: 'Arrived damaged')-- expect(create(:claim, store: store, reason: reason).reason).to eq(reason)- end-# A merchant mid-claim should not be blocked because nobody has curated# the vocabulary yet.it 'is optional' dodiff --git a/spree/core/spec/models/spree/classification_spec.rb b/spree/core/spec/models/spree/classification_spec.rbindex a9aca6faaf..fae22d650a 100644--- a/spree/core/spec/models/spree/classification_spec.rb+++ b/spree/core/spec/models/spree/classification_spec.rb@@ -22,19 +22,14 @@ module Spreeenddef positions_to_be_valid(category)- positions = category.reload.classifications.map(&:position)- expect(positions).to eq((1..category.classifications.count).to_a)- end-- it 'has a valid fixtures' do- expect positions_to_be_valid(taxon_with_5_products)- expect(Spree::ProductCategory.count).to eq 5+ positions = category.reload.product_categories.map(&:position)+ expect(positions).to eq((1..category.product_categories.count).to_a)endcontext 'removing product from category' dobefore dop = taxon_with_5_products.products[1]- expect(p.classifications.first.position).to eq(2)+ expect(p.product_categories.first.position).to eq(2)taxon_with_5_products.products.destroy(p)end@@ -59,7 +54,7 @@ module Spreecontext 'removing category from product' dobefore dop = taxon_with_5_products.products[1]- p.taxons.destroy(taxon_with_5_products)+ p.categories.destroy(taxon_with_5_products)p.save!end@@ -68,10 +63,10 @@ module Spreeendend- context "replacing product's taxons" do+ context "replacing product's categories" dobefore dop = taxon_with_5_products.products[1]- p.taxons = []+ p.categories = []p.save!end@@ -82,7 +77,7 @@ module Spreecontext 'destroying classification' dobefore do- classification = taxon_with_5_products.classifications[1]+ classification = taxon_with_5_products.product_categories[1]classification.destroyend@@ -112,12 +107,6 @@ module Spreeclassification.destroy}.to change { category.reload.products_count }.from(1).to(0)end-- it 'correctly counts multiple classifications' do- products = create_list(:product, 3)- products.each { |p| create(:product_category, category: category, product: p) }- expect(category.reload.products_count).to eq(3)- endenddescribe 'categories_count on product' do@@ -133,12 +122,6 @@ module Spreeclassification.destroy}.to change { product.reload.categories_count }.from(1).to(0)end-- it 'correctly counts multiple classifications' do- taxons = create_list(:category, 3)- taxons.each { |t| create(:product_category, category: t, product: product) }- expect(product.reload.categories_count).to eq(3)- endendenddiff --git a/spree/core/spec/models/spree/collection_rule_spec.rb b/spree/core/spec/models/spree/collection_rule_spec.rbindex 4737bb2306..a9651458e5 100644--- a/spree/core/spec/models/spree/collection_rule_spec.rb+++ b/spree/core/spec/models/spree/collection_rule_spec.rb@@ -14,13 +14,6 @@ RSpec.describe Spree::CollectionRule, type: :model doexpect(rule).not_to be_validexpect(rule.errors[:match_policy]).to be_presentend-- it 'requires a value' do- rule = build(:tag_collection_rule, :is_equal_to, collection: collection, value: nil)-- expect(rule).not_to be_valid- expect(rule.errors[:value]).to be_present- endend# Assert the callback reaches the collection's regeneration; stub only thediff --git a/spree/core/spec/models/spree/collection_spec.rb b/spree/core/spec/models/spree/collection_spec.rbindex 53936b15ad..c205e6ad87 100644--- a/spree/core/spec/models/spree/collection_spec.rb+++ b/spree/core/spec/models/spree/collection_spec.rb@@ -3,14 +3,6 @@ require 'spec_helper'RSpec.describe Spree::Collection, type: :model dolet(:store) { @default_store }- describe 'metadata' do- it 'defaults to an empty hash and round-trips a JSON value' do- collection = create(:collection, metadata: { erp_id: '123' })- expect(create(:collection).metadata).to eq({})- expect(collection.reload.metadata).to eq({ 'erp_id' => '123' })- end- end-describe 'permalink generation' doit 'derives a url-safe permalink from the name' doexpect(create(:collection, name: 'Summer Sale').permalink).to eq('summer-sale')diff --git a/spree/core/spec/models/spree/commission_rate_spec.rb b/spree/core/spec/models/spree/commission_rate_spec.rbindex 768aa447e7..79261ffb71 100644--- a/spree/core/spec/models/spree/commission_rate_spec.rb+++ b/spree/core/spec/models/spree/commission_rate_spec.rb@@ -180,12 +180,6 @@ RSpec.describe Spree::CommissionRate, type: :model doexpect(rate.amount_for('EUR')).to be_nilend- # A flat fee charging nothing anywhere is skipped for every sale, which- # reads as a broken rate rather than a disabled one.- it 'refuses a flat fee that states no amount at all' do- expect(build(:commission_rate, kind: 'fixed', value: 0)).not_to be_valid- end-# Charging the flat amount again per parcel would bill one sale twice, so# a marketplace wanting a flat delivery charge states it as its own rate.it 'refuses to also charge delivery' do@@ -375,13 +369,6 @@ RSpec.describe Spree::CommissionRate, type: :model do# The list IS the precedence, so a new rate has to take effect on# creation — appending would file it behind the catch-all that already# matches everything, leaving it dead on arrival.- it 'puts a new rate at the top of the list' do- first = create(:commission_rate, store: store)- second = create(:commission_rate, store: store)-- expect(described_class.ordered.to_a).to eq([second, first])- end-it 'walks the list top-down' dobottom = create(:commission_rate, store: store)top = create(:commission_rate, store: store)diff --git a/spree/core/spec/models/spree/company_spec.rb b/spree/core/spec/models/spree/company_spec.rbindex 1e1639f97f..efe19ead8a 100644--- a/spree/core/spec/models/spree/company_spec.rb+++ b/spree/core/spec/models/spree/company_spec.rb@@ -44,24 +44,11 @@ describe Spree::Company, type: :model doexpect(build(:company, store: store)).to be_validend-- it 'carries one identity per external system' do- company = create(:company, store: store)- company.set_external_id('erp', 'ACME')- company.set_external_id('crm', 'CUST-1')-- expect(company.external_id_for('erp')).to eq('ACME')- expect(company.external_id_for('crm')).to eq('CUST-1')- endenddescribe 'the tree' dolet(:root) { create(:company, store: store) }- it 'defaults a node to the company kind' do- expect(Spree::Company.new.kind).to eq('company')- end-it 'refuses a division at the root' doexpect(build(:company, store: store, kind: 'division')).not_to be_validend@@ -259,14 +246,6 @@ describe Spree::Company, type: :model doendend- describe 'metadata' do- it 'persists to the single metadata column' do- company = create(:company, store: store, metadata: { 'erp_ref' => 'X-1' })-- expect(company.reload.metadata['erp_ref']).to eq('X-1')- end- end-describe 'deletion' do# There is no foreign key behind spree_orders.company_id and children are# destroyed with the node, so an unguarded delete would strand a placed@@ -299,15 +278,4 @@ describe Spree::Company, type: :model doexpect(company.destroy).to be_truthyendend-- it 'destroys its memberships, addresses and invitations' do- company = create(:company, store: store)- create(:company_membership, company: company)- create(:company_address, owner: company)- create(:company_invitation, company: company)-- expect { company.destroy }.to change(Spree::CompanyMembership, :count).by(-1).- and change(Spree::Address, :count).by(-1).- and change(Spree::CompanyInvitation, :count).by(-1)- endenddiff --git a/spree/core/spec/models/spree/concerns/admin_user_methods_spec.rb b/spree/core/spec/models/spree/concerns/admin_user_methods_spec.rbindex 5e4e38e421..265251bc18 100644--- a/spree/core/spec/models/spree/concerns/admin_user_methods_spec.rb+++ b/spree/core/spec/models/spree/concerns/admin_user_methods_spec.rb@@ -4,16 +4,6 @@ describe Spree::AdminUserMethods dolet(:admin_user) { create(:admin_user) }let(:current_store) { @default_store }- describe 'prefixed_id' do- it 'generates a prefixed_id starting with adm_' do- expect(admin_user.prefixed_id).to start_with('adm_')- end-- it 'uses prefixed_id as to_param' do- expect(admin_user.to_param).to eq(admin_user.prefixed_id)- end- end-describe 'normalizations' doit 'normalizes email' doadmin_user.update(email: ' [email protected] ')@@ -67,44 +57,9 @@ describe Spree::AdminUserMethods doendend- describe 'selected_locale' do- # The admin-UI display language is a client concern (the React dashboard- # ships its own locale bundles); the backend just stores the preference and- # does NOT validate it against Spree.available_locales (Rails/Spree- # locales), which is an unrelated list. Each consumer applies it against its- # own supported set.- it 'stores any locale code, including ones the Rails backend has no translations for' do- admin_user.update(selected_locale: 'pl')- expect(admin_user.reload.selected_locale).to eq('pl')- end-- it 'accepts a blank value' do- admin_user.update!(selected_locale: 'pl')- admin_user.update!(selected_locale: nil)- expect(admin_user.reload.selected_locale).to be_nil- end- end-- describe 'ransackable attributes' do- it 'allows searching by id' do- expect(Spree.admin_user_class.ransackable_attributes).to include('id')- end-- it 'allows searching by email' do- expect(Spree.admin_user_class.ransackable_attributes).to include('email')- end-- it 'allows searching by first_name' do- expect(Spree.admin_user_class.ransackable_attributes).to include('first_name')- end-- it 'allows searching by last_name' do- expect(Spree.admin_user_class.ransackable_attributes).to include('last_name')- end- end-- describe 'ransackable associations' do- it 'allows searching by spree_roles' do+ describe 'ransackable attributes and associations' do+ it 'allows searching by id, email, names and roles' do+ expect(Spree.admin_user_class.ransackable_attributes).to include('id', 'email', 'first_name', 'last_name')expect(Spree.admin_user_class.ransackable_associations).to include('spree_roles')endend@@ -181,43 +136,4 @@ describe Spree::AdminUserMethods doendendend-- describe 'class configuration' do- it 'uses a different class than Spree.customer_class' do- expect(Spree.admin_user_class).to eq(Spree::AdminUser)- expect(Spree.customer_class).to eq(Spree::Customer)- expect(Spree.admin_user_class).not_to eq(Spree.customer_class)- end-- it 'does not include CustomerMethods' do- expect(Spree::AdminUser.included_modules).not_to include(Spree::CustomerMethods)- end-- it 'includes AdminUserMethods' do- expect(Spree::AdminUser.included_modules).to include(Spree::AdminUserMethods)- end- end-- describe 'avatar attachment' do- it 'can attach an avatar' do- admin_user.avatar.attach(- io: File.open(Spree::Core::Engine.root.join('spec', 'fixtures', 'thinking-cat.jpg')),- filename: 'avatar.jpg',- content_type: 'image/jpeg'- )- expect(admin_user.avatar).to be_attached- end- end-- describe 'roles integration' do- it 'can have roles assigned' do- role = create(:role, name: 'custom_role')- admin_user.add_role('custom_role', current_store)- expect(admin_user.has_spree_role?('custom_role', current_store)).to be(true)- end-- it 'can check admin status' do- expect(admin_user.spree_admin?(current_store)).to be(true)- end- endenddiff --git a/spree/core/spec/models/spree/concerns/metadata_spec.rb b/spree/core/spec/models/spree/concerns/metadata_spec.rbindex 32ca5ae800..3b87faff5d 100644--- a/spree/core/spec/models/spree/concerns/metadata_spec.rb+++ b/spree/core/spec/models/spree/concerns/metadata_spec.rb@@ -3,26 +3,6 @@ require 'spec_helper'RSpec.describe Spree::Metadata dolet(:product) { build(:product) }- describe '#metadata' do- it 'defaults to an empty hash' do- expect(product.metadata).to eq({})- end-- it 'reads back with indifferent access' do- product.metadata = { 'key' => 'value' }- expect(product.metadata[:key]).to eq('value')- expect(product.metadata['key']).to eq('value')- end- end-- describe 'merge semantics' do- it 'supports merging metadata' do- product.metadata = { 'a' => '1' }- product.metadata = product.metadata.merge('b' => '2')- expect(product.metadata).to eq('a' => '1', 'b' => '2')- end- end-describe 'the private_metadata deprecation bridge' doit 'reads through to metadata with a warning' doproduct.metadata = { 'key' => 'value' }@@ -38,10 +18,4 @@ RSpec.describe Spree::Metadata doexpect(product.metadata).to eq('key' => 'value')endend-- describe 'public_metadata' do- it 'is gone' do- expect(product).not_to respond_to(:public_metadata)- end- endenddiff --git a/spree/core/spec/models/spree/concerns/prefixed_id_spec.rb b/spree/core/spec/models/spree/concerns/prefixed_id_spec.rbindex 7d93d376c1..554a29d90e 100644--- a/spree/core/spec/models/spree/concerns/prefixed_id_spec.rb+++ b/spree/core/spec/models/spree/concerns/prefixed_id_spec.rb@@ -87,14 +87,6 @@ RSpec.describe Spree::PrefixedId doexpect(session.external_id).to eq('seti_test456')endend-- context 'with no prefixed IDs present' do- it 'does not modify attributes' do- product = build(:product)- product.assign_attributes(name: 'Updated Name')- expect(product.name).to eq('Updated Name')- end- endenddescribe '.find_by_prefix_id!' dodiff --git a/spree/core/spec/models/spree/concerns/user_management_spec.rb b/spree/core/spec/models/spree/concerns/user_management_spec.rbindex 1a38530fbe..ef5e30ba49 100644--- a/spree/core/spec/models/spree/concerns/user_management_spec.rb+++ b/spree/core/spec/models/spree/concerns/user_management_spec.rb@@ -49,34 +49,4 @@ describe Spree::UserManagement doendendend-- describe 'associations' do- it 'has many roles' do- association = test_store.class.reflect_on_association(:roles)- expect(association.macro).to eq :has_many- expect(association.options[:class_name]).to eq 'Spree::Role'- expect(association.options[:as]).to eq :resource- end-- # Assignments reach the resource through its roles, not directly.- it 'has many role_users through roles' do- association = test_store.class.reflect_on_association(:role_users)- expect(association.macro).to eq :has_many- expect(association.options[:through]).to eq :roles- end-- it 'has many users through role_users' do- association = test_store.class.reflect_on_association(:users)- expect(association.macro).to eq :has_many- expect(association.options[:through]).to eq :role_users- expect(association.options[:source]).to eq :user- expect(association.options[:source_type]).to eq Spree.admin_user_class.to_s- end-- it 'has many invitations' do- association = test_store.class.reflect_on_association(:invitations)- expect(association.macro).to eq :has_many- expect(association.options[:class_name]).to eq 'Spree::Invitation'- end- endenddiff --git a/spree/core/spec/models/spree/concerns/user_methods_spec.rb b/spree/core/spec/models/spree/concerns/user_methods_spec.rbindex 10a0b3b311..a69a5e246f 100644--- a/spree/core/spec/models/spree/concerns/user_methods_spec.rb+++ b/spree/core/spec/models/spree/concerns/user_methods_spec.rb@@ -48,7 +48,7 @@ describe Spree::CustomerMethods doendcontext 'with incomplete canceled order' do- let(:canceled_order) { create(:order, customer: test_user, created_at: 1.day.ago, store: current_store, state: 'canceled') }+ let!(:canceled_order) { create(:order, customer: test_user, created_at: 1.day.ago, store: current_store, state: 'canceled') }it { is_expected.to be_nil }end@@ -132,19 +132,14 @@ describe Spree::CustomerMethods do# Superseded by Spree::Customers::Anonymize, which this now delegates to.# The tombstone names changed with it — the anonymizer's coverage is in# spec/workflows/spree/customers/anonymize_spec.rb.- it 'erases the email and names' do+ it 'warns and erases the email and names' doexpect { test_user.scramble_email_and_names }.to change(test_user, :email).and change(test_user, :first_name).and change(test_user, :last_name)+ expect(Spree::Deprecation).to have_received(:warn).at_least(:once)expect(test_user.first_name).to eq(Spree::Customers::Anonymize::REDACTED_NAME)expect(test_user.last_name).to eq(Spree::Customers::Anonymize::REDACTED_NAME)end-- it 'warns that it is deprecated' do- expect(Spree::Deprecation).to receive(:warn).at_least(:once)-- test_user.scramble_email_and_names- endenddescribe '#invited_by' dodiff --git a/spree/core/spec/models/spree/concerns/user_roles_spec.rb b/spree/core/spec/models/spree/concerns/user_roles_spec.rbindex 0def909def..7d18c9de1c 100644--- a/spree/core/spec/models/spree/concerns/user_roles_spec.rb+++ b/spree/core/spec/models/spree/concerns/user_roles_spec.rb@@ -11,26 +11,11 @@ describe Spree::UserRoles doexpect(test_user.has_spree_role?('test', current_store)).to be_truthyend-- context 'when a resource parameter is provided' do- let(:resource) { create(:store) }- # A role belongs to what it governs, so the grant needs one here.- let!(:resource_role) { create(:role, name: 'test', resource: resource) }-- before { test_user.add_role('test', resource) }-- it 'adds a role to the user for the resource' do- expect(test_user.has_spree_role?('test', resource)).to be_truthy- end- endenddescribe '#remove_role' doit 'removes a role from the user' dotest_user.add_role('test')-- expect(test_user.has_spree_role?('test')).to be_truthy-test_user.remove_role('test')expect(test_user.has_spree_role?('test')).to be_falsy@@ -93,8 +78,6 @@ describe Spree::UserRoles docontext 'when a resource parameter is provided' dolet(:resource) { create(:store) }- # A role belongs to what it governs, so the grant needs one here.- let!(:resource_role) { create(:role, name: 'test', resource: resource) }it 'checks against the resource' doSpree::Role.default_admin_role(resource)diff --git a/spree/core/spec/models/spree/country_spec.rb b/spree/core/spec/models/spree/country_spec.rbindex 16af73f512..e40c312bbd 100644--- a/spree/core/spec/models/spree/country_spec.rb+++ b/spree/core/spec/models/spree/country_spec.rb@@ -97,10 +97,6 @@ describe Spree::Country, type: :model doenddescribe '#default?' do- before do- allow_any_instance_of(Spree::Store).to receive(:default).and_return(store)- end-context 'no arguments' doit 'returns true for store default country' doexpect(america.default?).to eq(true)diff --git a/spree/core/spec/models/spree/coupon_code_spec.rb b/spree/core/spec/models/spree/coupon_code_spec.rbindex da254e7e75..2c02e0783a 100644--- a/spree/core/spec/models/spree/coupon_code_spec.rb+++ b/spree/core/spec/models/spree/coupon_code_spec.rb@@ -6,11 +6,6 @@ RSpec.describe Spree::CouponCode, type: :model dodescribe 'validations' dodescribe 'code' do- it 'validates presence' do- coupon_code.code = nil- expect(coupon_code).not_to be_valid- end-it 'validates uniqueness' doother_coupon_code = promotion.coupon_codes.lastdiff --git a/spree/core/spec/models/spree/credit_card_spec.rb b/spree/core/spec/models/spree/credit_card_spec.rbindex a5c538ec27..3212b089cf 100644--- a/spree/core/spec/models/spree/credit_card_spec.rb+++ b/spree/core/spec/models/spree/credit_card_spec.rb@@ -16,8 +16,6 @@ describe Spree::CreditCard, type: :model dolet(:payment) { create(:payment, amount: 100, order: order) }let(:payment_method) { create(:payment_method) }- before { allow(payment).to receive_messages payment_method: payment_method }-describe '#can_capture?' doshared_examples 'can be captured' doit 'can be captured' do@@ -111,18 +109,6 @@ describe Spree::CreditCard, type: :model doexpect(credit_card.errors[:verification_value]).to eq(["can't be blank"])end- it 'validates name presence' do- credit_card.valid?- expect(credit_card.errors).not_to be_empty- expect(credit_card.errors.messages[:name]).to be_present- end-- it 'only validates on create' do- credit_card.attributes = valid_credit_card_attributes- credit_card.save- expect(credit_card).to be_valid- end-context 'encrypted data is present' doit 'does not validate presence of number or cvv' docredit_card.encrypted_data = '$fdgsfgdgfgfdg&gfdgfdgsf-'@@ -338,12 +324,6 @@ describe Spree::CreditCard, type: :model doendend- context 'Associations' do- it 'is able to access its payments' do- expect { credit_card.payments.to_a }.not_to raise_error- end- end-describe '#first_name' dobefore docredit_card.name = 'Ludwig van Beethoven'@@ -398,6 +378,8 @@ describe Spree::CreditCard, type: :model docontext 'Scopes' dodescribe '#not_expired' do+ around { |example| Timecop.freeze(Time.current.change(month: 6, day: 15)) { example.run } }+let(:previous_year) { DateTime.now.year - 1 }let(:current_year) { DateTime.now.year }let(:next_year) { DateTime.now.year + 1 }@@ -500,7 +482,7 @@ describe Spree::CreditCard, type: :model doit 'invalidates the payment' docard.destroy- expect(checkout_payment.reload.state).to eq('invalid')+ expect(checkout_payment.reload.status).to eq('invalid')endend@@ -511,8 +493,8 @@ describe Spree::CreditCard, type: :model doit 'voids the payments' docard.destroy- expect(completed_payment.reload.state).to eq('void')- expect(pending_payment.reload.state).to eq('void')+ expect(completed_payment.reload.status).to eq('void')+ expect(pending_payment.reload.status).to eq('void')endend@@ -523,14 +505,8 @@ describe Spree::CreditCard, type: :model doit 'does not modify payments on completed orders' docard.destroy- expect(completed_order_payment.reload.state).to eq('completed')+ expect(completed_order_payment.reload.status).to eq('completed')endend-- it 'soft deletes the credit card' do- card.destroy-- expect(card.reload.deleted_at).not_to be_nil- endendenddiff --git a/spree/core/spec/models/spree/current_spec.rb b/spree/core/spec/models/spree/current_spec.rbindex 10ec4c6b51..6b2f3b19b5 100644--- a/spree/core/spec/models/spree/current_spec.rb+++ b/spree/core/spec/models/spree/current_spec.rb@@ -6,16 +6,6 @@ RSpec.describe Spree::Current doenddescribe '#store' do- context 'when store is set' do- let(:store) { create(:store) }-- before { described_class.store = store }-- it 'returns the set store' do- expect(described_class.store).to eq(store)- end- end-context 'when store is not set' doit 'returns the default store' doexpect(described_class.store).to eq(Spree::Store.default)@@ -24,14 +14,6 @@ RSpec.describe Spree::Current doenddescribe '#currency' do- context 'when currency is set' do- before { described_class.currency = 'EUR' }-- it 'returns the set currency' do- expect(described_class.currency).to eq('EUR')- end- end-context 'when currency is not set' dolet!(:store) { create(:store, default: true, default_currency: 'GBP') }@@ -42,16 +24,6 @@ RSpec.describe Spree::Current doenddescribe '#tax_country' do- context 'when tax_country is set' do- let(:country) { create(:country) }-- before { described_class.tax_country = country }-- it 'returns the set country' do- expect(described_class.tax_country).to eq(country)- end- end-context 'when tax_country is not set' dolet!(:store) { create(:store, default: true) }let(:market) { create(:market, store: store) }@@ -72,14 +44,6 @@ RSpec.describe Spree::Current doenddescribe '#locale' do- context 'when locale is set' do- before { described_class.locale = 'fr' }-- it 'returns the set locale' do- expect(described_class.locale).to eq('fr')- end- end-context 'when locale is not set but market has a default locale' dolet!(:store) { create(:store, default: true, default_locale: 'en') }let!(:market) { create(:market, store: store, default: true, default_locale: 'de') }@@ -107,14 +71,6 @@ RSpec.describe Spree::Current doenddescribe '#content_locale' do- context 'when content_locale is set' do- before { described_class.content_locale = 'de' }-- it 'returns the set content locale' do- expect(described_class.content_locale).to eq('de')- end- end-context 'when content_locale is not set' doit 'falls back to the application default locale' doexpect(described_class.content_locale).to eq(I18n.default_locale.to_s)@@ -131,16 +87,6 @@ RSpec.describe Spree::Current doenddescribe '#market' do- context 'when market is set' do- let(:market) { create(:market) }-- before { described_class.market = market }-- it 'returns the set market' do- expect(described_class.market).to eq(market)- end- end-context 'when market is not set' dolet!(:store) { create(:store, default: true) }let!(:market) { create(:market, store: store, default: true) }@@ -149,14 +95,6 @@ RSpec.describe Spree::Current doexpect(described_class.market).to eq(market)endend-- context 'when market is not set' do- let!(:store) { create(:store, default: true) }-- it 'falls back to the store default market' do- expect(described_class.market).to eq(store.default_market)- end- endenddescribe '#global_pricing_context' do@@ -169,10 +107,6 @@ RSpec.describe Spree::Current dodescribed_class.market = marketend- it 'returns a Spree::Pricing::Context' do- expect(described_class.global_pricing_context).to be_a(Spree::Pricing::Context)- end-it 'uses the current store' doexpect(described_class.global_pricing_context.store).to eq(store)end@@ -220,10 +154,6 @@ RSpec.describe Spree::Current doexpect(described_class.price_lists).not_to include(other_store_price_list)end- it 'includes active price lists' do- expect(described_class.price_lists).to include(active_price_list)- end-it 'includes scheduled price lists within date range' doexpect(described_class.price_lists).to include(scheduled_price_list)end@@ -367,12 +297,6 @@ RSpec.describe Spree::Current doenddescribe '#provider_cache' do- it 'defaults to a hash providers can memoize into' do- described_class.provider_cache[:quote] = 'cached'-- expect(described_class.provider_cache[:quote]).to eq('cached')- end-# Carrier quotes are request-scoped; leaking them across requests would# price one customer's checkout with another's destination.it 'is cleared between requests' dodiff --git a/spree/core/spec/models/spree/custom_field_definition_spec.rb b/spree/core/spec/models/spree/custom_field_definition_spec.rbindex 69c48293db..7c09a4c03c 100644--- a/spree/core/spec/models/spree/custom_field_definition_spec.rb+++ b/spree/core/spec/models/spree/custom_field_definition_spec.rb@@ -181,13 +181,6 @@ RSpec.describe Spree::CustomFieldDefinition, type: :model doSpree::Current.store = nilend- it 'is reachable through the store association' do- custom_field_definition = create(:custom_field_definition, store: other_store)-- expect(other_store.custom_field_definitions).to include(custom_field_definition)- expect(@default_store.custom_field_definitions).not_to include(custom_field_definition)- end-it 'allows the same namespace and key in two stores' docreate(:custom_field_definition, store: @default_store, resource_type: 'Spree::Product',namespace: 'custom', key: 'material')@@ -218,15 +211,6 @@ RSpec.describe Spree::CustomFieldDefinition, type: :model doexpect(colliding.errors[:filter_key]).to be_presentend- it 'allows the same filter_key in a different store' do- create(:custom_field_definition, store: @default_store, resource_type: 'Spree::Product',- namespace: 'a_b', key: 'c')- other_store = build(:custom_field_definition, store: create(:store), resource_type: 'Spree::Product',- namespace: 'a', key: 'b_c')-- expect(other_store).to be_valid- end-it 'allows the same namespace/key split on a different resource type' docreate(:custom_field_definition, resource_type: 'Spree::Product', namespace: 'a_b', key: 'c')other_resource = build(:custom_field_definition, resource_type: 'Spree::Variant', namespace: 'a', key: 'b_c')diff --git a/spree/core/spec/models/spree/custom_field_spec.rb b/spree/core/spec/models/spree/custom_field_spec.rbindex 5a6e6c459b..1ef896a2f2 100644--- a/spree/core/spec/models/spree/custom_field_spec.rb+++ b/spree/core/spec/models/spree/custom_field_spec.rb@@ -29,13 +29,6 @@ RSpec.describe Spree::CustomField, type: :model doendend- describe '#serialize_value' do- it 'returns the value' do- custom_field = build(:custom_field, value: 'Test Value')- expect(custom_field.serialize_value).to eq('Test Value')- end- end-describe '#csv_value' docontext 'for base CustomField' doit 'returns the value as string' do@@ -76,24 +69,6 @@ RSpec.describe Spree::CustomField, type: :model doendend- context 'for ShortText custom_field' do- let(:custom_field_definition) { create(:custom_field_definition, field_type: 'Spree::CustomFields::ShortText') }-- it 'returns the text value' do- custom_field = Spree::CustomFields::ShortText.new(custom_field_definition: custom_field_definition, value: 'Short text')- expect(custom_field.csv_value).to eq('Short text')- end- end-- context 'for LongText custom_field' do- let(:custom_field_definition) { create(:custom_field_definition, field_type: 'Spree::CustomFields::LongText') }-- it 'returns the text value' do- custom_field = Spree::CustomFields::LongText.new(custom_field_definition: custom_field_definition, value: 'Long text content')- expect(custom_field.csv_value).to eq('Long text content')- end- end-context 'for RichText custom_field' dolet(:custom_field_definition) { create(:custom_field_definition, field_type: 'Spree::CustomFields::RichText') }@@ -188,6 +163,7 @@ RSpec.describe Spree::CustomField, type: :model doit 'assigns through metafield_definition=' dodefinition = create(:custom_field_definition)custom_field = Spree::CustomField.new+ expect(Spree::Deprecation).to receive(:warn).with(/metafield_definition= is deprecated/)custom_field.metafield_definition = definitionexpect(custom_field.custom_field_definition).to eq(definition)diff --git a/spree/core/spec/models/spree/custom_fields/boolean_spec.rb b/spree/core/spec/models/spree/custom_fields/boolean_spec.rbindex 6e5a2eaf7a..1fc422c741 100644--- a/spree/core/spec/models/spree/custom_fields/boolean_spec.rb+++ b/spree/core/spec/models/spree/custom_fields/boolean_spec.rb@@ -24,11 +24,4 @@ describe Spree::CustomFields::Boolean, type: :model doexpect(custom_field.csv_value).to eq('Yes')endend-- describe '.searchable? / .sortable?' do- it 'is neither searchable nor sortable (filterable in Phase 6)' do- expect(described_class.searchable?).to eq(false)- expect(described_class.sortable?).to eq(false)- end- endenddiff --git a/spree/core/spec/models/spree/custom_fields/number_spec.rb b/spree/core/spec/models/spree/custom_fields/number_spec.rbindex 87d1dafd90..722c31452b 100644--- a/spree/core/spec/models/spree/custom_fields/number_spec.rb+++ b/spree/core/spec/models/spree/custom_fields/number_spec.rb@@ -26,11 +26,4 @@ describe Spree::CustomFields::Number, type: :model doexpect(custom_field.csv_value).to eq('123.0')endend-- describe '.searchable? / .sortable?' do- it 'is searchable and sortable' do- expect(described_class.searchable?).to eq(true)- expect(described_class.sortable?).to eq(true)- end- endenddiff --git a/spree/core/spec/models/spree/custom_fields/rich_text_spec.rb b/spree/core/spec/models/spree/custom_fields/rich_text_spec.rbindex fa8b616ac0..9d9a14b3fc 100644--- a/spree/core/spec/models/spree/custom_fields/rich_text_spec.rb+++ b/spree/core/spec/models/spree/custom_fields/rich_text_spec.rb@@ -8,12 +8,6 @@ describe Spree::CustomFields::RichText, type: :model dovalue: '<p>Rich text with <strong>formatting</strong></p>')end- describe '#value' do- it 'stores HTML in the shared value column' do- expect(custom_field.value).to eq('<p>Rich text with <strong>formatting</strong></p>')- end- end-describe '#serialize_value' doit 'returns the stored HTML' doexpect(custom_field.serialize_value).to eq('<p>Rich text with <strong>formatting</strong></p>')diff --git a/spree/core/spec/models/spree/custom_fields/short_text_spec.rb b/spree/core/spec/models/spree/custom_fields/short_text_spec.rbdeleted file mode 100644index addb106b5a..0000000000--- a/spree/core/spec/models/spree/custom_fields/short_text_spec.rb+++ /dev/null@@ -1,12 +0,0 @@-# frozen_string_literal: true--require 'spec_helper'--describe Spree::CustomFields::ShortText, type: :model do- describe '.searchable? / .sortable?' do- it 'is searchable and sortable' do- expect(described_class.searchable?).to eq(true)- expect(described_class.sortable?).to eq(true)- end- end-enddiff --git a/spree/core/spec/models/spree/customer_group_spec.rb b/spree/core/spec/models/spree/customer_group_spec.rbindex 6250e98e92..8f7fd4e26b 100644--- a/spree/core/spec/models/spree/customer_group_spec.rb+++ b/spree/core/spec/models/spree/customer_group_spec.rb@@ -5,32 +5,11 @@ RSpec.describe Spree::CustomerGroup, type: :model dolet(:customer_group) { create(:customer_group, store: store) }describe 'validations' do- context 'uniqueness' do- let!(:existing_group) { create(:customer_group, name: 'VIP', store: store) }+ it 'validates uniqueness of name within store scope' do+ create(:customer_group, name: 'VIP', store: store)- it 'validates uniqueness of name within store scope' do- new_group = build(:customer_group, name: 'VIP', store: store)- expect(new_group).not_to be_valid- expect(new_group.errors[:name]).to include('has already been taken')- end-- it 'allows same name in different store' do- other_store = create(:store)- new_group = build(:customer_group, name: 'VIP', store: other_store)- expect(new_group).to be_valid- end- end- end-- describe 'scopes' do- describe '.for_store' do- let!(:group1) { create(:customer_group, store: store) }- let!(:group2) { create(:customer_group, store: create(:store)) }-- it 'returns groups for the specified store' do- expect(described_class.for_store(store)).to include(group1)- expect(described_class.for_store(store)).not_to include(group2)- end+ expect(build(:customer_group, name: 'VIP', store: store)).not_to be_valid+ expect(build(:customer_group, name: 'VIP', store: create(:store))).to be_validendend@@ -48,30 +27,19 @@ RSpec.describe Spree::CustomerGroup, type: :model doendend- describe 'soft delete' do- it 'supports soft deletion' do- customer_group.destroy- expect(described_class.with_deleted.find(customer_group.id)).to be_present- expect(described_class.find_by(id: customer_group.id)).to be_nil- end- end-describe '#add_customers' dolet(:user1) { create(:user) }let(:user2) { create(:user) }let(:user3) { create(:user) }- it 'adds customers to the group' do+ it 'adds customers to the group and returns how many were added' do+ count = nilexpect {- customer_group.add_customers([user1.id, user2.id])+ count = customer_group.add_customers([user1.id, user2.id])}.to change { customer_group.customer_group_users.count }.by(2)- expect(customer_group.users).to include(user1, user2)- end-- it 'returns the count of added customers' do- count = customer_group.add_customers([user1.id, user2.id])expect(count).to eq(2)+ expect(customer_group.users).to include(user1, user2)endit 'skips users already in the group' do@@ -131,20 +99,17 @@ RSpec.describe Spree::CustomerGroup, type: :model docustomer_group.add_customers([user1.id, user2.id, user3.id])end- it 'removes customers from the group' do+ it 'removes customers from the group and returns how many were removed' do+ count = nilexpect {- customer_group.remove_customers([user1.id, user2.id])+ count = customer_group.remove_customers([user1.id, user2.id])}.to change { customer_group.customer_group_users.count }.by(-2)+ expect(count).to eq(2)expect(customer_group.users).not_to include(user1, user2)expect(customer_group.users).to include(user3)end- it 'returns the count of removed customers' do- count = customer_group.remove_customers([user1.id, user2.id])- expect(count).to eq(2)- end-it 'returns 0 when users are not in the group' doother_user = create(:user)count = customer_group.remove_customers([other_user.id])diff --git a/spree/core/spec/models/spree/customer_group_user_spec.rb b/spree/core/spec/models/spree/customer_group_user_spec.rbdeleted file mode 100644index cc01155fdd..0000000000--- a/spree/core/spec/models/spree/customer_group_user_spec.rb+++ /dev/null@@ -1,24 +0,0 @@-require 'spec_helper'--RSpec.describe Spree::CustomerGroupUser, type: :model do- let(:customer_group) { create(:customer_group) }- let(:user) { create(:user) }-- describe 'validations' do- context 'uniqueness' do- let!(:existing) { create(:customer_group_user, customer_group: customer_group, customer: user) }-- it 'validates uniqueness of customer_group_id within user scope' do- duplicate = build(:customer_group_user, customer_group: customer_group, customer: user)- expect(duplicate).not_to be_valid- expect(duplicate.errors[:customer_group_id]).to include('has already been taken')- end-- it 'allows same user in different groups' do- other_group = create(:customer_group)- new_membership = build(:customer_group_user, customer_group: other_group, customer: user)- expect(new_membership).to be_valid- end- end- end-enddiff --git a/spree/core/spec/models/spree/customer_spec.rb b/spree/core/spec/models/spree/customer_spec.rbindex 24de728ddd..4207013298 100644--- a/spree/core/spec/models/spree/customer_spec.rb+++ b/spree/core/spec/models/spree/customer_spec.rb@@ -4,14 +4,6 @@ describe Spree::Customer, type: :model dosubject(:customer) { create(:customer, password: 'secret-123', password_confirmation: 'secret-123') }describe 'has_secure_password' do- it 'authenticates with the correct password' do- expect(customer.authenticate('secret-123')).to eq(customer)- end-- it 'rejects an incorrect password' do- expect(customer.authenticate('wrong')).to be(false)- end-it 'exposes valid_password? as an alias for authenticate' doexpect(customer.valid_password?('secret-123')).to be(true)expect(customer.valid_password?('wrong')).to be(false)@@ -22,18 +14,6 @@ describe Spree::Customer, type: :model doendend- describe 'validations' do- it 'requires an email' do- expect(build(:customer, email: nil)).not_to be_valid- end-- it 'enforces case-insensitive email uniqueness' do- customer- dup = build(:customer, email: customer.email.upcase)- expect(dup).not_to be_valid- end- end-describe 'password reset tokens' doit 'round-trips through find_by_password_reset_token' dotoken = customer.generate_token_for(:password_reset)@@ -77,10 +57,4 @@ describe Spree::Customer, type: :model doexpect(customer.reload.ship_address_id).to eq(labelled.id)endend-- describe 'prefixed id' do- it 'uses the cust_ prefix' do- expect(customer.prefixed_id).to start_with('cust_')- end- endenddiff --git a/spree/core/spec/models/spree/data_feed/google_spec.rb b/spree/core/spec/models/spree/data_feed/google_spec.rbindex feb84efcf5..bd34f27dd5 100644--- a/spree/core/spec/models/spree/data_feed/google_spec.rb+++ b/spree/core/spec/models/spree/data_feed/google_spec.rb@@ -33,12 +33,4 @@ describe Spree::DataFeed::Google, type: :model doexpect(data_feed.formatted_url).to eq(expected_url)endend-- describe '.label' do- subject { Spree::DataFeed::Google.label }-- it 'returns a descriptive label' do- expect(subject).to eq('Google Merchant Center Feed')- end- endenddiff --git a/spree/core/spec/models/spree/delivery_method_rule_spec.rb b/spree/core/spec/models/spree/delivery_method_rule_spec.rbindex 4104dca49d..39b808e6d7 100644--- a/spree/core/spec/models/spree/delivery_method_rule_spec.rb+++ b/spree/core/spec/models/spree/delivery_method_rule_spec.rb@@ -175,7 +175,7 @@ describe Spree::DeliveryMethodRule, type: :model dolet(:company_package) docreate(:company_membership, company: company, customer: customer)- cart = create(:cart, store: store, user: customer, company: company)+ cart = create(:cart, store: store, customer: customer, company: company)create(:line_item, cart: cart, order: nil)fulfillment = create(:fulfillment, cart: cart, order: nil, stock_location: create(:stock_location))fulfillment.to_package@@ -190,13 +190,6 @@ describe Spree::DeliveryMethodRule, type: :model doexpect(rule.eligible?(package)).to be(false)end- it 'hides a freight method from a retail cart' do- rule = described_class.new(delivery_method: delivery_method, preferred_company_orders_only: true)-- expect(rule.eligible?(company_package)).to be(true)- expect(rule.eligible?(package)).to be(false)- end-it 'hides a parcel method from a company cart when turned off' dorule = described_class.new(delivery_method: delivery_method, preferred_company_orders_only: false)diff --git a/spree/core/spec/models/spree/delivery_method_spec.rb b/spree/core/spec/models/spree/delivery_method_spec.rbindex 019c52d1ec..1d3c7df2f8 100644--- a/spree/core/spec/models/spree/delivery_method_spec.rb+++ b/spree/core/spec/models/spree/delivery_method_spec.rb@@ -84,13 +84,6 @@ describe Spree::DeliveryMethod, type: :model doexpect(method.requires_zone_check?).to be falseendend-- it 'is true for the Manual provider' do- method = create(:delivery_method)-- expect(method.fulfillment_provider).to eq('Spree::FulfillmentProvider::Manual')- expect(method.requires_address?).to be true- endenddescribe '#serves_location?' do@@ -148,30 +141,10 @@ describe Spree::DeliveryMethod, type: :model do])expect(described_class.calculators).to eq([Spree::Calculator::Shipping::FlatPercentItemTotal, Spree::Calculator::Shipping::PriceSack, DummyShippingCalculator])- expect(described_class.calculators).not_to eq([Spree::Calculator::FlatRate])- end- end-- # Regression test for #4492- context '#shipments' do- let!(:delivery_method) { create(:delivery_method) }- let!(:shipment) do- shipment = create(:fulfillment)- shipment.shipping_rates.create!(delivery_method: delivery_method)- shipment- end-- it 'can gather all the related shipments' do- expect(delivery_method.shipments).to include(shipment)endendcontext 'validations' do- it 'validates presence of name' do- subject.valid?- expect(subject.errors.messages[:name].size).to eq(1)- end-it 'requires a name unique within the store and owner' docreate(:delivery_method, name: 'Standard')@@ -181,14 +154,6 @@ describe Spree::DeliveryMethod, type: :model doexpect(build(:delivery_method, name: 'Standard', seller: create(:seller))).to be_validend- it 'defaults to storefront visible and rejects a blank value' do- expect(subject.storefront_visible).to be true-- subject.storefront_visible = nil- subject.valid?- expect(subject.errors.messages[:storefront_visible].size).not_to be_zero- end-context 'shipping method does not have a tracking URL mask on file' dolet(:usps_tracking_number) { '1Z879E930346834440' }@@ -317,16 +282,6 @@ describe Spree::DeliveryMethod, type: :model doendend- # Regression test for #4320- context 'soft deletion' do- let(:delivery_method) { create(:delivery_method) }-- it 'soft-deletes when destroy is called' do- delivery_method.destroy- expect(delivery_method.deleted_at).not_to be_blank- end- end-describe '#available_to?' docontext 'for the storefront' doit { expect(visible_delivery_method.available_to?(described_class::STOREFRONT)).to be true }@@ -534,10 +489,6 @@ describe Spree::DeliveryMethod, type: :model doit 'offers a first-party package the marketplace methods only' doexpect(described_class.available_to_seller(nil)).to contain_exactly(marketplace_method, shared_method)end-- it "never offers one seller another seller's method" do- expect(described_class.available_to_seller(seller)).not_to include(other_sellers_method)- endendendenddiff --git a/spree/core/spec/models/spree/delivery_rate_provider/base_spec.rb b/spree/core/spec/models/spree/delivery_rate_provider/base_spec.rbindex ff8987d7ee..9db52d93de 100644--- a/spree/core/spec/models/spree/delivery_rate_provider/base_spec.rb+++ b/spree/core/spec/models/spree/delivery_rate_provider/base_spec.rb@@ -9,13 +9,6 @@ RSpec.describe Spree::DeliveryRateProvider::Base doexpect { described_class.new(delivery_method).estimate(nil) }.to raise_error(NotImplementedError)end- it 'no-ops the optional lifecycle hooks' do- provider = described_class.new(delivery_method)-- expect { provider.book(nil) }.not_to raise_error- expect { provider.release(nil) }.not_to raise_error- end-it 'needs no integration by default' doexpect(described_class.integration_class).to be_nilexpect(described_class.available_for_store?(store)).to be(true)diff --git a/spree/core/spec/models/spree/delivery_rate_provider/freight_spec.rb b/spree/core/spec/models/spree/delivery_rate_provider/freight_spec.rbindex ca7d5d02f5..4a6bc0e4db 100644--- a/spree/core/spec/models/spree/delivery_rate_provider/freight_spec.rb+++ b/spree/core/spec/models/spree/delivery_rate_provider/freight_spec.rb@@ -36,13 +36,4 @@ RSpec.describe Spree::DeliveryRateProvider::Freight doexpect(summary['total_pallets']).to eq(1)expect(summary['complete']).to be(true)end-- it 'ships to an address and never consults a calculator' do- expect(described_class.requires_address?).to be(true)- expect(described_class.uses_calculator?).to be(false)- end-- it 'is registered as a selectable rate provider' do- expect(Spree.delivery_rate_providers).to include(described_class)- endenddiff --git a/spree/core/spec/models/spree/delivery_rate_spec.rb b/spree/core/spec/models/spree/delivery_rate_spec.rbindex b5af13dfc3..73479bd674 100644--- a/spree/core/spec/models/spree/delivery_rate_spec.rb+++ b/spree/core/spec/models/spree/delivery_rate_spec.rb@@ -67,16 +67,6 @@ describe Spree::DeliveryRate, type: :model doexpect(shipping_rate.display_price.to_s).to eq("$10.00 (incl. $1.67 #{non_default_tax_rate.name})")end-- context 'when cost is zero' do- before do- shipping_rate.cost = 0- end-- it 'shows no tax amount' do- expect(shipping_rate.display_price.to_s).to eq('$0.00')- end- endendend@@ -89,16 +79,6 @@ describe Spree::DeliveryRate, type: :model doexpect(shipping_rate.display_price.to_s).to eq("$10.00 (+ $1.00 #{tax_rate.name})")end-- context 'when cost is zero' do- before do- shipping_rate.cost = 0- end-- it 'shows no tax amount' do- expect(shipping_rate.display_price.to_s).to eq('$0.00')- end- endendcontext 'when the currency is JPY' do@@ -124,10 +104,6 @@ describe Spree::DeliveryRate, type: :model do# Regression test for #3829context '#delivery_method' do- it 'can be retrieved' do- expect(shipping_rate.delivery_method.reload).to eq(delivery_method)- end-it 'can be retrieved even when deleted' dodelivery_method.update_column(:deleted_at, Time.current)shipping_rate.save@@ -143,10 +119,6 @@ describe Spree::DeliveryRate, type: :model doshipping_rate.tax_rate = tax_rateend- it 'can be retrieved' do- expect(shipping_rate.tax_rate.reload).to eq(tax_rate)- end-it 'can be retrieved even when deleted' dotax_rate.update_column(:deleted_at, Time.current)shipping_rate.save@@ -155,14 +127,6 @@ describe Spree::DeliveryRate, type: :model doendend- context '#tax_amount' do- context 'without tax rate' do- it 'returns 0.0' do- expect(shipping_rate.tax_amount).to eq(0.0)- end- end- end-describe '#additional_tax_total' docontext 'without tax rate' doit 'returns 0' dodiff --git a/spree/core/spec/models/spree/delivery_spec.rb b/spree/core/spec/models/spree/delivery_spec.rbindex fafa4b93f0..5d31c374ec 100644--- a/spree/core/spec/models/spree/delivery_spec.rb+++ b/spree/core/spec/models/spree/delivery_spec.rb@@ -6,20 +6,6 @@ RSpec.describe Spree::Delivery, type: :model dolet(:fulfillment) { order.fulfillments.first }describe 'validations' do- it 'requires a tracking number' do- delivery = build(:delivery, owner: fulfillment, tracking_number: nil)-- expect(delivery).not_to be_valid- expect(delivery.errors[:tracking_number]).to be_present- end-- it 'refuses the same number twice on one owner' do- create(:delivery, owner: fulfillment, tracking_number: 'DUP-1')- duplicate = build(:delivery, owner: fulfillment, tracking_number: 'DUP-1')-- expect(duplicate).not_to be_valid- end-it 'allows the same number on another owner' docreate(:delivery, owner: fulfillment, tracking_number: 'SHARED-1')other = build(:delivery, owner: create(:fulfillment, order: create(:order, store: store), tracking: nil), tracking_number: 'SHARED-1')@@ -27,12 +13,6 @@ RSpec.describe Spree::Delivery, type: :model doexpect(other).to be_validend- it 'rejects a status outside the carrier vocabulary' do- delivery = build(:delivery, owner: fulfillment, status: 'teleported')-- expect(delivery).not_to be_valid- end-# A forwarder's PRO number belongs to a carrier the registry has never# heard of, and must still be enterable.it 'accepts a carrier the registry does not know' do@@ -78,6 +58,17 @@ RSpec.describe Spree::Delivery, type: :model doexpect(delivery.resolved_tracking_url).to eq('https://tracker.example/t/1')end+ # The column is free text a merchant or seller pastes, and every consumer+ # renders it as a link — so a scripting scheme must never come back out.+ it 'drops a link that is not a real http address' do+ ['javascript:alert(1)', 'data:text/html,<script>alert(1)</script>', 'file:///etc/passwd'].each do |hostile|+ delivery = build(:delivery, owner: fulfillment, store: store,+ tracking_number: '1Z999', tracking_url: hostile)++ expect(delivery.resolved_tracking_url).not_to eq(hostile)+ end+ end+# The column says what the merchant chose; the reader says what to show.# Keeping them apart is what lets a cleared field stay cleared.it 'leaves the stored column alone' do@@ -172,23 +163,4 @@ RSpec.describe Spree::Delivery, type: :model doexpect(delivery.correction_attributes(tracking_number: ' 1Z_OLD ')).not_to have_key(:status)endend- describe '#resolved_tracking_url' do- # The column is free text a merchant or seller pastes, and every consumer- # renders it as a link — so a scripting scheme must never come back out.- it 'drops a link that is not a real http address' do- ['javascript:alert(1)', 'data:text/html,<script>alert(1)</script>', 'file:///etc/passwd'].each do |hostile|- delivery = build(:delivery, owner: fulfillment, store: store,- tracking_number: '1Z999', tracking_url: hostile)-- expect(delivery.resolved_tracking_url).not_to eq(hostile)- end- end-- it 'keeps a link the merchant legitimately pasted' do- delivery = build(:delivery, owner: fulfillment, store: store, tracking_number: '1Z999',- tracking_url: 'https://forwarder.example/track/1Z999')-- expect(delivery.resolved_tracking_url).to eq('https://forwarder.example/track/1Z999')- end- endenddiff --git a/spree/core/spec/models/spree/delivery_zone_spec.rb b/spree/core/spec/models/spree/delivery_zone_spec.rbindex ef949b4318..20a1c6e775 100644--- a/spree/core/spec/models/spree/delivery_zone_spec.rb+++ b/spree/core/spec/models/spree/delivery_zone_spec.rb@@ -20,16 +20,6 @@ describe Spree::DeliveryZone, type: :model doexpect(destroyed.deleted_at).to be_presentexpect(destroyed.delivery_zone_id).to eq(zone.id)end-- it 'never leaves a live method quoting worldwide' do- method = create(:delivery_method, store: store, delivery_zone: zone,- delivery_origin_group: zone.delivery_origin_group)-- zone.destroy-- expect(Spree::DeliveryMethod.exists?(method.id)).to be(false)- expect(Spree::DeliveryMethod.with_deleted.find(method.id).delivery_zone_id).not_to be_nil- endenddescribe '#include?' dodiff --git a/spree/core/spec/models/spree/deprecated_transition_verbs_spec.rb b/spree/core/spec/models/spree/deprecated_transition_verbs_spec.rbindex 31f0ecf399..e994af3397 100644--- a/spree/core/spec/models/spree/deprecated_transition_verbs_spec.rb+++ b/spree/core/spec/models/spree/deprecated_transition_verbs_spec.rb@@ -154,9 +154,5 @@ RSpec.describe 'deprecated transition verbs' doexpect { item.return! }.to change { item.reload.status }.from('shipped').to('returned')end-- it 'return! leaves an unshipped item alone' do- expect(item.return!).to be(false)- endendenddiff --git a/spree/core/spec/models/spree/digital_link_spec.rb b/spree/core/spec/models/spree/digital_link_spec.rbindex 7027568359..2631e5dcc9 100644--- a/spree/core/spec/models/spree/digital_link_spec.rb+++ b/spree/core/spec/models/spree/digital_link_spec.rb@@ -4,36 +4,9 @@ describe Spree::DigitalLink, type: :model dolet(:store) { @default_store }let(:digital_asset) { create(:digital_asset) }let(:variant) { digital_asset.variant }- let(:line_item) { create(:line_item, variant: variant) }it_behaves_like 'lifecycle events'- it 'validates presence of digital_asset and line_item' do- expect(described_class.new(digital_asset: digital_asset, line_item: line_item)).to be_valid- end-- it 'validates presence of line_item' do- expect(described_class.new(digital_asset: digital_asset)).not_to be_valid- end-- it 'validates presence of digital_asset' do- expect(described_class.new(line_item: line_item)).not_to be_valid- end-- context 'validates access_counter' do- it 'validates access_counter numericality' do- expect(described_class.new(digital_asset: digital_asset, line_item: line_item, access_counter: 'string')).not_to be_valid- end-- it 'validates access_counter 0 or greater' do- expect(described_class.new(digital_asset: digital_asset, line_item: line_item, access_counter: -3)).not_to be_valid- end-- it 'validates access_counter 0 is valid' do- expect(described_class.new(digital_asset: digital_asset, line_item: line_item, access_counter: 0)).to be_valid- end- end-describe '#store' dolet(:order) { create(:order, store: store) }let(:line_item) { create(:line_item, order: order, variant: variant) }@@ -54,12 +27,6 @@ describe Spree::DigitalLink, type: :model dodescribe '#reset!' dolet!(:digital_link) { create(:digital_link, access_counter: 5) }- after do- digital_link.update(access_counter: 5)- digital_link.save!- digital_link.reload- end-it 'resets access_counter' doexpect { digital_link.reset! }.to change(digital_link, :access_counter).from(5).to(0)end@@ -151,24 +118,6 @@ describe Spree::DigitalLink, type: :model doit { expect(digital_link.authorizable?).to be false }end- context 'count exceeded but the store does not limit digital download count' do- let(:digital_link) { create(:digital_link) }-- before do- digital_link.line_item.order.store.preferred_limit_digital_download_count = false- digital_link.line_item.order.store.save!- digital_link.line_item.order.store.reload- end-- it { expect(digital_link.authorizable?).to be true }- end-- context 'still in count range' do- let(:digital_link) { create(:digital_link) }-- it { expect(digital_link.authorizable?).to be true }- end-context 'out of date' dolet(:digital_link) { create(:digital_link) }@@ -181,18 +130,6 @@ describe Spree::DigitalLink, type: :model doit { expect(digital_link.authorizable?).to be false }end- context 'out of date but the store does not track date of expire' do- let(:digital_link) { create(:digital_link) }-- before do- digital_link.line_item.order.store.preferred_limit_digital_download_days = false- digital_link.line_item.order.store.save!- digital_link.line_item.order.store.reload- end-- it { expect(digital_link.authorizable?).to be true }- end-context 'still in date' dolet(:digital_link) { create(:digital_link) }@@ -204,12 +141,6 @@ describe Spree::DigitalLink, type: :model dolet!(:digital_link) { create(:digital_link, access_counter: 2) }let!(:digital_link_expired) { create(:digital_link, access_counter: 100) }- after do- digital_link.update(access_counter: 2)- digital_link.save!- digital_link.reload- end-it 'increments the access counter' doexpect { digital_link.authorize! }.to change(digital_link, :access_counter).from(2).to(3)end@@ -236,12 +167,6 @@ describe Spree::DigitalLink, type: :model dolet(:limit) { store.preferred_digital_asset_authorized_clicks }let!(:digital_link) { create(:digital_link, access_counter: limit - 1) }- after do- digital_link.update(access_counter: 2)- digital_link.save!- digital_link.reload- end-it 'allows exactly the configured number of downloads and denies the rest' doexpect(digital_link.authorize!).to be_truthyexpect(digital_link.reload.access_counter).to eq(limit)@@ -258,12 +183,6 @@ describe Spree::DigitalLink, type: :model dolet(:limit) { store.preferred_digital_asset_authorized_clicks }let!(:digital_link) { create(:digital_link, access_counter: limit - 1) }- after do- digital_link.update(access_counter: 2)- digital_link.save!- digital_link.reload- end-it 'never lets the counter exceed the limit' doresults = Array.new(5) doThread.new dodiff --git a/spree/core/spec/models/spree/discount_spec.rb b/spree/core/spec/models/spree/discount_spec.rbindex 2886d2acd9..d2d89b7d58 100644--- a/spree/core/spec/models/spree/discount_spec.rb+++ b/spree/core/spec/models/spree/discount_spec.rb@@ -32,8 +32,12 @@ describe Spree::Discount, type: :model doendit 'keeps provenance snapshots when the promotion is gone' do+ promotion = create(:promotion)discount = create(:discount, order: order, line_item: line_item, amount: -2, kind: 'promotion',- code: 'SUMMER10', value: 10, value_type: 'percent')+ promotion: promotion, code: 'SUMMER10', value: 10, value_type: 'percent')++ promotion.destroy!+expect(discount.reload.code).to eq('SUMMER10')expect(discount.promotion).to be_nilenddiff --git a/spree/core/spec/models/spree/event_spec.rb b/spree/core/spec/models/spree/event_spec.rbindex 323eec5a20..a48a9e3927 100644--- a/spree/core/spec/models/spree/event_spec.rb+++ b/spree/core/spec/models/spree/event_spec.rb@@ -79,29 +79,6 @@ RSpec.describe Spree::Event doendend- describe 'validations' do- it 'requires name' do- event = described_class.new(store_id: store.id, payload: {})-- expect(event).not_to be_valid- expect(event.errors[:name]).to include("can't be blank")- end-- it 'requires store_id' do- allow(Spree::Current).to receive(:store).and_return(nil)- event = described_class.new(name: 'test', payload: {})-- expect(event).not_to be_valid- expect(event.errors[:store_id]).to include("can't be blank")- end-- it 'is valid with name and store_id' do- event = described_class.new(name: 'test', store_id: store.id, payload: {})-- expect(event).to be_valid- end- end-describe '#store' doit 'returns the store for the store_id' doevent = described_class.new(name: 'order.placed', store_id: store.id)@@ -149,24 +126,6 @@ RSpec.describe Spree::Event doendend- describe '#matches?' do- let(:event) { described_class.new(name: 'order.placed', payload: {}) }-- it 'matches exact event names' do- expect(event.matches?('order.placed')).to be true- expect(event.matches?('order.canceled')).to be false- end-- it 'matches wildcard patterns' do- expect(event.matches?('order.*')).to be true- expect(event.matches?('product.*')).to be false- end-- it 'matches global wildcard' do- expect(event.matches?('*')).to be true- end- end-describe '.matches?' doit 'matches exact names' doexpect(described_class.matches?('order.placed', 'order.placed')).to be truediff --git a/spree/core/spec/models/spree/exchange_spec.rb b/spree/core/spec/models/spree/exchange_spec.rbindex 7366e4e689..0d6e2468f4 100644--- a/spree/core/spec/models/spree/exchange_spec.rb+++ b/spree/core/spec/models/spree/exchange_spec.rb@@ -10,12 +10,6 @@ RSpec.describe Spree::Exchange doexpect(exchange).to be_requestedend- it 'is reachable from its order' do- exchange = create(:exchange, store: store)-- expect(exchange.order.reload.exchanges).to include(exchange)- end-describe '#price_difference' dolet(:exchange) { create(:exchange, store: store) }let(:line) { exchange.exchange_line_items.first }@@ -51,9 +45,5 @@ RSpec.describe Spree::Exchange doexpect(line.original_price).to eq(line_item.amount / line_item.quantity)end-- it 'starts with nothing received' do- expect(line.received_quantity).to eq(0)- endendenddiff --git a/spree/core/spec/models/spree/export_spec.rb b/spree/core/spec/models/spree/export_spec.rbindex 3eb99c6a26..3087c8aff2 100644--- a/spree/core/spec/models/spree/export_spec.rb+++ b/spree/core/spec/models/spree/export_spec.rb@@ -71,11 +71,6 @@ RSpec.describe Spree::Export, :job, type: :model docontext 'when the export type is Spree::Exports::Customers' dolet(:export) { build(:customer_export, store: store, user: user, format: 'csv') }- it 'generates the export' do- export.save!- expect { export.generate }.to change(export.attachment, :attached?).from(false).to(true)- end-it 'writes a row for a customer with addresses' docustomer = create(:customer_with_addresses)export.save!@@ -348,22 +343,6 @@ RSpec.describe Spree::Export, :job, type: :model doendend- describe '#send_export_done_email' do- before { export.save! }-- it 'queues the export done email' do- expect { export.send_export_done_email }.to have_enqueued_job(ActionMailer::MailDeliveryJob)- end-- context 'when the export has no user' do- let(:export) { build(:product_export, store: store, user: nil, format: 'csv') }-- it 'does not queue an email — apps polling via secret API key have no inbox' do- expect { export.send_export_done_email }.not_to have_enqueued_job(ActionMailer::MailDeliveryJob)- end- end- end-describe 'CSV formula injection' dolet(:export) { build(:customer_export, store: store, user: user, format: 'csv') }@@ -412,12 +391,6 @@ RSpec.describe Spree::Export, :job, type: :model doexport.normalize_search_paramsexpect(JSON.parse(export.search_params)).to eq(JSON.parse(params))end-- it 'ensures valid JSON output' do- export.search_params = params- export.normalize_search_params- expect { JSON.parse(export.search_params) }.not_to raise_error- endendcontext 'with invalid JSON string' dodiff --git a/spree/core/spec/models/spree/exports/customers_spec.rb b/spree/core/spec/models/spree/exports/customers_spec.rbindex e24b8f95ca..bf90c31ec1 100644--- a/spree/core/spec/models/spree/exports/customers_spec.rb+++ b/spree/core/spec/models/spree/exports/customers_spec.rb@@ -5,28 +5,31 @@ RSpec.describe Spree::Exports::Customers, type: :model dolet(:export) { described_class.new(store: store) }describe '#csv_headers' do+ let(:base_headers) do+ [+ 'First Name',+ 'Last Name',+ 'Email',+ 'Accepts Email Marketing',+ 'Company',+ 'Address 1',+ 'Address 2',+ 'City',+ 'Province',+ 'Province Code',+ 'Country',+ 'Country Code',+ 'Zip',+ 'Phone',+ 'Total Spent',+ 'Total Orders',+ 'Tags'+ ]+ end+context 'when no custom_fields exist' doit 'returns customer headers' do- expected_headers = [- 'First Name',- 'Last Name',- 'Email',- 'Accepts Email Marketing',- 'Company',- 'Address 1',- 'Address 2',- 'City',- 'Province',- 'Province Code',- 'Country',- 'Country Code',- 'Zip',- 'Phone',- 'Total Spent',- 'Total Orders',- 'Tags'- ]- expect(export.csv_headers).to eq(expected_headers)+ expect(export.csv_headers).to eq(base_headers)endend@@ -39,27 +42,7 @@ RSpec.describe Spree::Exports::Customers, type: :model doendit 'includes custom_field headers' do- expected_headers = [- 'First Name',- 'Last Name',- 'Email',- 'Accepts Email Marketing',- 'Company',- 'Address 1',- 'Address 2',- 'City',- 'Province',- 'Province Code',- 'Country',- 'Country Code',- 'Zip',- 'Phone',- 'Total Spent',- 'Total Orders',- 'Tags',- 'custom_field.custom.loyalty_points'- ]- expect(export.csv_headers).to eq(expected_headers)+ expect(export.csv_headers).to eq(base_headers + ['custom_field.custom.loyalty_points'])endendenddiff --git a/spree/core/spec/models/spree/exports/gift_cards_spec.rb b/spree/core/spec/models/spree/exports/gift_cards_spec.rbindex 3ea8d93593..348cb59a97 100644--- a/spree/core/spec/models/spree/exports/gift_cards_spec.rb+++ b/spree/core/spec/models/spree/exports/gift_cards_spec.rb@@ -29,23 +29,26 @@ RSpec.describe Spree::Exports::GiftCards, type: :model doenddescribe '#csv_headers' do+ let(:base_headers) do+ [+ 'Code',+ 'Amount',+ 'Amount Used',+ 'Amount Remaining',+ 'Currency',+ 'Status',+ 'Expires At',+ 'Customer Email',+ 'Customer First Name',+ 'Customer Last Name',+ 'Created At',+ 'Updated At'+ ]+ end+context 'when no custom_fields exist' doit 'returns gift card headers' do- expected_headers = [- 'Code',- 'Amount',- 'Amount Used',- 'Amount Remaining',- 'Currency',- 'Status',- 'Expires At',- 'Customer Email',- 'Customer First Name',- 'Customer Last Name',- 'Created At',- 'Updated At'- ]- expect(export.csv_headers).to eq(expected_headers)+ expect(export.csv_headers).to eq(base_headers)endend@@ -58,22 +61,7 @@ RSpec.describe Spree::Exports::GiftCards, type: :model doendit 'includes custom_field headers' do- expected_headers = [- 'Code',- 'Amount',- 'Amount Used',- 'Amount Remaining',- 'Currency',- 'Status',- 'Expires At',- 'Customer Email',- 'Customer First Name',- 'Customer Last Name',- 'Created At',- 'Updated At',- 'custom_field.custom.purchase_location'- ]- expect(export.csv_headers).to eq(expected_headers)+ expect(export.csv_headers).to eq(base_headers + ['custom_field.custom.purchase_location'])endendenddiff --git a/spree/core/spec/models/spree/exports/orders_spec.rb b/spree/core/spec/models/spree/exports/orders_spec.rbindex e1ad716bb2..73d5a53646 100644--- a/spree/core/spec/models/spree/exports/orders_spec.rb+++ b/spree/core/spec/models/spree/exports/orders_spec.rb@@ -5,66 +5,69 @@ RSpec.describe Spree::Exports::Orders, type: :model dolet(:export) { described_class.new(store: store) }describe '#csv_headers' do+ let(:base_headers) do+ [+ 'Number',+ 'Email',+ 'Status',+ 'Currency',+ 'Subtotal',+ 'Shipping',+ 'Taxes',+ 'Taxes included',+ 'Discount Used',+ 'Free Shipping',+ 'Discount',+ 'Discount Code',+ 'Store Credit amount',+ 'Total',+ 'Shipping method',+ 'Total weight',+ 'Payment Type Used',+ 'Product ID',+ 'Item Quantity',+ 'Item SKU',+ 'Item Name',+ 'Item Price',+ 'Item Total Discount',+ 'Item Total Price',+ 'Item requires shipping',+ 'Item taxbale',+ 'Item Seller',+ 'Category lvl0',+ 'Category lvl1',+ 'Category lvl2',+ 'Category lvl3',+ 'Category lvl4',+ 'Billing Name',+ 'Billing Address 1',+ 'Billing Address 2',+ 'Billing Company',+ 'Billing City',+ 'Billing Zip',+ 'Billing State',+ 'Billing Country',+ 'Billing Phone',+ 'Shipping Name',+ 'Shipping Address 1',+ 'Shipping Address 2',+ 'Shipping Company',+ 'Shipping City',+ 'Shipping Zip',+ 'Shipping State',+ 'Shipping Country',+ 'Shipping Phone',+ 'Placed at',+ 'Shipped at',+ 'Cancelled at',+ 'Cancelled by',+ 'Notes'+ ]+ end+context 'when no custom_fields exist' doit 'returns order line item headers' do- expected_headers = [- 'Number',- 'Email',- 'Status',- 'Currency',- 'Subtotal',- 'Shipping',- 'Taxes',- 'Taxes included',- 'Discount Used',- 'Free Shipping',- 'Discount',- 'Discount Code',- 'Store Credit amount',- 'Total',- 'Shipping method',- 'Total weight',- 'Payment Type Used',- 'Product ID',- 'Item Quantity',- 'Item SKU',- 'Item Name',- 'Item Price',- 'Item Total Discount',- 'Item Total Price',- 'Item requires shipping',- 'Item taxbale',- 'Item Seller',- 'Category lvl0',- 'Category lvl1',- 'Category lvl2',- 'Category lvl3',- 'Category lvl4',- 'Billing Name',- 'Billing Address 1',- 'Billing Address 2',- 'Billing Company',- 'Billing City',- 'Billing Zip',- 'Billing State',- 'Billing Country',- 'Billing Phone',- 'Shipping Name',- 'Shipping Address 1',- 'Shipping Address 2',- 'Shipping Company',- 'Shipping City',- 'Shipping Zip',- 'Shipping State',- 'Shipping Country',- 'Shipping Phone',- 'Placed at',- 'Shipped at',- 'Cancelled at',- 'Cancelled by',- 'Notes'- ]- expect(export.csv_headers).to eq(expected_headers)+ expect(export.csv_headers).to eq(base_headers)endend@@ -77,65 +80,7 @@ RSpec.describe Spree::Exports::Orders, type: :model doendit 'includes custom_field headers' do- expected_headers = [- 'Number',- 'Email',- 'Status',- 'Currency',- 'Subtotal',- 'Shipping',- 'Taxes',- 'Taxes included',- 'Discount Used',- 'Free Shipping',- 'Discount',- 'Discount Code',- 'Store Credit amount',- 'Total',- 'Shipping method',- 'Total weight',- 'Payment Type Used',- 'Product ID',- 'Item Quantity',- 'Item SKU',- 'Item Name',- 'Item Price',- 'Item Total Discount',- 'Item Total Price',- 'Item requires shipping',- 'Item taxbale',- 'Item Seller',- 'Category lvl0',- 'Category lvl1',- 'Category lvl2',- 'Category lvl3',- 'Category lvl4',- 'Billing Name',- 'Billing Address 1',- 'Billing Address 2',- 'Billing Company',- 'Billing City',- 'Billing Zip',- 'Billing State',- 'Billing Country',- 'Billing Phone',- 'Shipping Name',- 'Shipping Address 1',- 'Shipping Address 2',- 'Shipping Company',- 'Shipping City',- 'Shipping Zip',- 'Shipping State',- 'Shipping Country',- 'Shipping Phone',- 'Placed at',- 'Shipped at',- 'Cancelled at',- 'Cancelled by',- 'Notes',- 'custom_field.custom.gift_message'- ]- expect(export.csv_headers).to eq(expected_headers)+ expect(export.csv_headers).to eq(base_headers + ['custom_field.custom.gift_message'])endendenddiff --git a/spree/core/spec/models/spree/exports/products_spec.rb b/spree/core/spec/models/spree/exports/products_spec.rbindex 86f507ef7b..771aca4739 100644--- a/spree/core/spec/models/spree/exports/products_spec.rb+++ b/spree/core/spec/models/spree/exports/products_spec.rb@@ -47,52 +47,55 @@ RSpec.describe Spree::Exports::Products, type: :model doenddescribe '#csv_headers' do+ let(:base_headers) do+ [+ 'product_id',+ 'sku',+ 'name',+ 'slug',+ 'status',+ 'seller_name',+ 'description',+ 'meta_title',+ 'meta_description',+ 'meta_keywords',+ 'tags',+ 'labels',+ 'price',+ 'compare_at_price',+ 'currency',+ 'width',+ 'height',+ 'depth',+ 'dimensions_unit',+ 'weight',+ 'weight_unit',+ 'available_on',+ 'discontinue_on',+ 'track_inventory',+ 'inventory_count',+ 'inventory_backorderable',+ 'stock_location',+ 'tax_category',+ 'product_type',+ 'image1_src',+ 'image2_src',+ 'image3_src',+ 'option1_name',+ 'option1_value',+ 'option2_name',+ 'option2_value',+ 'option3_name',+ 'option3_value',+ 'category1',+ 'category2',+ 'category3'+ ]+ end+context 'when no custom_fields' doit 'returns product variant headers without properties' do- expected_headers = [- 'product_id',- 'sku',- 'name',- 'slug',- 'status',- 'seller_name',- 'description',- 'meta_title',- 'meta_description',- 'meta_keywords',- 'tags',- 'labels',- 'price',- 'compare_at_price',- 'currency',- 'width',- 'height',- 'depth',- 'dimensions_unit',- 'weight',- 'weight_unit',- 'available_on',- 'discontinue_on',- 'track_inventory',- 'inventory_count',- 'inventory_backorderable',- 'stock_location',- 'tax_category',- 'product_type',- 'image1_src',- 'image2_src',- 'image3_src',- 'option1_name',- 'option1_value',- 'option2_name',- 'option2_value',- 'option3_name',- 'option3_value',- 'category1',- 'category2',- 'category3'- ]- expect(export.csv_headers).to eq(expected_headers)+ expect(export.csv_headers).to eq(base_headers)endend@@ -100,51 +103,7 @@ RSpec.describe Spree::Exports::Products, type: :model dolet!(:custom_field_definition) { create(:custom_field_definition, resource_type: 'Spree::Product', namespace: 'custom', key: 'field1') }it 'includes custom_field headers' do- expected_headers = [- 'product_id',- 'sku',- 'name',- 'slug',- 'status',- 'seller_name',- 'description',- 'meta_title',- 'meta_description',- 'meta_keywords',- 'tags',- 'labels',- 'price',- 'compare_at_price',- 'currency',- 'width',- 'height',- 'depth',- 'dimensions_unit',- 'weight',- 'weight_unit',- 'available_on',- 'discontinue_on',- 'track_inventory',- 'inventory_count',- 'inventory_backorderable',- 'stock_location',- 'tax_category',- 'product_type',- 'image1_src',- 'image2_src',- 'image3_src',- 'option1_name',- 'option1_value',- 'option2_name',- 'option2_value',- 'option3_name',- 'option3_value',- 'category1',- 'category2',- 'category3',- 'custom_field.custom.field1'- ]- expect(export.csv_headers).to eq(expected_headers)+ expect(export.csv_headers).to eq(base_headers + ['custom_field.custom.field1'])endendenddiff --git a/spree/core/spec/models/spree/freight_summary_spec.rb b/spree/core/spec/models/spree/freight_summary_spec.rbindex fbb4dbcba0..af28623f0d 100644--- a/spree/core/spec/models/spree/freight_summary_spec.rb+++ b/spree/core/spec/models/spree/freight_summary_spec.rb@@ -176,16 +176,8 @@ RSpec.describe Spree::FreightSummary doexpect(merged.total_units).to eq(12)expect(merged.total_cartons).to eq(1)expect(merged.total_pallets).to eq(1)- end-- # Adding two part-full cartons' volumes reports space the combined- # shipment does not take, which would misprice a volume tier.- it 're-derives volume from the recombined carton count' do- split = [summary_for([[packed_variant, 3]]), summary_for([[packed_variant, 9]])]-- merged = described_class.merge(split)-- expect(merged.total_cartons).to eq(1)+ # Adding two part-full cartons' volumes reports space the combined+ # shipment does not take, which would misprice a volume tier.expect(merged.total_volume).to eq(BigDecimal('0.03'))enddiff --git a/spree/core/spec/models/spree/fulfillment/custom_events_spec.rb b/spree/core/spec/models/spree/fulfillment/custom_events_spec.rbindex 6ede827187..2bc3c0fc3d 100644--- a/spree/core/spec/models/spree/fulfillment/custom_events_spec.rb+++ b/spree/core/spec/models/spree/fulfillment/custom_events_spec.rb@@ -12,13 +12,6 @@ RSpec.describe Spree::Fulfillment::CustomEvents doenddescribe 'fulfillment.fulfilled event' do- it 'publishes fulfillment.fulfilled and dual-emits the legacy shipment.shipped' do- Spree.fulfillment_fulfill_workflow.call(fulfillment: fulfillment)-- expect(Spree::Events).to have_received(:publish).with('fulfillment.fulfilled', anything, anything)- expect(Spree::Events).to have_received(:publish).with('shipment.shipped', anything, anything)- end-it 'does not publish when events are disabled' doallow(Spree::Events).to receive(:enabled?).and_return(false)@@ -45,6 +38,7 @@ RSpec.describe Spree::Fulfillment::CustomEvents doSpree.fulfillment_fulfill_workflow.call(fulfillment: fulfillment)expect(Spree::Events).to have_received(:publish).with('fulfillment.fulfilled', anything, anything)+ expect(Spree::Events).to have_received(:publish).with('shipment.shipped', anything, anything)expect(Spree::Events).to have_received(:publish).with('order.fulfilled', anything, anything)expect(Spree::Events).to have_received(:publish).with('order.shipped', anything, anything)enddiff --git a/spree/core/spec/models/spree/fulfillment_provider/base_spec.rb b/spree/core/spec/models/spree/fulfillment_provider/base_spec.rbindex d25c8c3060..bd2481cb95 100644--- a/spree/core/spec/models/spree/fulfillment_provider/base_spec.rb+++ b/spree/core/spec/models/spree/fulfillment_provider/base_spec.rb@@ -17,21 +17,6 @@ describe Spree::FulfillmentProvider::Base, type: :model doexpect { provider.cancel_fulfillment(fulfillment) }.to raise_error(NotImplementedError)end- describe 'registry' do- it 'exposes the built-in providers and their class predicates' do- expect(Spree.fulfillment_providers).to include(- Spree::FulfillmentProvider::Manual,- Spree::FulfillmentProvider::Digital,- Spree::FulfillmentProvider::Pickup,- Spree::FulfillmentProvider::PickupPoint- )- expect(Spree::FulfillmentProvider::Digital).to be_digital- expect(Spree::FulfillmentProvider::Pickup).to be_pickup- expect(Spree::FulfillmentProvider::PickupPoint).to be_pickup_point- expect(Spree::FulfillmentProvider::Manual).not_to be_digital- end- end-describe 'Fulfillment#provider' doit 'falls back to Manual without a delivery method' doexpect(build(:fulfillment).provider).to be_a(Spree::FulfillmentProvider::Manual)diff --git a/spree/core/spec/models/spree/fulfilment_changer_spec.rb b/spree/core/spec/models/spree/fulfilment_changer_spec.rbindex a79fe40c73..57465dc905 100644--- a/spree/core/spec/models/spree/fulfilment_changer_spec.rb+++ b/spree/core/spec/models/spree/fulfilment_changer_spec.rb@@ -158,7 +158,7 @@ describe Spree::FulfillmentChanger doendit 'does not unstock the desired location' do- expect { subject }.not_to change(stock_level, :count_on_hand)+ expect { subject }.not_to change { stock_level.reload.count_on_hand }endendend@@ -191,16 +191,6 @@ describe Spree::FulfillmentChanger docontext 'when the desired stock location already has a backordered units' dolet(:desired_count_on_hand) { -1 }- it 'releases seven at the original stock location' do- expect { subject }.- to change { current_shipment.stock_location.stock_level(variant).allocated_count }.by(-7)- end-- it 'allocates seven at the desired stock location' do- expect { subject }.- to change { desired_shipment.stock_location.stock_level(variant).allocated_count }.by(7)- end-it 'creates a shipment with the correct number of on hand and backordered units' dosubjectexpect(desired_shipment.inventory_units.on_hand.sum(:quantity)).to eq(0)@@ -407,7 +397,7 @@ describe Spree::FulfillmentChanger dosubject- expect(desired_shipment.reload.shipping_method).to eq(shipping_method_that_should_be_selected)+ expect(desired_shipment.reload.delivery_method).to eq(shipping_method_that_should_be_selected)expect(desired_shipment.reload.cost).to eq(10)enddiff --git a/spree/core/spec/models/spree/gateway/bogus_spec.rb b/spree/core/spec/models/spree/gateway/bogus_spec.rbindex ed3d05af82..1167b180ef 100644--- a/spree/core/spec/models/spree/gateway/bogus_spec.rb+++ b/spree/core/spec/models/spree/gateway/bogus_spec.rb@@ -9,9 +9,5 @@ module Spreebogus.disable_customer_profile(cc)expect(cc.gateway_customer_profile_id).to be_nilend-- describe '#session_required?' do- it { expect(bogus.session_required?).to be true }- endendenddiff --git a/spree/core/spec/models/spree/gateway_spec.rb b/spree/core/spec/models/spree/gateway_spec.rbindex 459c98e8d0..68e4eabd1d 100644--- a/spree/core/spec/models/spree/gateway_spec.rb+++ b/spree/core/spec/models/spree/gateway_spec.rb@@ -152,15 +152,5 @@ describe Spree::Gateway, type: :model doit 'returns nil' doexpect(payment_method.gateway_dashboard_payment_url(payment)).to be_nilend-- context 'when implemented' do- before do- expect(payment_method).to receive(:gateway_dashboard_payment_url).with(payment).and_return("https://dashboard.stripe.com/payments/#{payment.transaction_id}")- end-- it 'returns the url' do- expect(payment_method.gateway_dashboard_payment_url(payment)).to eq('https://dashboard.stripe.com/payments/123')- end- endendenddiff --git a/spree/core/spec/models/spree/gift_card_spec.rb b/spree/core/spec/models/spree/gift_card_spec.rbindex a96c243d50..747eb0c4a2 100644--- a/spree/core/spec/models/spree/gift_card_spec.rb+++ b/spree/core/spec/models/spree/gift_card_spec.rb@@ -45,10 +45,10 @@ RSpec.describe Spree::GiftCard, type: :model doenddescribe 'Scopes' do- let(:active_gift_card) { create(:gift_card, status: :active) }- let(:redeemed_gift_card) { create(:gift_card, status: :redeemed) }- let(:partially_redeemed_gift_card) { create(:gift_card, status: :partially_redeemed) }- let(:expired_gift_card) { create(:gift_card, expires_at: Date.current, status: :active) }+ let!(:active_gift_card) { create(:gift_card, status: :active) }+ let!(:redeemed_gift_card) { create(:gift_card, status: :redeemed) }+ let!(:partially_redeemed_gift_card) { create(:gift_card, status: :partially_redeemed) }+ let!(:expired_gift_card) { create(:gift_card, expires_at: Date.current, status: :active) }describe '#masked_code' doit 'shows only the last four characters' do@@ -57,8 +57,8 @@ RSpec.describe Spree::GiftCard, type: :model doenddescribe '#active' do- it 'returns active gift cards' do- expect(described_class.active).to contain_exactly(active_gift_card)+ it 'returns unexpired active and partially redeemed gift cards' do+ expect(described_class.active).to contain_exactly(active_gift_card, partially_redeemed_gift_card)endend@@ -225,20 +225,6 @@ RSpec.describe Spree::GiftCard, type: :model doendend- describe 'status' do- it 'has no state machine' do- expect(described_class).not_to respond_to(:state_machines)- end-- it 'defaults to active' do- expect(described_class.new.status).to eq('active')- end-- it 'rejects an unknown status' do- expect(build(:gift_card, status: 'nonsense')).not_to be_valid- end- end-describe 'status scopes and predicates' dolet(:store) { Spree::Store.default }let!(:active) { create(:gift_card, store: store, amount: 10) }diff --git a/spree/core/spec/models/spree/import_mapping_spec.rb b/spree/core/spec/models/spree/import_mapping_spec.rbindex c6ddfee289..f203fd2b6b 100644--- a/spree/core/spec/models/spree/import_mapping_spec.rb+++ b/spree/core/spec/models/spree/import_mapping_spec.rb@@ -5,56 +5,6 @@ RSpec.describe Spree::ImportMapping, type: :model dolet(:user) { create(:admin_user) }let(:import) { create(:product_import, store: store, user: user) }- describe 'Validations' do- describe 'presence validations' do- it 'validates presence of import' do- mapping = build(:import_mapping, import: nil)- expect(mapping).not_to be_valid- expect(mapping.errors[:import]).to include('must exist')- end-- it 'validates presence of schema_field' do- mapping = build(:import_mapping, schema_field: nil)- expect(mapping).not_to be_valid- expect(mapping.errors[:schema_field]).to include("can't be blank")- end- end-- describe 'uniqueness validations' do- let!(:existing_mapping) { create(:import_mapping, import: import, schema_field: 'slug') }-- it 'validates uniqueness of schema_field scoped to import_id' do- duplicate_mapping = build(:import_mapping, import: import, schema_field: 'slug')- expect(duplicate_mapping).not_to be_valid- expect(duplicate_mapping.errors[:schema_field]).to include('has already been taken')- end-- it 'allows same schema_field for different imports' do- other_import = create(:product_import, store: store, user: user)- duplicate_mapping = build(:import_mapping, import: other_import, schema_field: 'slug')- expect(duplicate_mapping).to be_valid- end-- it 'validates uniqueness of file_column scoped to import_id' do- existing_mapping.update!(file_column: 'product_name')- duplicate_mapping = build(:import_mapping, import: import, file_column: 'product_name')- expect(duplicate_mapping).not_to be_valid- expect(duplicate_mapping.errors[:file_column]).to include('has already been taken')- end-- it 'allows blank file_column' do- mapping = build(:import_mapping, import: import, schema_field: 'description', file_column: nil)- expect(mapping).to be_valid- end-- it 'allows same file_column for different imports' do- other_import = create(:product_import, store: store, user: user)- mapping = build(:import_mapping, import: other_import, schema_field: 'sku', file_column: 'name')- expect(mapping).to be_valid- end- end- end-describe '#required?' docontext 'when schema_field is a required field' dolet(:mapping) { build(:import_mapping, import: import, schema_field: 'slug') }diff --git a/spree/core/spec/models/spree/import_row_spec.rb b/spree/core/spec/models/spree/import_row_spec.rbindex c218652e79..2ebbde18ef 100644--- a/spree/core/spec/models/spree/import_row_spec.rb+++ b/spree/core/spec/models/spree/import_row_spec.rb@@ -12,44 +12,9 @@ RSpec.describe Spree::ImportRow, :job, type: :model doallow(import).to receive(:attachment_file_content).and_return(csv_content)end- describe 'Associations' do- describe '#store' do- it 'delegates to import' do- import_row.save!- expect(import_row.store).to eq(store)- end- end- end-- describe 'Validations' do- context 'row_number uniqueness' do- before { import_row.save! }-- it 'validates uniqueness scoped to import_id' do- duplicate_row = build(:import_row, import: import, row_number: 1)- expect(duplicate_row).not_to be_valid- expect(duplicate_row.errors[:row_number]).to include('has already been taken')- end-- it 'allows same row_number for different imports' do- other_import = create(:product_import, store: store)- other_row = build(:import_row, import: other_import, row_number: 1)- expect(other_row).to be_valid- end- end- end-describe 'status' dobefore { import_row.save! }- it 'has no state machine' do- expect(described_class).not_to respond_to(:state_machines)- end-- it 'starts in pending status' do- expect(import_row.status).to eq('pending')- end-it 'rejects an unknown status' doimport_row.status = 'nonsense'expect(import_row).not_to be_valid@@ -69,20 +34,6 @@ RSpec.describe Spree::ImportRow, :job, type: :model doendend- describe '.completed' do- it 'returns only completed rows' do- expect(described_class.completed).to include(completed_row)- expect(described_class.completed).not_to include(pending_row, failed_row, processing_row)- end- end-- describe '.failed' do- it 'returns only failed rows' do- expect(described_class.failed).to include(failed_row)- expect(described_class.failed).not_to include(pending_row, completed_row, processing_row)- end- end-describe '.processed' doit 'returns completed and failed rows' doexpect(described_class.processed).to include(completed_row, failed_row)diff --git a/spree/core/spec/models/spree/import_spec.rb b/spree/core/spec/models/spree/import_spec.rbindex eb679a08ac..ed934b77a8 100644--- a/spree/core/spec/models/spree/import_spec.rb+++ b/spree/core/spec/models/spree/import_spec.rb@@ -44,18 +44,9 @@ RSpec.describe Spree::Import, :job, type: :model dodescribe 'status' dobefore { import.save! }- it 'has no state machine' do- expect(described_class).not_to respond_to(:state_machines)- end-it 'starts in pending status' doexpect(import.status).to eq('pending')end-- it 'rejects an unknown status' do- import.status = 'nonsense'- expect(import).not_to be_valid- endenddescribe '#model_class' do@@ -196,13 +187,6 @@ RSpec.describe Spree::Import, :job, type: :model doexpect(all_fields.count).to eq(base_field_count + custom_field_count)end-- it 'has correct structure for custom_field fields' do- custom_field_field = import.schema_fields.find { |f| f[:name] == 'custom_field.properties.manufacturer' }- expect(custom_field_field).to eq(- { name: 'custom_field.properties.manufacturer', label: 'Manufacturer' }- )- endendcontext 'when model does not support custom_fields' do@@ -216,11 +200,6 @@ RSpec.describe Spree::Import, :job, type: :model dofields = import.schema_fieldsexpect(fields).to eq(Spree::ImportSchemas::Products::FIELDS)end-- it 'does not include any custom_field fields' do- custom_field_fields = import.schema_fields.select { |f| f[:name].start_with?('custom_field.') }- expect(custom_field_fields).to be_empty- endendcontext 'when model supports custom_fields but has no custom_field definitions' do@@ -287,20 +266,6 @@ RSpec.describe Spree::Import, :job, type: :model doendend- describe '#store' do- context 'when owner is a Store' do- it 'returns the owner' do- expect(import.store).to eq(store)- end- end- end-- describe '.available_types' do- it 'returns configured import types' do- expect(described_class.available_types).to eq(Spree.import_types)- end- end-describe '.available_models' doit 'returns model classes for available types' doexpect(described_class.available_models).to include(Spree::Product)@@ -314,12 +279,6 @@ RSpec.describe Spree::Import, :job, type: :model doendend- describe '.model_class' do- it 'returns the model class for the import type' do- expect(Spree::Imports::Products.model_class).to eq(Spree::Product)- end- end-describe '#template_csv' doit 'is the schema header row' doimport = Spree::Imports::Products.newdiff --git a/spree/core/spec/models/spree/import_tenancy_spec.rb b/spree/core/spec/models/spree/import_tenancy_spec.rbindex 204f9835f2..2bbe81d536 100644--- a/spree/core/spec/models/spree/import_tenancy_spec.rb+++ b/spree/core/spec/models/spree/import_tenancy_spec.rb@@ -69,6 +69,7 @@ RSpec.describe 'import and export tenancy' doit 'still accepts a seller on write' doimport = build(:product_import, user: user)+ expect(Spree::Deprecation).to receive(:warn).with(/Import#owner= is deprecated/)import.owner = sellerexpect(import.seller).to eq(seller)@@ -107,24 +108,13 @@ RSpec.describe 'import and export tenancy' doexpect(Spree::Export.for_store(store)).to include(theirs)end- # `Export#scope` has narrowed exported rows by seller since 5.6, but with- # no column behind the association `seller` was always nil, so the line- # never fired. The column is what lets it.- #- # It applies to models that answer `for_seller` — `Spree::Variant` does,- # `Spree::Product` does not, so a product export is still store-wide. That- # gap predates this change and is a separate decision.it 'narrows an export to the seller where the model supports it' do- mine = create(:product, store: store, seller: seller).default_variant- theirs = create(:product, store: store).default_variant- export = create(:export, store: store, seller: seller, user: user,- type: 'Spree::Exports::Products')+ mine = create(:product, store: store, seller: seller)+ theirs = create(:product, store: store)+ export = build(:product_export, store: store, seller: seller, user: nil)- scoped = Spree::Variant.for_seller(seller)-- expect(export.seller).to eq(seller)- expect(scoped).to include(mine)- expect(scoped).not_to include(theirs)+ expect(export.records_to_export).to include(mine)+ expect(export.records_to_export).not_to include(theirs)endendenddiff --git a/spree/core/spec/models/spree/imports/customers_spec.rb b/spree/core/spec/models/spree/imports/customers_spec.rbdeleted file mode 100644index 9e57553307..0000000000--- a/spree/core/spec/models/spree/imports/customers_spec.rb+++ /dev/null@@ -1,24 +0,0 @@-require 'spec_helper'--RSpec.describe Spree::Imports::Customers, type: :model do- let(:store) { Spree::Store.default }- let(:import) { create(:customer_import, store: store) }-- describe '#row_processor_class' do- it 'returns Customer row processor' do- expect(import.row_processor_class).to eq Spree::Imports::RowProcessors::Customer- end- end-- describe '#model_class' do- it 'returns the user class' do- expect(import.model_class).to eq Spree.customer_class- end- end-- describe '#import_schema' do- it 'returns the customers import schema' do- expect(import.import_schema).to be_a(Spree::ImportSchemas::Customers)- end- end-enddiff --git a/spree/core/spec/models/spree/inventory_unit_spec.rb b/spree/core/spec/models/spree/inventory_unit_spec.rbindex ec0fa899b1..c6b1b51b1a 100644--- a/spree/core/spec/models/spree/inventory_unit_spec.rb+++ b/spree/core/spec/models/spree/inventory_unit_spec.rb@@ -10,25 +10,9 @@ describe Spree::FulfillmentItem, type: :model dolet!(:inventory_unit_3) { create(:fulfillment_item, state: 'shipped') }let!(:inventory_unit_4) { create(:fulfillment_item, state: 'returned') }- describe '.backordered' do- it { expect(Spree::FulfillmentItem.backordered).to eq([inventory_unit_2]) }- end-- describe '.on_hand' do- it { expect(Spree::FulfillmentItem.on_hand).to eq([inventory_unit_1]) }- end-describe '.on_hand_or_backordered' doit { expect(Spree::FulfillmentItem.on_hand_or_backordered).to match_array([inventory_unit_1, inventory_unit_2]) }end-- describe '.shipped' do- it { expect(Spree::FulfillmentItem.shipped).to eq([inventory_unit_3]) }- end-- describe '.returned' do- it { expect(Spree::FulfillmentItem.returned).to eq([inventory_unit_4]) }- endenddescribe '#backordered_for_stock_level' do@@ -46,10 +30,6 @@ describe Spree::FulfillmentItem, type: :model doorder.fulfillments.firstend- let(:shipping_method) do- shipment.shipping_methods.first- end-let!(:unit) dounit = shipment.inventory_units.firstunit.state = 'backordered'@@ -92,13 +72,6 @@ describe Spree::FulfillmentItem, type: :model doexpect(Spree::FulfillmentItem.backordered_for_stock_level(stock_level)).not_to include(other_variant_unit)end- it 'does not change shipping cost when fulfilling the order' do- current_shipment_cost = shipment.cost- shipping_method.calculator.set_preference(:amount, current_shipment_cost + 5.0)- stock_level.set_count_on_hand(0)- expect(shipment.reload.cost).to eq(current_shipment_cost)- end-context 'other shipments' dolet(:other_order) doorder = create(:order)@@ -134,7 +107,6 @@ describe Spree::FulfillmentItem, type: :model doenddescribe '#finalize_units!' do- let!(:stock_location) { create(:stock_location) }let(:variant) { create(:variant) }let (:shipment) { create(:fulfillment) }let(:inventory_units) do@@ -188,40 +160,6 @@ describe Spree::FulfillmentItem, type: :model doendend- describe '#additional_tax_total' do- subject do- build(:fulfillment_item, line_item: line_item)- end-- let(:quantity) { 2 }- let(:line_item_additional_tax_total) { 10.00 }- let(:line_item) do- build(:line_item, quantity: quantity,- additional_tax_total: line_item_additional_tax_total)- end-- it 'is the correct amount' do- expect(subject.additional_tax_total).to eq line_item_additional_tax_total / quantity- end- end-- describe '#included_tax_total' do- subject do- build(:fulfillment_item, line_item: line_item)- end-- let(:quantity) { 2 }- let(:line_item_included_tax_total) { 10.00 }- let(:line_item) do- build(:line_item, quantity: quantity,- included_tax_total: line_item_included_tax_total)- end-- it 'is the correct amount' do- expect(subject.included_tax_total).to eq line_item_included_tax_total / quantity- end- end-describe '#charged_amount' dosubject { build(:fulfillment_item, line_item: line_item, quantity: 1) }diff --git a/spree/core/spec/models/spree/invitation_spec.rb b/spree/core/spec/models/spree/invitation_spec.rbindex a05a5218a9..54355764ce 100644--- a/spree/core/spec/models/spree/invitation_spec.rb+++ b/spree/core/spec/models/spree/invitation_spec.rb@@ -19,20 +19,6 @@ RSpec.describe Spree::Invitation, type: :model doendend- context 'when invitation is accepted after expiration' do- it 'is refused' do- invitation.save!- invitation.update_column(:expires_at, 1.day.ago)-- result = Spree.invitation_accept_workflow.call(invitation: invitation)-- expect(result).not_to be_success- expect(result.error.value).to eq(:invitation_expired)- expect(invitation.reload.accepted_at).not_to be_present- expect(invitation.status).to eq('pending')- end- end-context 'when invitee already exists in the store' doit 'is invalid' docreate(:admin_user, email: '[email protected]')@@ -88,31 +74,7 @@ RSpec.describe Spree::Invitation, type: :model doenddescribe 'State Machine' do- it 'has initial state of pending' do- expect(invitation.status).to eq('pending')- end-context 'when accepting an invitation' do- it 'changes status to accepted' do- invitation.invitee = create(:admin_user, :without_admin_role)- Spree.invitation_accept_workflow.call(invitation: invitation)- expect(invitation.status).to eq('accepted')- end-- it 'sets accepted_at timestamp' do- expect(invitation.accepted_at).to be_nil- invitation.invitee = create(:admin_user, :without_admin_role)- Spree.invitation_accept_workflow.call(invitation: invitation)- expect(invitation.accepted_at).to be_present- end-- it 'publishes invitation.accept event', events: true do- invitation.invitee = create(:admin_user, :without_admin_role)-- expect(invitation).to receive(:publish_event).with('invitation.accepted')- Spree.invitation_accept_workflow.call(invitation: invitation)- end-it 'creates a resource user' doinvitation.invitee = create(:admin_user, :without_admin_role)expect { Spree.invitation_accept_workflow.call(invitation: invitation) }.to change(invitation, :role_user).from(nil).to(Spree::RoleUser)diff --git a/spree/core/spec/models/spree/legacy_encrypted_password_recipe_spec.rb b/spree/core/spec/models/spree/legacy_encrypted_password_recipe_spec.rbindex ca784b9722..b3f8ec151a 100644--- a/spree/core/spec/models/spree/legacy_encrypted_password_recipe_spec.rb+++ b/spree/core/spec/models/spree/legacy_encrypted_password_recipe_spec.rb@@ -38,10 +38,4 @@ describe 'Legacy encrypted_password bridge', type: :model doexpect(user.authenticate('secret123')).to be_truthyexpect(user.authenticate('wrong')).to be(false)end-- it 're-authenticates a reloaded record' do- model.create!(email: '[email protected]', password: 'hunter2!')-- expect(model.find_by(email: '[email protected]').authenticate('hunter2!')).to be_truthy- endenddiff --git a/spree/core/spec/models/spree/line_item_spec.rb b/spree/core/spec/models/spree/line_item_spec.rbindex 24d15dfaaa..f292fa352d 100644--- a/spree/core/spec/models/spree/line_item_spec.rb+++ b/spree/core/spec/models/spree/line_item_spec.rb@@ -35,36 +35,6 @@ describe Spree::LineItem, type: :model doendend- describe 'Validations' do- describe 'ensure_proper_currency' do- context 'order is present' do- context "when line_item's currency matches with order's" do- it { expect(line_item).to be_valid }- end-- context "when line_item's currency does not matches with order's" do- before do- line_item.currency = 'Invalid Currency'- end-- it { expect(line_item).not_to be_valid }- end- end- end- end-- describe '#quantity' do- it 'has a default quantity of 1' do- line_item = build(:line_item)- expect(line_item.quantity).to eq(1)- end-- it 'allows to set different value for quantity' do- line_item = build(:line_item, quantity: 5)- expect(line_item.quantity).to eq(5)- end- end-describe '#ensure_valid_quantity' docontext 'quantity.nil?' dobefore do@@ -105,13 +75,6 @@ describe Spree::LineItem, type: :model doendend- context '#save' do- it 'touches the order' do- expect(line_item.order).to receive(:touch)- line_item.touch- end- end-context '#discontinued' doit 'fetches discontinued products' doline_item.product.discontinue!@@ -151,10 +114,6 @@ describe Spree::LineItem, type: :model doorder.reloadend- it 'is an all-digital order' do- expect(order).to be_digital- end-it 'builds fulfillment items for a stock-limited digital variant' dosecond_licence = create(:product, delivery_profile: digital_profile, store: store).default_variantsecond_licence.update!(track_inventory: true)@@ -397,9 +356,12 @@ describe Spree::LineItem, type: :model doendend- describe '.currency' do- it 'returns the globally configured currency' do- line_item.currency == 'USD'+ describe '#currency' do+ it "defaults to the order's currency" do+ line_item = build(:line_item, order: build(:order, currency: 'EUR'), currency: nil)+ line_item.valid?++ expect(line_item.currency).to eq('EUR')endend@@ -440,7 +402,7 @@ describe Spree::LineItem, type: :model dovariant.stock_levels.update_all count_on_hand: 5, backorderable: falseSpree::Orders::AddItem.call(order: order, variant: variant, quantity: 5)order.rebuild_fulfillments!- order.finalize!+ Spree.order_complete_workflow.call(order: order, payment_pending: true)order.reloadend@@ -469,7 +431,7 @@ describe Spree::LineItem, type: :model dovariant.stock_levels.update_all count_on_hand: 7, backorderable: falseSpree::Orders::AddItem.call(order: order, variant: variant, quantity: 5)order.rebuild_fulfillments!- order.finalize!+ Spree.order_complete_workflow.call(order: order, payment_pending: true)order.reloadend@@ -516,10 +478,6 @@ describe Spree::LineItem, type: :model doenddescribe '#options=' do- it 'can handle updating a blank line item with no order' do- line_item.options = { price: 123 }- end-it 'updates the data provided in the options' doline_item.options = { price: 123 }expect(line_item.price).to eq 123@@ -726,58 +684,6 @@ describe Spree::LineItem, type: :model doendend- describe '#dimensions_unit' do- let(:variant) { create(:variant, dimensions_unit: 'cm') }- let(:line_item) { build(:line_item, variant: variant, quantity: 2) }-- it 'returns the dimension unit for the line item' do- expect(line_item.dimensions_unit).to eq('cm')- end- end-- describe '#weight_unit' do- let(:variant) { create(:variant, weight_unit: 'kg') }- let(:line_item) { build(:line_item, variant: variant, quantity: 2) }-- it 'returns the weight unit for the line item' do- expect(line_item.weight_unit).to eq('kg')- end- end-- describe '#should_update_price?' do- let(:variant) { create(:variant, price: 10) }- let(:order) { create(:order, store: store) }- let(:line_item) { create(:line_item, order: order, variant: variant) }-- context 'when order is not completed' do- it 'returns true' do- expect(order.completed?).to be false- expect(line_item.send(:should_update_price?)).to be true- end- end-- context 'when order is completed' do- before do- order.update_column(:completed_at, Time.current)- end-- it 'returns false' do- expect(order.completed?).to be true- expect(line_item.send(:should_update_price?)).to be false- end- end-- context 'when the line carries a negotiated (manual) price' do- before do- line_item.update_columns(price: 7.2, price_source: Spree::LineItem::MANUAL_PRICE_SOURCE)- end-- it 'returns false' do- expect(line_item.send(:should_update_price?)).to be false- end- end- end-describe '#recalculate_price' dolet(:variant) { create(:variant, price: 10) }let(:order) { create(:order, store: store) }diff --git a/spree/core/spec/models/spree/market_spec.rb b/spree/core/spec/models/spree/market_spec.rbindex be2be30681..ff873f392b 100644--- a/spree/core/spec/models/spree/market_spec.rb+++ b/spree/core/spec/models/spree/market_spec.rb@@ -3,32 +3,7 @@ require 'spec_helper'RSpec.describe Spree::Market, type: :model dolet(:store) { create(:store) }- describe 'validations' do- subject { build(:market, store: store) }-- it 'validates presence of countries' do- market = build(:market, store: store, countries: [])- expect(market).not_to be_valid- expect(market.errors[:countries]).to be_present- end-- it 'validates uniqueness of name scoped to store' do- create(:market, name: 'North America', store: store)- market = build(:market, name: 'North America', store: store)- expect(market).not_to be_valid- expect(market.errors[:name]).to be_present- end- end-describe 'associations' do- it 'has many countries through market_countries' do- country1 = create(:country)- country2 = create(:country)- market = create(:market, store: store, countries: [country1, country2])-- expect(market.countries).to contain_exactly(country1, country2)- end-it 'destroys market_countries on destroy' docreate(:market, :default, store: store)market = create(:market, store: store)@@ -197,29 +172,11 @@ RSpec.describe Spree::Market, type: :model doendend- describe '#can_be_deleted?' do- it 'returns false for the default market' do- create(:market, store: store)- market = create(:market, :default, store: store)- expect(market.can_be_deleted?).to be false- end-- it 'returns false for the only market in a store' do- market = store.markets.sole- expect(market.can_be_deleted?).to be false- end-- it 'returns true for a non-default market when other markets remain' do- create(:market, :default, store: store)- market = create(:market, store: store)- expect(market.can_be_deleted?).to be true- end- end-describe 'destroy' doit 'does not allow destroying the default market' docreate(:market, store: store)market = create(:market, :default, store: store)+ expect(market.can_be_deleted?).to be falseexpect(market.destroy).to be falseexpect(market.reload.deleted_at).to be_nilexpect(market.errors[:base]).to include(I18n.t('activerecord.errors.models.spree/market.attributes.base.cannot_destroy_default_market'))@@ -228,6 +185,7 @@ RSpec.describe Spree::Market, type: :model doit 'does not allow destroying the only market in a store' domarket = store.markets.solemarket.update_column(:default, false)+ expect(market.can_be_deleted?).to be falseexpect(market.destroy).to be falseexpect(market.reload.deleted_at).to be_nilexpect(market.errors[:base]).to include(I18n.t('activerecord.errors.models.spree/market.attributes.base.cannot_destroy_last_market'))@@ -236,6 +194,7 @@ RSpec.describe Spree::Market, type: :model doit 'allows destroying a non-default market when other markets remain' docreate(:market, :default, store: store)market = create(:market, store: store)+ expect(market.can_be_deleted?).to be trueexpect { market.destroy }.to change { market.reload.deleted_at }.from(nil).to(be_present)end@@ -283,13 +242,6 @@ RSpec.describe Spree::Market, type: :model doendend- describe 'has_prefix_id' do- it 'generates prefixed id with mkt prefix' do- market = create(:market, store: store)- expect(market.prefixed_id).to start_with('mkt_')- end- end-describe '#tax_provider_instance' dolet(:market) { create(:market, store: store) }diff --git a/spree/core/spec/models/spree/media_counters_spec.rb b/spree/core/spec/models/spree/media_counters_spec.rbindex bca630b398..c8d133fafd 100644--- a/spree/core/spec/models/spree/media_counters_spec.rb+++ b/spree/core/spec/models/spree/media_counters_spec.rb@@ -16,11 +16,6 @@ describe Spree::Media, type: :model doexpect(media).not_to be_validend- it 'allows only web image content types' do- media.attachment.attach(io: image_file, filename: 'thinking-cat.jpg', content_type: 'image/jpeg')- expect(media).to be_valid- end-it 'does not allow non-web image content types' domedia.attachment.attach(io: text_file, filename: 'text-file.txt', content_type: 'text/plain')expect(media).not_to be_valid@@ -67,13 +62,6 @@ describe Spree::Media, type: :model doimage = create(:media, viewable: variant)expect { image.destroy }.to change { variant.reload.media_count }.by(-1)end-- it 'tracks multiple images correctly' do- expect(variant.media_count).to eq(0)- create(:media, viewable: variant)- create(:media, viewable: variant)- expect(variant.reload.media_count).to eq(2)- endenddescribe 'product media_count counter cache' do@@ -92,14 +80,6 @@ describe Spree::Media, type: :model doimage = create(:media, viewable: variant)expect { image.destroy }.to change { product.reload.media_count }.by(-1)end-- it 'tracks media across all variants correctly' do- expect(product.media_count).to eq(0)- create(:media, viewable: product.default_variant)- create(:media, viewable: variant)- create(:media, viewable: variant)- expect(product.reload.media_count).to eq(3)- endenddescribe 'thumbnail choice with video in the gallery' dodiff --git a/spree/core/spec/models/spree/media_spec.rb b/spree/core/spec/models/spree/media_spec.rbindex 18f3605cfb..0e9063c97e 100644--- a/spree/core/spec/models/spree/media_spec.rb+++ b/spree/core/spec/models/spree/media_spec.rb@@ -324,11 +324,6 @@ describe Spree::Media, type: :model doexpect(asset.media_type).to eq('image')end- it 'defaults to image for Spree::Media subclass' do- image = Spree::Media.new- expect(image.media_type).to eq('image')- end-it 'answers a predicate per media type' doexpect(build(:media)).to be_imageexpect(build(:video_media)).to be_video@@ -337,10 +332,6 @@ describe Spree::Media, type: :model doenddescribe 'video' do- it 'accepts an uploaded video file' do- expect(build(:video_media)).to be_valid- end-it 'requires a file, not a URL' doasset = build(:media, media_type: 'video')asset.attachment.detach@@ -369,10 +360,6 @@ describe Spree::Media, type: :model doenddescribe 'external video' do- it 'accepts a YouTube link' do- expect(build(:external_video_media)).to be_valid- end-it 'accepts a Vimeo link' doexpect(build(:external_video_media, external_video_url: 'https://vimeo.com/123456789')).to be_validend@@ -515,45 +502,6 @@ describe Spree::Media, type: :model doendend- describe 'delegated methods' do- let(:asset) { create(:media) }- let(:attachment) { asset.attachment }-- before do- allow(asset).to receive(:attachment).and_return(attachment)- end-- it 'delegates :key to attachment' do- expect(attachment).to receive(:key)- asset.key- end-- it 'delegates :attached? to attachment' do- expect(attachment).to receive(:attached?)- asset.attached?- end-- it 'delegates :variant to attachment' do- expect(attachment).to receive(:variant)- asset.variant- end-- it 'delegates :variable? to attachment' do- expect(attachment).to receive(:variable?)- asset.variable?- end-- it 'delegates :blob to attachment' do- expect(attachment).to receive(:blob)- asset.blob- end-- it 'delegates :filename to attachment' do- expect(attachment).to receive(:filename)- asset.filename- end- end-describe '.with_session_uploaded_assets_uuid' dosubject { described_class.with_session_uploaded_assets_uuid(uuid) }diff --git a/spree/core/spec/models/spree/number_sequence_spec.rb b/spree/core/spec/models/spree/number_sequence_spec.rbindex 9434a989f2..c14c14c7c7 100644--- a/spree/core/spec/models/spree/number_sequence_spec.rb+++ b/spree/core/spec/models/spree/number_sequence_spec.rb@@ -66,12 +66,4 @@ RSpec.describe Spree::NumberSequence doexpect(values.sort).to eq([1, 2, 3, 4])endend-- describe 'uniqueness' do- it 'allows one row per store and resource type' do- create(:number_sequence, store: store, resource_type: 'order')-- expect(build(:number_sequence, store: store, resource_type: 'order')).not_to be_valid- end- endenddiff --git a/spree/core/spec/models/spree/option_type_spec.rb b/spree/core/spec/models/spree/option_type_spec.rbindex b7c07f8321..03afee7223 100644--- a/spree/core/spec/models/spree/option_type_spec.rb+++ b/spree/core/spec/models/spree/option_type_spec.rb@@ -3,10 +3,6 @@ require 'spec_helper'describe Spree::OptionType, type: :model doit_behaves_like 'metadata'- describe '#filterable' do- it { expect(subject.filterable).to eq(true) }- end-describe 'callbacks' dodescribe '#normalize_name' dolet!(:option_type) { build(:option_type, name: 'Shirt Size') }@@ -28,15 +24,6 @@ describe Spree::OptionType, type: :model doendend- let(:option_type_pl_translation) { option_type.translations.find_by(locale: 'pl') }-- it 'translates option type fields' do- expect(option_type.label).to eq('Size')-- expect(option_type_pl_translation).to be_present- expect(option_type_pl_translation.label).to eq('Rozmiar')- end-describe '#label' doit 'returns the translated label for the current locale' doexpect(option_type.label).to eq('Size')@@ -91,11 +78,6 @@ describe Spree::OptionType, type: :model doenddescribe 'kind' do- it 'defaults to dropdown' do- option_type = create(:option_type)- expect(option_type.kind).to eq('dropdown')- end-it 'validates inclusion in KINDS' dooption_type = build(:option_type, kind: 'invalid')expect(option_type).not_to be_valid@@ -108,11 +90,6 @@ describe Spree::OptionType, type: :model doexpect(option_type).to be_validendend-- it 'validates presence' do- option_type = build(:option_type, kind: '')- expect(option_type).not_to be_valid- endenddescribe '#color_swatch?' do@@ -146,16 +123,6 @@ describe Spree::OptionType, type: :model doenddescribe '#option_values=' do- context 'with an array of OptionValue records' do- let(:option_type) { create(:option_type) }- let(:option_value) { build(:option_value, option_type: option_type) }-- it 'delegates to the AR collection writer' do- option_type.option_values = [option_value]- expect(option_type.option_values).to eq([option_value])- end- end-context 'on a new option type' doit 'persists option values when the parent is saved' dooption_type = build(:option_type)diff --git a/spree/core/spec/models/spree/option_value_spec.rb b/spree/core/spec/models/spree/option_value_spec.rbindex 4db7b1dbbc..0fe6febaad 100644--- a/spree/core/spec/models/spree/option_value_spec.rb+++ b/spree/core/spec/models/spree/option_value_spec.rb@@ -45,29 +45,11 @@ describe Spree::OptionValue, type: :model doenddescribe 'color_code validation' do- it 'accepts valid 6-digit hex color' do- option_value = build(:option_value, color_code: '#FF0000')- expect(option_value).to be_valid- end-- it 'accepts valid 8-digit hex color (with alpha)' do- option_value = build(:option_value, color_code: '#FF0000AA')- expect(option_value).to be_valid- end-- it 'accepts lowercase hex' do- option_value = build(:option_value, color_code: '#aabbcc')- expect(option_value).to be_valid- end-- it 'accepts nil color_code' do- option_value = build(:option_value, color_code: nil)- expect(option_value).to be_valid- end-- it 'accepts blank color_code' do- option_value = build(:option_value, color_code: '')- expect(option_value).to be_valid+ it 'accepts 6- and 8-digit hex colors in any case, or no color' do+ ['#FF0000', '#FF0000AA', '#aabbcc', nil, ''].each do |valid|+ option_value = build(:option_value, color_code: valid)+ expect(option_value).to be_valid, "Expected #{valid.inspect} to be valid"+ endendit 'rejects invalid hex colors' do@@ -88,15 +70,6 @@ describe Spree::OptionValue, type: :model doendend- let(:option_value_pl_translation) { option_value.translations.find_by(locale: 'pl') }-- it 'translates option value fields' do- expect(option_value.label).to eq('Red')-- expect(option_value_pl_translation).to be_present- expect(option_value_pl_translation.label).to eq('Czerwony')- end-describe '#label' doit 'returns the translated label for the current locale' doexpect(option_value.label).to eq('Red')diff --git a/spree/core/spec/models/spree/option_value_variant_spec.rb b/spree/core/spec/models/spree/option_value_variant_spec.rbdeleted file mode 100644index 747df3e4a7..0000000000--- a/spree/core/spec/models/spree/option_value_variant_spec.rb+++ /dev/null@@ -1,14 +0,0 @@-require 'spec_helper'--describe Spree::OptionValueVariant, type: :model do- let(:option_value_variant) { create(:option_value_variant) }-- describe 'touching' do- let(:variant) { option_value_variant.variant }-- it 'touches a variant' do- expect(variant).to receive(:touch)- option_value_variant.touch- end- end-enddiff --git a/spree/core/spec/models/spree/order/checkout_spec.rb b/spree/core/spec/models/spree/order/checkout_spec.rbindex abfb8db421..85b70e4d3d 100644--- a/spree/core/spec/models/spree/order/checkout_spec.rb+++ b/spree/core/spec/models/spree/order/checkout_spec.rb@@ -54,16 +54,16 @@ describe Spree::Order, type: :model doit 'subscribes to newsletter', :events doexpect(Spree::NewsletterSubscriber).to receive(:subscribe).with(email: order.email, customer: order.customer, store: order.store)- order.finalize!+ Spree.order_complete_workflow.call(order: order, payment_pending: true)endendcontext 'when newsletter is not accepted for the order' dolet(:accept_marketing) { false }- it 'does not subscribe to newsletter' do+ it 'does not subscribe to newsletter', :events doexpect(Spree::NewsletterSubscriber).not_to receive(:subscribe)- order.finalize!+ Spree.order_complete_workflow.call(order: order, payment_pending: true)endendend@@ -78,7 +78,7 @@ describe Spree::Order, type: :model doit 'redeems the gift card' doexpect(gift_card.redeemed_at).to be_nil- expect { order.finalize! }.to change { gift_card.reload.status }.from('active').to('redeemed')+ expect { Spree.order_complete_workflow.call(order: order, payment_pending: true) }.to change { gift_card.reload.status }.from('active').to('redeemed')expect(gift_card.amount_used).to eq(order.total)expect(gift_card.amount_remaining).to eq(0)expect(gift_card.redeemed_at).to be_present@@ -88,7 +88,7 @@ describe Spree::Order, type: :model dolet(:gift_card) { create(:gift_card, amount: order.total + 1, store: store) }it 'partially redeems the gift card' do- expect { order.finalize! }.to change { gift_card.reload.status }.from('active').to('partially_redeemed')+ expect { Spree.order_complete_workflow.call(order: order, payment_pending: true) }.to change { gift_card.reload.status }.from('active').to('partially_redeemed')expect(gift_card.amount_used).to eq(order.total)expect(gift_card.amount_remaining).to eq(1)expect(gift_card.redeemed_at).to be_nil@@ -106,7 +106,7 @@ describe Spree::Order, type: :model doendit 'creates a new user', :events do- expect { order.finalize! }.to change { Spree.customer_class.count }.by(1)+ expect { Spree.order_complete_workflow.call(order: order, payment_pending: true) }.to change { Spree.customer_class.count }.by(1)# The subscriber attaches the user on its own loaded instance.expect(order.reload.customer).to be_presentexpect(order.customer.email).to eq(order.email)@@ -115,11 +115,11 @@ describe Spree::Order, type: :model docontext 'with signup_for_an_account set to false' dobefore do- allow(order).to receive(:signup_for_an_account?).and_return(false)+ order.update_column(:signup_for_an_account, false)end- it 'does not create a new user' do- expect { order.finalize! }.not_to change { Spree.customer_class.count }+ it 'does not create a new user', :events do+ expect { Spree.order_complete_workflow.call(order: order, payment_pending: true) }.not_to change { Spree.customer_class.count }endendenddiff --git a/spree/core/spec/models/spree/order/digital_auto_fulfillment_spec.rb b/spree/core/spec/models/spree/order/digital_auto_fulfillment_spec.rbindex d66538a9e3..ecf50e7087 100644--- a/spree/core/spec/models/spree/order/digital_auto_fulfillment_spec.rb+++ b/spree/core/spec/models/spree/order/digital_auto_fulfillment_spec.rb@@ -18,12 +18,12 @@ describe 'Digital auto-fulfillment on order completion', type: :model doendend- it 'fulfills the digital fulfillment and creates links per quantity on finalize' do+ it 'fulfills the digital fulfillment and creates links per quantity on completion' doline_item = order.line_items.firstline_item.update_columns(quantity: 2)order.fulfillment_items.update_all(quantity: 2)- order.finalize!+ Spree.order_complete_workflow.call(order: order, payment_pending: true)fulfillment = order.fulfillments.reload.firstexpect(fulfillment).to be_fulfilled@@ -31,8 +31,8 @@ describe 'Digital auto-fulfillment on order completion', type: :model doexpect(order.reload.fulfillment_status).to eq('fulfilled')end- it 'is idempotent across repeated finalization side effects' do- order.finalize!+ it 'is idempotent across repeated completion side effects' do+ Spree.order_complete_workflow.call(order: order, payment_pending: true)fulfillment = order.fulfillments.reload.firstexpect { fulfillment.provider.create_fulfillment(fulfillment) }.diff --git a/spree/core/spec/models/spree/order/payment_spec.rb b/spree/core/spec/models/spree/order/payment_spec.rbindex 92b479f545..9cb5778e5f 100644--- a/spree/core/spec/models/spree/order/payment_spec.rb+++ b/spree/core/spec/models/spree/order/payment_spec.rb@@ -69,16 +69,6 @@ module Spreeexpect(order.outstanding_balance).to eq(30.00)endend-- context 'order payment status should be partially paid' do- let!(:payment_amount) { 90.00 }- let!(:store_credit_amount) { 10.00 }-- it do- expect(order.payment_status).to eq('partially_paid')- expect(order.outstanding_balance).to eq(10.00)- end- endendend@@ -106,11 +96,11 @@ module Spreeit 'does not use failed payments' dopayment_1 = create(:payment, amount: 50, order: order)payment_2 = create(:payment, amount: 50, status: 'failed', order: order)- allow(order).to receive(:pending_payments).and_return([payment_1])-- expect(payment_2).not_to receive(:process!)order.process_payments!++ expect(payment_1.reload).not_to be_checkout+ expect(payment_2.reload).to be_failedendend@@ -191,25 +181,5 @@ module Spreeexpect(order.outstanding_balance).to eq 10endend-- context '#outstanding_balance?' do- it 'is true when total greater than payment_total' do- order.total = 10.10- order.payment_total = 9.50- expect(order.outstanding_balance?).to be true- end-- it 'is true when total less than payment_total' do- order.total = 8.25- order.payment_total = 10.44- expect(order.outstanding_balance?).to be true- end-- it 'is false when total equals payment_total' do- order.total = 10.10- order.payment_total = 10.10- expect(order.outstanding_balance?).to be false- end- endendenddiff --git a/spree/core/spec/models/spree/order/risk_assessment_spec.rb b/spree/core/spec/models/spree/order/risk_assessment_spec.rbindex ce75686bd9..be301ed244 100644--- a/spree/core/spec/models/spree/order/risk_assessment_spec.rb+++ b/spree/core/spec/models/spree/order/risk_assessment_spec.rb@@ -1,8 +1,6 @@require 'spec_helper'describe Spree::Order, type: :model do- let(:order) { create(:order) }-describe '.is_risky?' docontext 'Not risky order' dolet(:order) { FactoryBot.create(:order, payments: [payment]) }diff --git a/spree/core/spec/models/spree/order/shipments_spec.rb b/spree/core/spec/models/spree/order/shipments_spec.rbindex 6c2c07d44c..d2db1db954 100644--- a/spree/core/spec/models/spree/order/shipments_spec.rb+++ b/spree/core/spec/models/spree/order/shipments_spec.rb@@ -9,12 +9,12 @@ describe Spree::Order, type: :model docontext "except when order is completed, that's OrderInventory job" doit "doesn't touch anything" doallow(order).to receive_messages completed?: true- order.update_column(:shipment_total, 5)+ order.update_column(:delivery_total, 5)order.shipments.create!(stock_location: create(:stock_location))expect doorder.ensure_updated_fulfillments- end.not_to change(order, :shipment_total)+ end.not_to change(order, :delivery_total)expect doorder.ensure_updated_fulfillmentsdiff --git a/spree/core/spec/models/spree/order/state_machine_spec.rb b/spree/core/spec/models/spree/order/state_machine_spec.rbindex 719870c4d1..aff517bac0 100644--- a/spree/core/spec/models/spree/order/state_machine_spec.rb+++ b/spree/core/spec/models/spree/order/state_machine_spec.rb@@ -38,7 +38,7 @@ describe Spree::Order, type: :model doexpect(order.reload.status).to eq('canceled')expect(order.canceled_at).to be_presentexpect(order.fulfillments.reload).to all(be_canceled)- expect(order.payments.reload.map(&:state)).to all(be_in(%w[void invalid checkout]))+ expect(order.payments.reload.map(&:status)).to eq(%w[void])endit 'refuses to cancel when not allowed' do@@ -55,6 +55,7 @@ describe Spree::Order, type: :model dolet(:admin) { create(:admin_user) }it 'records the canceler and cancels through the service' do+ expect(Spree::Deprecation).to receive(:warn).with(/Order#canceled_by is deprecated/)order.canceled_by(admin)expect(order.reload.status).to eq('canceled')diff --git a/spree/core/spec/models/spree/order/updating_spec.rb b/spree/core/spec/models/spree/order/updating_spec.rbdeleted file mode 100644index 0b0c442500..0000000000--- a/spree/core/spec/models/spree/order/updating_spec.rb+++ /dev/null@@ -1,13 +0,0 @@-require 'spec_helper'--describe Spree::Order, type: :model do- let(:order) { create(:order) }-- context '#recalculate_totals!' do- let(:line_items) { create_list(:line_item, 1, amount: 5) }-- it 'persists recalculated totals' do- expect { order.recalculate_totals! }.to change { order.reload.updated_at }- end- end-enddiff --git a/spree/core/spec/models/spree/order_group_spec.rb b/spree/core/spec/models/spree/order_group_spec.rbindex 06b293d63d..6da25f7a4f 100644--- a/spree/core/spec/models/spree/order_group_spec.rb+++ b/spree/core/spec/models/spree/order_group_spec.rb@@ -202,10 +202,4 @@ RSpec.describe Spree::OrderGroup, type: :model doexpect(group.errors[:base]).to be_presentendend-- describe 'numbering' do- it 'takes an order-style number' do- expect(group.number).to start_with('R')- end- endenddiff --git a/spree/core/spec/models/spree/order_inventory_spec.rb b/spree/core/spec/models/spree/order_inventory_spec.rbindex b646ca568d..1cb835267b 100644--- a/spree/core/spec/models/spree/order_inventory_spec.rb+++ b/spree/core/spec/models/spree/order_inventory_spec.rb@@ -164,11 +164,6 @@ describe Spree::OrderInventory, type: :model dosubject.line_item.reloadend- it 'is a messed up order' do- expect(order.fulfillments.first.inventory_units_for(line_item.variant).sum(&:quantity)).to eq(3)- expect(line_item.quantity).to eq(2)- end-it 'decreases the number of inventory units' dosubject.verifyexpect(subject.fulfillment_items.reload.sum(:quantity)).to eq 2@@ -222,17 +217,6 @@ describe Spree::OrderInventory, type: :model doexpect(subject.send(:remove_from_shipment, shipment, 1)).to eq(1)end- it 'only attempts to destroy as many units as are eligible, and return amount destroyed' do- allow(shipment).to receive_messages(inventory_units_for_item: inventory_units_for_item)-- expect(shipment.inventory_units_for_item[0]).not_to receive(:destroy)- expect(shipment.inventory_units_for_item[1]).to receive(:destroy)- allow(shipment.inventory_units_for_item[0]).to receive(:save!)- allow(shipment.inventory_units_for_item[1]).to receive(:save!)-- expect(subject.send(:remove_from_shipment, shipment, 1)).to eq(1)- end-it 'destroys self if not inventory units remain' doallow(shipment).to receive(:fulfillment_items).and_return(shipment.fulfillment_items)allow(shipment.fulfillment_items).to receive_messages(sum: 0)diff --git a/spree/core/spec/models/spree/order_merger_spec.rb b/spree/core/spec/models/spree/order_merger_spec.rbindex 05faf41446..8acd01fbfd 100644--- a/spree/core/spec/models/spree/order_merger_spec.rb+++ b/spree/core/spec/models/spree/order_merger_spec.rb@@ -9,6 +9,13 @@ module Spreelet(:user) { create(:user) }let(:subject) { Spree::OrderMerger.new(order_1) }+ before { allow(Spree::Deprecation).to receive(:warn) }++ it 'warns that it is deprecated' do+ subject+ expect(Spree::Deprecation).to have_received(:warn).with(/Spree::OrderMerger is deprecated/)+ end+it 'destroys the other order' dosubject.merge!(order_2)expect { order_2.reload }.to raise_error(ActiveRecord::RecordNotFound)@@ -41,8 +48,8 @@ module Spreecontext 'merging together two orders with line items for the same variant' dobefore do- Spree::Carts::AddItem.call order: order_1, variant: variant, quantity: 1- Spree::Carts::AddItem.call order: order_2, variant: variant, quantity: 1+ Spree::Orders::AddItem.call(order: order_1, variant: variant, quantity: 1)+ Spree::Orders::AddItem.call(order: order_2, variant: variant, quantity: 1)endspecify do@@ -87,8 +94,8 @@ module Spreebefore doallow(order_1).to receive(:foos_match).and_return(false)- Spree::Carts::AddItem.call order: order_1, variant: variant, quantity: 1, options: {foos: {}}- Spree::Carts::AddItem.call order: order_2, variant: variant, quantity: 1, options: {foos: {}}+ Spree::Orders::AddItem.call(order: order_1, variant: variant, quantity: 1, options: {foos: {}})+ Spree::Orders::AddItem.call(order: order_2, variant: variant, quantity: 1, options: {foos: {}})endspecify do@@ -110,8 +117,8 @@ module Spreelet(:variant_2) { create(:variant) }before do- Spree::Carts::AddItem.call order: order_1, variant: variant, quantity: 1- Spree::Carts::AddItem.call order: order_2, variant: variant_2, quantity: 1+ Spree::Orders::AddItem.call(order: order_1, variant: variant, quantity: 1)+ Spree::Orders::AddItem.call(order: order_2, variant: variant_2, quantity: 1)endspecify do@@ -119,7 +126,7 @@ module Spreeexpect(order_1.line_items.length).to eq(2)expect(order_1.line_items.count).to eq(2)- expect(order_1.item_count).to eq 2+ expect(order_1.total_quantity).to eq 2expect(order_1.item_total).to eq order_1.line_items.map(&:amount).sum# No guarantee on ordering of line items, so we do this:@@ -132,8 +139,8 @@ module Spreelet(:variant_2) { create(:variant) }before do- Spree::Carts::AddItem.call order: order_1, variant: variant, quantity: 1- Spree::Carts::AddItem.call order: order_2, variant: variant_2, quantity: 1+ Spree::Orders::AddItem.call(order: order_1, variant: variant, quantity: 1)+ Spree::Orders::AddItem.call(order: order_2, variant: variant_2, quantity: 1)endit 'creates errors with invalid line items' dodiff --git a/spree/core/spec/models/spree/order_promotion_spec.rb b/spree/core/spec/models/spree/order_promotion_spec.rbindex 66a61bf1ec..4a9449b7f6 100644--- a/spree/core/spec/models/spree/order_promotion_spec.rb+++ b/spree/core/spec/models/spree/order_promotion_spec.rb@@ -13,18 +13,6 @@ describe Spree::OrderPromotion, type: :model doorder.discounts.promotion.update_all(amount: -5.0)end- context '#name' do- it 'returns the same value as Promotion name' do- expect(subject.name).to eq(promotion.name)- end- end-- context '#description' do- it 'returns the same value as Promotion description' do- expect(subject.description).to eq(promotion.description)- end- end-context '#amount' doit 'equals sum of adjustments created by promotion' doexpect(subject.amount).to eq(-5.0)diff --git a/spree/core/spec/models/spree/order_routing/strategy/parity_spec.rb b/spree/core/spec/models/spree/order_routing/strategy/parity_spec.rbindex 9a2984c2da..a9f8c98204 100644--- a/spree/core/spec/models/spree/order_routing/strategy/parity_spec.rb+++ b/spree/core/spec/models/spree/order_routing/strategy/parity_spec.rb@@ -389,23 +389,6 @@ RSpec.describe 'OrderRouting strategy parity', type: :model doendend- context 'stock reservations globally disabled' do- before { stub_store_preferences(stock_reservations_enabled: false) }-- let(:order) do- o = create(:order, store: store, ship_address: create(:ship_address))- create(:line_item, order: o, variant: variant_a, quantity: 1)- o.reload- end-- before { nyc.stock_level_or_create(variant_a).update!(count_on_hand: 5) }-- it 'allocates unaffected by reservation feature flag' do- packages = strategy.for_allocation- expect(total_on_hand(packages)).to eq(1)- end- end-# ---------------------------------------------------------------# Splitter chain: fulfillment-type split runs per-location# ---------------------------------------------------------------@@ -627,7 +610,7 @@ RSpec.describe 'OrderRouting strategy parity', type: :model do# No inventory units → no requested_variant_ids → no eligible# locations → empty package list. Same for both pipelines.packages = strategy.for_allocation- expect(packages).to eq([]).or be_empty+ expect(packages).to be_emptyexpect(total_on_hand(packages)).to eq(0)expect(total_backordered(packages)).to eq(0)enddiff --git a/spree/core/spec/models/spree/order_routing_rule_spec.rb b/spree/core/spec/models/spree/order_routing_rule_spec.rbindex 1072995ff6..7efc487617 100644--- a/spree/core/spec/models/spree/order_routing_rule_spec.rb+++ b/spree/core/spec/models/spree/order_routing_rule_spec.rb@@ -8,18 +8,6 @@ RSpec.describe Spree::OrderRoutingRule, type: :model dolet(:channel) { store.default_channel }describe 'validations' do- it 'requires a type' do- rule = described_class.new(store: store, channel: channel, position: 1)- expect(rule).not_to be_valid- expect(rule.errors[:type]).to be_present- end-- it 'requires a channel' do- rule = Spree::OrderRouting::Rules::PreferredLocation.new(store: store, position: 1)- expect(rule).not_to be_valid- expect(rule.errors[:channel]).to be_present- end-it 'is valid when instantiated as an STI subclass with a channel' do# The seeded rule of the same kind must go first — `type` is unique per channel.channel.order_routing_rules.find_by(type: 'Spree::OrderRouting::Rules::PreferredLocation').destroy!@@ -71,16 +59,6 @@ RSpec.describe Spree::OrderRoutingRule, type: :model doendend- describe 'Spree.order_routing.rules' do- it 'includes the core rule kinds' do- expect(Spree.order_routing.rules).to include(- Spree::OrderRouting::Rules::PreferredLocation,- Spree::OrderRouting::Rules::MinimizeSplits,- Spree::OrderRouting::Rules::DefaultLocation- )- end- end-describe 'scopes' do# Channels seed 3 default rules on create. We test scopes against fresh rules# in a clean channel to avoid coupling to the seed list.diff --git a/spree/core/spec/models/spree/order_spec.rb b/spree/core/spec/models/spree/order_spec.rbindex c7fc572ce3..95ad4ff2fb 100644--- a/spree/core/spec/models/spree/order_spec.rb+++ b/spree/core/spec/models/spree/order_spec.rb@@ -71,7 +71,7 @@ describe Spree::Order, type: :model dodescribe '.for_channel' dolet!(:channel) { create(:channel) }- let!(:channeled_order) { create(:order, user: user, channel: channel) }+ let!(:channeled_order) { create(:order, customer: user, channel: channel) }it 'filters by the given channel and returns all orders for nil' doexpect(described_class.for_channel(channel)).to contain_exactly(channeled_order)@@ -129,24 +129,6 @@ describe Spree::Order, type: :model doendend- describe 'Callbacks' do- let(:order) { build(:order, customer: user, store: store, ship_address: ship_address) }- let(:ship_address) { create(:address, customer: user) }-- describe '#clone_shipping_address' do- it 'clones the shipping address when use_shipping is true' do- order.update!(use_shipping: true)- expect(order.reload.bill_address).to eq(ship_address)- expect(user.reload.bill_address).to eq(ship_address)- end-- it 'does not clone the shipping address when use_shipping is false' do- order.update!(use_shipping: false)- expect(order.reload.bill_address).not_to eq(order.ship_address)- end- end- end-describe '#full_name' dosubject { order.full_name }@@ -181,15 +163,16 @@ describe Spree::Order, type: :model doenddescribe '#recalculate_totals!' do- let(:updater) { order.updater }-- before do- allow(order).to receive(:updater).and_return(updater)- allow(updater).to receive(:update).and_return(true)- end+ let(:order) { create(:order_with_line_items, store: store) }it 'recalculates and persists totals through the RecalculateTotals flow' do- expect { order.recalculate_totals! }.to change { order.reload.updated_at }+ expected_total = order.total+ order.update_columns(item_total: 0, total: 0)++ order.recalculate_totals!++ expect(order.reload.item_total).to eq(order.line_items.sum(&:amount))+ expect(order.total).to eq(expected_total)endend@@ -216,7 +199,7 @@ describe Spree::Order, type: :model do:payment,order: order,amount: order.total,- state: 'completed'+ status: 'completed')endlet(:payment_method) { double }@@ -260,22 +243,7 @@ describe Spree::Order, type: :model doexpect(order.status).to eq('canceled')expect(order.shipments).to all(have_attributes(state: 'canceled'))- expect(order.payments.store_credits).to all(have_attributes(state: 'void'))- end- end-- context 'when no gift card' do- let(:order) { create(:completed_order_with_totals, store: store) }- let!(:payment) { create(:payment, order: order, status: 'completed', amount: 10) }-- it 'handles additional actions' do- order.cancel- order.reload-- expect(order.status).to eq('canceled')- expect(order.shipments).to all(have_attributes(state: 'canceled'))- expect(order.payments).to all(have_attributes(state: 'void'))- expect(order.payments.store_credits).to all(have_attributes(state: 'void'))+ expect(order.payments.store_credits).to all(have_attributes(status: 'void'))endendend@@ -286,25 +254,14 @@ describe Spree::Order, type: :model dolet(:admin_user) { create :admin_user }let(:order) { create(:completed_order_with_totals) }- it 'cancels the order' do- expect { subject }.to change { order.reload.status }.to('canceled')- end-- it 'saves canceler_id' do- subject- expect(order.reload.canceler_id).to eq(admin_user.id)- end-- it 'has canceler' do- subject- expect(order.reload.canceler).to eq(admin_user)- end+ before { allow(Spree::Deprecation).to receive(:warn) }context 'when canceled_at is not given' doit 'saves canceled_at to Time.current' doTimecop.freeze(Time.current) dosubjectexpect(order.reload.canceled_at.to_s).to eq Time.current.to_s+ expect(Spree::Deprecation).to have_received(:warn).with(/Order#canceled_by is deprecated/)endendend@@ -332,18 +289,12 @@ describe Spree::Order, type: :model dodescribe '#create' dolet(:order) { Spree::Order.create }- it 'assigns an order number' do- expect(order.number).not_to be_nil- end-it 'creates a randomized 35 character token' doexpect(order.token.size).to eq(35)endendcontext 'creates shipments cost' do- let(:shipment) { double }-let(:order) { create(:order_with_line_items) }let(:shipment) { order.fulfillments.first }@@ -374,6 +325,8 @@ describe Spree::Order, type: :model dolet(:order) { create :order_with_line_items }+ before { allow(Spree::Deprecation).to receive(:warn) }+context 'when variant is destroyed' dobefore doorder.line_items.first.variant.discontinue!@@ -392,6 +345,7 @@ describe Spree::Order, type: :model docontext 'when no variants are destroyed' doit 'is true' doexpect(subject).to be_truthy+ expect(Spree::Deprecation).to have_received(:warn).with(/ensure_line_item_variants_are_not_discontinued is deprecated/)endendend@@ -399,15 +353,15 @@ describe Spree::Order, type: :model dodescribe '#ensure_line_items_are_in_stock' dosubject { order.ensure_line_items_are_in_stock }- let(:line_item) { create(:line_item, order: order) }-before do+ allow(Spree::Deprecation).to receive(:warn)allow(order).to receive(:insufficient_stock_lines).and_return([true])endit 'has error message' dosubjectexpect(order.errors[:base]).to include(I18n.t('spree.insufficient_stock_lines_present'))+ expect(Spree::Deprecation).to have_received(:warn).with(/ensure_line_items_are_in_stock is deprecated/)endit 'is false' do@@ -452,34 +406,6 @@ describe Spree::Order, type: :model doendend- describe '#display_outstanding_balance' do- it 'returns the value as a spree money' do- allow(order).to receive(:outstanding_balance).and_return(10.55)- expect(order.display_outstanding_balance).to eq(Spree::Money.new(10.55))- end- end-- describe '#display_item_total' do- it 'returns the value as a spree money' do- allow(order).to receive(:item_total).and_return(10.55)- expect(order.display_item_total).to eq(Spree::Money.new(10.55))- end- end-- describe '#display_adjustment_total' do- it 'returns the value as a spree money' do- order.adjustment_total = 10.55- expect(order.display_adjustment_total).to eq(Spree::Money.new(10.55))- end- end-- describe '#display_promo_total' do- it 'returns the value as a spree money' do- order.promo_total = 10.55- expect(order.display_promo_total).to eq(Spree::Money.new(10.55))- end- end-describe '#display_total' doit 'returns the value as a spree money' doorder.total = 10.55@@ -487,16 +413,6 @@ describe Spree::Order, type: :model doendend- describe '#currency' do- context 'when object currency is EUR' do- before { order.currency = 'EUR' }-- it 'returns the currency from the object' do- expect(order.currency).to eq('EUR')- end- end- end-describe '#tax_address' dosubject { order.tax_address }@@ -522,61 +438,22 @@ describe Spree::Order, type: :model do# The deprecated twin of #payment_methods; it must keep matching its# replacement until it is removed in 6.1.describe '#collect_payment_methods' do- it 'excludes an inactive method even when it is storefront-visible' do- store.payment_methods.create!(name: 'Fake', active: false, storefront_visible: true)-- expect(order.send(:collect_payment_methods)).to be_empty- end-- it 'excludes a backoffice-only method' do- store.payment_methods.create!(name: 'Fake', active: true, storefront_visible: false)-- expect(order.send(:collect_payment_methods)).to be_empty- end-it 'includes an active storefront-visible method' dopayment_method = store.payment_methods.create!(name: 'Fake', active: true, storefront_visible: true)+ expect(Spree::Deprecation).to receive(:warn).with(/collect_payment_methods is deprecated/)expect(order.send(:collect_payment_methods)).to include(payment_method)endend# Regression test for #4199describe '#collect_frontend_payment_methods' do- let(:ok_method) { double :payment_method, store_credit?: false, available_for_order?: true, available_for_store?: true, store: store }- let(:no_method) { double :payment_method, store_credit?: false, available_for_order?: false, available_for_store?: true, store: store }- let(:methods) { [ok_method, no_method] }let(:store_2) { create(:store) }let(:order_from_different_store) { create(:order, customer: user, store: store_2) }- it 'includes frontend payment methods' do- payment_method = store.payment_methods.create!(name: 'Fake', active: true, storefront_visible: true)- expect(order.collect_frontend_payment_methods).to include(payment_method)- end-- it 'includes payment methods that are storefront-visible by default' do- payment_method = store.payment_methods.create!(name: 'Fake', active: true)- expect(order.collect_frontend_payment_methods).to include(payment_method)- end-- it 'does not include backend payment method' do- store.payment_methods.create!(name: 'Fake', active: true, storefront_visible: false)- expect(order.collect_frontend_payment_methods.count).to eq(0)- end-- it 'does not include inactive payment methods' do- store.payment_methods.create!(name: 'Fake', active: false, storefront_visible: true)- expect(order.collect_frontend_payment_methods.count).to eq(0)- end-- it 'does not include a payment method that is not suitable for this order' do- allow(order.store).to receive_message_chain(:payment_methods, :active, :storefront_visible).and_return(methods)-- expect(order.collect_frontend_payment_methods).to contain_exactly(ok_method)- end-it 'does not include a payment method from different stores' dopayment_method = store_2.payment_methods.create!(name: 'Fake', active: true)+ expect(Spree::Deprecation).to receive(:warn).with(/collect_frontend_payment_methods is deprecated/).twiceexpect(order.collect_frontend_payment_methods).not_to include(payment_method)expect(order_from_different_store.collect_frontend_payment_methods).to include(payment_method)@@ -792,37 +669,6 @@ describe Spree::Order, type: :model doendend- describe '#approved_by' do- let(:admin_user) { create(:admin_user) }- let(:order) { create(:order_ready_to_ship) }-- it 'sets approver_id' do- order.approved_by(admin_user)- expect(order.reload.approver_id).to eq(admin_user.id)- end-- it 'sets approved_at' do- Timecop.freeze(Time.current) do- order.approved_by(admin_user)- expect(order.reload.approved_at.to_s).to eq(Time.current.to_s)- end- end-- it 'sets considered_risky to false' do- order.update_column(:considered_risky, true)- order.approved_by(admin_user)- expect(order.reload.considered_risky).to be false- end-- context 'events', :events do- it 'publishes order.approved event' do- allow(Spree::Events).to receive(:publish)- order.approved_by(admin_user)- expect(Spree::Events).to have_received(:publish).with('order.approved', any_args)- end- end- end-describe '#considered_risky!' dolet(:order) { create(:completed_order_with_totals) }@@ -850,14 +696,6 @@ describe Spree::Order, type: :model doorder.approve!expect(order.reload.considered_risky).to be falseend-- context 'events', :events do- it 'publishes order.approved event' do- allow(Spree::Events).to receive(:publish)- order.approve!- expect(Spree::Events).to have_received(:publish).with('order.approved', any_args)- end- endenddescribe '#ensure_updated_fulfillments' do@@ -994,16 +832,6 @@ describe Spree::Order, type: :model doendend- describe '#completed?' do- it 'indicates if order is completed' do- order.completed_at = nil- expect(order.completed?).to be false-- order.completed_at = Time.current- expect(order.completed?).to be true- end- end-describe '#allow_checkout?' doit 'is true if there are line_items in the order' doallow(order).to receive_message_chain(:line_items, :exists?).and_return(true)@@ -1032,46 +860,6 @@ describe Spree::Order, type: :model doendend- describe '#tax_total' do- it 'adds included tax and additional tax' do- allow(order).to receive_messages(additional_tax_total: 10, included_tax_total: 20)-- expect(order.tax_total).to eq 30- end- end-- # Regression test for #4923- context 'locking' do- let(:order) { create(:order) } # need a persisted in order to test locking-- it 'can lock' do- expect { order.with_lock {} }.not_to raise_error- end- end-- describe '#pre_tax_item_amount' do- let(:order) { create(:order) }-- before do- line_item = create(:line_item, order: order, price: 10, quantity: 2)- line_item_2 = create(:line_item, order: order, price: 30, quantity: 1)-- line_item.update(pre_tax_amount: 5.0)- line_item_2.update(pre_tax_amount: 14.0)- end-- it "sums all of the line items' pre tax amounts" do- expect(order.pre_tax_item_amount).to eq BigDecimal(19)- end- end-- describe '#display_pre_tax_item_amount' do- it 'returns the value as a spree money' do- allow(order).to receive(:pre_tax_item_amount).and_return(10.55)- expect(order.display_pre_tax_item_amount).to eq(Spree::Money.new(10.55))- end- end-describe '#pre_tax_total' dolet(:order) { create(:order) }@@ -1088,13 +876,6 @@ describe Spree::Order, type: :model doendend- describe '#display_pre_tax_total' do- it 'returns the value as a spree money' do- allow(order).to receive(:pre_tax_total).and_return(10.55)- expect(order.display_pre_tax_total).to eq(Spree::Money.new(10.55))- end- end-describe '#analytics_subtotal' dolet(:order) { create(:order_with_line_items, line_items_count: 2) }@@ -1109,15 +890,6 @@ describe Spree::Order, type: :model doendend- describe '#quantity' do- # Uses a persisted record, as the quantity is retrieved via a DB count- let(:order) { create :order_with_line_items, line_items_count: 3 }-- it 'sums the quantity of all line items' do- expect(order.quantity).to eq 3- end- end-describe '#rebuild_fulfillments!' docontext 'has unassociated inventory units' dolet!(:inventory_unit) { create(:fulfillment_item, order: subject) }@@ -1522,9 +1294,12 @@ describe Spree::Order, type: :model dolet!(:order) { create(:order_with_line_items, line_items_count: 10) }+ before { allow(Spree::Deprecation).to receive(:warn) }+context 'without promotions' doit 'returns 0' doexpect(subject).to eq(BigDecimal('0.00'))+ expect(Spree::Deprecation).to have_received(:warn).with(/cart_promo_total is deprecated/)endend@@ -1658,201 +1433,17 @@ describe Spree::Order, type: :model dolet(:ship_address) { create(:address, customer: user) }let(:address) { create(:address, customer: user) }- context 'when assigned address exist' do- context 'when assigned address belongs to user' do- it 'assigns address to order as bill address' do- expect(order.bill_address_id).not_to eq address.id- subject- expect(order.bill_address_id).to eq address.id- end-- it 'does not set address as user default bill address' do- subject- expect(user.bill_address_id).not_to eq address.id- end- end- end-- context 'when assigned address does not belong to user' do- let(:address) { create(:address, customer: create(:user)) }-- it 'sets order bill address to nil' do- expect { subject }.to change { order.bill_address_id }.to(nil)- end- end-- context 'with guest user' do- let(:user) { nil }- let(:address) { create(:address, customer: nil) }-- context 'when assigning the same existing address' do- let(:address) { bill_address }-- it 'does nothing' do- expect { subject }.not_to(change { order.bill_address_id })- end- end-- context 'when assigning a different existing address' do- it 'sets order bill address to nil' do- expect { subject }.to change { order.bill_address_id }.to(nil)- end- end- end- end-- describe '#bill_address_attributes=' do- subject { order.bill_address_attributes = address_attributes }-- let(:order) { create(:order, customer: user) }- let(:address_attributes) { attributes_for(:address) }-- context 'when user has default bill address' do- let!(:user) { create(:user_with_addresses) }-- it 'changes user default bill address' do- expect(user.bill_address_id).not_to be_nil-- expect { subject }.to(change { user.bill_address_id })- end- end-- context 'when user has no default address' do- let!(:user) { create(:user) }-- it 'assigns a new default address' do- subject-- expect(user.bill_address).to be_present- expect(user.bill_address.address1).to eq(address_attributes[:address1])- end- end-- context 'when user does not have any addresses' do- let!(:user) { create(:user) }-- it 'changes user default bill addresss' do- expect(user.bill_address_id).to be_nil- expect(user.addresses).to be_empty-- expect { subject }.to change { user.bill_address_id }- end- end-- context 'when user has address but without default bill address' do- let(:address) { create(:address, customer: user) }- let(:user) { create(:user_with_addresses) }-- before { user.bill_address = nil }-- it 'changes user default bill addresss' do- expect(user.bill_address_id).to be_nil- expect(user.addresses).not_to be_empty-- expect { subject }.to change { user.bill_address_id }- end- end- end-- describe 'ship_address_id=' do- subject { order.ship_address_id = address.id }-- let(:user) { create(:user) }- let(:order) { create(:order, customer: user, bill_address: bill_address, ship_address: ship_address) }- let(:bill_address) { create(:address, customer: user) }- let(:ship_address) { create(:address, customer: user) }- let(:address) { create(:address, customer: user) }-- context 'when assigned address exist' do- context 'when assigned address belongs to user' do- it 'assigns address to order as ship address' do- expect(order.ship_address_id).not_to eq address.id- subject- expect(order.ship_address_id).to eq address.id- end-- it 'does not set address as user default ship address' do- subject- expect(user.ship_address_id).not_to eq address.id- end- end- end-- context 'when assigned address does not belong to user' do- let(:address) { create(:address, customer: create(:user)) }-- it 'sets order ship address to nil' do- expect { subject }.to change { order.ship_address_id }.to(nil)- end+ it 'does not set address as user default bill address' do+ subject+ expect(user.bill_address_id).not_to eq address.idend- context 'with guest user' do+ context 'with guest user assigning the same existing address' dolet(:user) { nil }- let(:address) { create(:address, customer: nil) }-- context 'when assigning the same existing address' do- let(:address) { ship_address }-- it 'does nothing' do- expect { subject }.not_to(change { order.ship_address_id })- end- end-- context 'when assigning a different existing address' do- it 'sets order ship address to nil' do- expect { subject }.to change { order.ship_address_id }.to(nil)- end- end- end- end-- describe '#ship_address_attributes=' do- subject { order.ship_address_attributes = address_attributes }-- let(:order) { create(:order, customer: user) }- let(:address_attributes) { attributes_for(:address) }+ let(:address) { bill_address }- context 'when user has default ship address' do- let!(:user) { create(:user_with_addresses) }-- it 'changes user default ship addresss' do- expect { subject }.to(change { user.ship_address_id })- end- end-- context 'when user has no default address' do- let!(:user) { create(:user) }-- it 'assigns a new default address' do- subject-- expect(user.ship_address).to be_present- expect(user.ship_address.address1).to eq(address_attributes[:address1])- end- end-- context 'when user does not have any addresses' do- let!(:user) { create(:user) }-- it 'changes user default ship address' do- expect(user.ship_address_id).to be_nil- expect(user.addresses).to be_empty-- expect { subject }.to change { user.ship_address_id }- end- end-- context 'when user has address but without default ship address' do- let(:address) { create(:address, customer: user) }- let(:user) { create(:user_with_addresses) }-- before { user.update(ship_address: nil) }-- it 'changes user default ship address' do- expect(user.ship_address_id).to be_nil- expect(user.addresses).not_to be_empty-- expect { subject }.to change { user.ship_address_id }+ it 'does nothing' do+ expect { subject }.not_to(change { order.bill_address_id })endendend@@ -1961,8 +1552,8 @@ describe Spree::Order, type: :model doendend- describe '#fully_shipped?' do- subject { order.fully_shipped? }+ describe '#fully_fulfilled?' do+ subject { order.fully_fulfilled? }let!(:shipments) docreate_list(@@ -1985,6 +1576,11 @@ describe Spree::Order, type: :model docontext 'when not all order shipments were shipped' doit { expect(subject).to eq(false) }end++ it 'is still answered by the deprecated fully_shipped?' do+ expect(Spree::Deprecation).to receive(:warn).with(/fully_shipped\? is deprecated/)+ expect(order.fully_shipped?).to eq(false)+ endenddescribe '#total_weight' do@@ -2198,8 +1794,8 @@ describe Spree::Order, type: :model doendend- describe '#line_items_without_shipping_rates' do- subject { order.line_items_without_shipping_rates }+ describe '#line_items_without_delivery_rates' do+ subject { order.line_items_without_delivery_rates }let(:order) { create(:order_with_line_items) }let(:shipment) { order.fulfillments.first }@@ -2219,6 +1815,11 @@ describe Spree::Order, type: :model doit 'returns the line items without shipping rates' doexpect(subject).to eq([line_item])end++ it 'is still answered by the deprecated line_items_without_shipping_rates' do+ expect(Spree::Deprecation).to receive(:warn).with(/line_items_without_shipping_rates is deprecated/)+ expect(order.line_items_without_shipping_rates).to eq([line_item])+ endendcontext 'when order has shipments with shipping rates' do@@ -2293,18 +1894,12 @@ describe Spree::Order, type: :model doendcontext 'when order has line items' do- let(:order) { create(:order_with_line_items) }+ let(:order) { create(:order_with_line_items, line_items_count: 2) }- let(:presenter) { Spree::CSV::OrderLineItemPresenter }- let(:presenter_instance) { instance_double(presenter) }-- before do- allow(presenter).to receive(:new).and_return(presenter_instance)- allow(presenter_instance).to receive(:call).and_return('csv_line')- end-- it 'returns the csv lines' do- expect(subject).to eq(['csv_line'])+ it 'returns a csv line per line item' do+ expect(subject.size).to eq(2)+ expect(subject).to all(include(order.number))+ expect(subject.flatten).to include(*order.line_items.map(&:sku))endendend@@ -2417,9 +2012,12 @@ describe Spree::Order, type: :model dodescribe '#remove_out_of_stock_items!' dolet(:order) { create(:order_with_totals, store: store, customer: user) }+ before { allow(Spree::Deprecation).to receive(:warn) }+context 'when all items are in stock' doit 'does not remove any items' doexpect { order.remove_out_of_stock_items! }.not_to change { order.line_items.count }+ expect(Spree::Deprecation).to have_received(:warn).with(/remove_out_of_stock_items! is deprecated/)endit 'sets warnings to empty array' dodiff --git a/spree/core/spec/models/spree/order_updater_spec.rb b/spree/core/spec/models/spree/order_updater_spec.rbindex f5d194e641..c681e96fab 100644--- a/spree/core/spec/models/spree/order_updater_spec.rb+++ b/spree/core/spec/models/spree/order_updater_spec.rb@@ -5,6 +5,8 @@ module Spreelet(:order) { create(:order) }let(:updater) { order.updater }+ before { allow(Spree::Deprecation).to receive(:warn) }+context 'order totals' dobefore docreate_list(:line_item, 2, order: order, price: 10)@@ -27,7 +29,7 @@ module Spreecreate(:fulfillment, order: order, cost: 10)order.reloadupdater.update_shipment_total- expect(order.shipment_total).to eq(10)+ expect(order.delivery_total).to eq(10)endcontext 'with order promotion followed by line item addition' do@@ -49,7 +51,7 @@ module Spreeendit 'updates promotion total' do- expect(order.promo_total).to eq(-3)+ expect(order.discount_total).to eq(-3)endend@@ -67,7 +69,7 @@ module Spreeexpect(order.adjustment_total).to eq(2.55)expect(order.additional_tax_total).to eq(0.05)expect(order.fee_total).to eq(5)- expect(order.promo_total).to eq(0)+ expect(order.discount_total).to eq(0)endend@@ -78,7 +80,7 @@ module Spreeorder.recalculate_totals!- expect(order.item_count).to eq(2)+ expect(order.total_quantity).to eq(2)endend@@ -296,10 +298,6 @@ module Spreeit 'updates each shipment' doallow(order).to receive_messages fulfillments: shipments- allow(shipments).to receive_messages states: []- allow(shipments).to receive_messages ready: []- allow(shipments).to receive_messages pending: []- allow(shipments).to receive_messages shipped: []expect(shipment).to receive(:update!).with(order)updater.update_shipments@@ -331,28 +329,8 @@ module Spreeendcontext 'incomplete order' do- let(:shipment) { create(:fulfillment) }- let(:shipments) { [shipment] }-- it 'doesnt update payment state' do- expect(updater).not_to receive(:update_payment_state)- updater.update- end-- it 'doesnt update shipment state' do- expect(updater).not_to receive(:update_shipment_state)- updater.update- end-- it 'doesnt update each shipment' do- allow(order).to receive_messages shipments: shipments- allow(shipments).to receive_messages states: []- allow(shipments).to receive_messages ready: []- allow(shipments).to receive_messages pending: []- allow(shipments).to receive_messages shipped: []-- allow(updater).to receive(:update_totals) # Otherwise this gets called and causes a scene- expect(updater).not_to receive(:update_shipments).with(order)+ it 'doesnt update statuses' do+ expect(updater).not_to receive(:update_statuses)updater.updateenddiff --git a/spree/core/spec/models/spree/package_type_spec.rb b/spree/core/spec/models/spree/package_type_spec.rbindex b5eee69e94..3bf7d96e5b 100644--- a/spree/core/spec/models/spree/package_type_spec.rb+++ b/spree/core/spec/models/spree/package_type_spec.rb@@ -198,13 +198,6 @@ RSpec.describe Spree::PackageType, type: :model doexpect(store.reload.default_package_type).to eq(package_type)end- it 'allows it once another row holds the flag' do- first = create(:package_type, store: store, default: true)- create(:package_type, store: store, default: true)-- expect(first.reload).not_to be_default- end-# The marketplace's box is not a replacement for the seller's: it is a# different owner's row, so it cannot stand in as "another default".it 'refuses a seller’s only default even when the marketplace has one' dodiff --git a/spree/core/spec/models/spree/payment/custom_events_spec.rb b/spree/core/spec/models/spree/payment/custom_events_spec.rbindex 42523a1216..bc6fcbc1fc 100644--- a/spree/core/spec/models/spree/payment/custom_events_spec.rb+++ b/spree/core/spec/models/spree/payment/custom_events_spec.rb@@ -12,16 +12,8 @@ RSpec.describe Spree::Payment::CustomEvents doenddescribe 'payment.paid event' do- it 'publishes payment.paid when payment state changes to completed' do- payment.update!(amount: order.total - 1)-- payment.update!(state: 'completed')-- expect(Spree::Events).to have_received(:publish).with('payment.paid', anything, anything)- end-it 'does not publish payment.paid when state changes to something other than completed' do- payment.update!(state: 'processing')+ payment.update!(status: 'processing')expect(Spree::Events).not_to have_received(:publish).with('payment.paid', anything, anything)end@@ -29,7 +21,7 @@ RSpec.describe Spree::Payment::CustomEvents doit 'does not publish when events are disabled' doallow(Spree::Events).to receive(:enabled?).and_return(false)- payment.update!(state: 'completed')+ payment.update!(status: 'completed')expect(Spree::Events).not_to have_received(:publish).with('payment.paid', anything, anything)end@@ -39,7 +31,7 @@ RSpec.describe Spree::Payment::CustomEvents doit 'publishes order.paid when payment completes and order is fully paid' dopayment.update!(amount: order.total)- payment.update!(state: 'completed')+ payment.update!(status: 'completed')expect(Spree::Events).to have_received(:publish).with('payment.paid', anything, anything)expect(Spree::Events).to have_received(:publish).with('order.paid', anything, anything)@@ -48,7 +40,7 @@ RSpec.describe Spree::Payment::CustomEvents doit 'does not publish order.paid when order still has outstanding balance' dopayment.update!(amount: order.total - 1)- payment.update!(state: 'completed')+ payment.update!(status: 'completed')expect(Spree::Events).to have_received(:publish).with('payment.paid', anything, anything)expect(Spree::Events).not_to have_received(:publish).with('order.paid', anything, anything)diff --git a/spree/core/spec/models/spree/payment/gateway_options_spec.rb b/spree/core/spec/models/spree/payment/gateway_options_spec.rbindex 6ae66107e4..24c63c9ae9 100644--- a/spree/core/spec/models/spree/payment/gateway_options_spec.rb+++ b/spree/core/spec/models/spree/payment/gateway_options_spec.rb@@ -45,115 +45,6 @@ RSpec.describe Spree::Payment::GatewayOptions, type: :model dodouble Spree::Address, gateway_hash: { ship: :address }end- describe '#order' do- subject { options.order }-- it { is_expected.to eq order }- end-- describe '#payment' do- subject { options.payment }-- it { is_expected.to eq payment }- end-- describe '#payment_id' do- subject { options.payment_id }-- it { is_expected.to eq 'P1566' }- end-- describe '#payment_prefixed_id' do- subject { options.payment_prefixed_id }-- # The stable lookup handle: the derived number cannot be queried (NULL- # column on 6.0 rows) and shifts when a sibling is destroyed.- it { is_expected.to eq 'py_k5nR8xLq' }- end-- describe '#email' do- subject { options.email }-- it { is_expected.to eq '[email protected]' }- end-- describe '#customer' do- subject { options.customer }-- it { is_expected.to eq '[email protected]' }- end-- describe '#customer_id' do- subject { options.customer_id }-- it { is_expected.to eq 144 }- end-- describe '#ip' do- subject { options.ip }-- it { is_expected.to eq '0.0.0.0' }- end-- describe '#order_id' do- subject { options.order_id }-- # The payment number already names its order, so this is no longer the- # order number and the payment number concatenated.- it { is_expected.to eq 'P1566' }- end-- describe '#idempotency_key' do- subject { options.idempotency_key }-- # The prefixed ID, not the number — a derived number can shift if an- # earlier sibling payment is destroyed, and a shifted key could collide- # with one already used at the gateway.- it { is_expected.to eq 'spree-py_k5nR8xLq' }- end-- describe '#shipping' do- subject { options.shipping }-- it { is_expected.to eq 1244 }- end-- describe '#tax' do- subject { options.tax }-- it { is_expected.to eq 153 }- end-- describe '#subtotal' do- subject { options.subtotal }-- it { is_expected.to eq 1511 }- end-- describe '#discount' do- subject { options.discount }-- it { is_expected.to eq 257 }- end-- describe '#currency' do- subject { options.currency }-- it { is_expected.to eq 'EUR' }- end-- describe '#billing_address' do- subject { options.billing_address }-- it { is_expected.to eq(bill: :address) }- end-- describe '#shipping_address' do- subject { options.shipping_address }-- it { is_expected.to eq(ship: :address) }- end-describe '#to_hash' dosubject { options.to_hash }@@ -163,9 +54,16 @@ RSpec.describe Spree::Payment::GatewayOptions, type: :model docustomer: '[email protected]',customer_id: 144,ip: '0.0.0.0',+ # The payment number already names its order, so this is no longer the+ # order number and the payment number concatenated.order_id: 'P1566',payment_id: 'P1566',+ # The stable lookup handle: the derived number cannot be queried (NULL+ # column on 6.0 rows) and shifts when a sibling is destroyed.payment_prefixed_id: 'py_k5nR8xLq',+ # The prefixed ID, not the number — a derived number can shift if an+ # earlier sibling payment is destroyed, and a shifted key could collide+ # with one already used at the gateway.idempotency_key: 'spree-py_k5nR8xLq',shipping: '1244'.to_d,tax: '153'.to_d,diff --git a/spree/core/spec/models/spree/payment/store_credit_spec.rb b/spree/core/spec/models/spree/payment/store_credit_spec.rbindex ca318c21bb..8df08b372f 100644--- a/spree/core/spec/models/spree/payment/store_credit_spec.rb+++ b/spree/core/spec/models/spree/payment/store_credit_spec.rb@@ -47,7 +47,7 @@ describe 'Payment' docontext 'cancels successfully' doit 'voids the payment', retry: 3 do- expect { subject }.to change(payment, :state).to('void')+ expect { subject }.to change(payment, :status).to('void')endend@@ -55,7 +55,7 @@ describe 'Payment' doit 'does not change the payment state' doexpect(payment.payment_method).to receive(:cancel).with(payment.response_code, payment, refund: true) { failed_response }expect { subject }.to raise_error(Spree::Core::GatewayError)- expect(payment.reload.state).not_to eq 'void'+ expect(payment.reload.status).not_to eq 'void'endendenddiff --git a/spree/core/spec/models/spree/payment_method/store_credit_spec.rb b/spree/core/spec/models/spree/payment_method/store_credit_spec.rbindex bc20cc29eb..405ca80b23 100644--- a/spree/core/spec/models/spree/payment_method/store_credit_spec.rb+++ b/spree/core/spec/models/spree/payment_method/store_credit_spec.rb@@ -224,7 +224,7 @@ describe Spree::PaymentMethod::StoreCredit doendcontext "when the store credit isn't credited successfully" do- before { allow(Spree::StoreCredit).to receive_messages(credit: false) }+ before { allow_any_instance_of(Spree::StoreCredit).to receive_messages(credit: false) }it 'returns an error response' doexpect(subject.success?).to be false@@ -245,8 +245,8 @@ describe Spree::PaymentMethod::StoreCredit dolet(:originator) { double('originator') }it 'passes the originator' do- allow_any_instance_of(Spree::StoreCredit).to receive(:credit).- with(anything, anything, anything, action_originator: originator)+ expect_any_instance_of(Spree::StoreCredit).to receive(:credit).+ with(anything, anything, anything, action_originator: originator).and_return(true)subjectendend@@ -271,8 +271,8 @@ describe Spree::PaymentMethod::StoreCredit docontext 'store credit event found' doit 'creates a store credit for the same amount that was captured' do- allow_any_instance_of(Spree::StoreCredit).to receive(:credit).- with(captured_amount, auth_code, store_credit.currency)+ expect_any_instance_of(Spree::StoreCredit).to receive(:credit).+ with(captured_amount, auth_code, store_credit.currency).and_return(true)subjectenddiff --git a/spree/core/spec/models/spree/payment_method_spec.rb b/spree/core/spec/models/spree/payment_method_spec.rbindex 90815606ac..4b0eb1e7fd 100644--- a/spree/core/spec/models/spree/payment_method_spec.rb+++ b/spree/core/spec/models/spree/payment_method_spec.rb@@ -46,10 +46,6 @@ describe Spree::PaymentMethod, type: :model do)end- it 'defaults to visible on the storefront' do- expect(visible_method.storefront_visible).to be true- end-describe '.storefront_visible' doit 'returns only customer-facing methods' doexpect(Spree::PaymentMethod.storefront_visible).to contain_exactly(visible_method)@@ -93,8 +89,11 @@ describe Spree::PaymentMethod, type: :model dolet(:visible_method) { build(:check_payment_method) }let(:admin_only_method) { build(:check_payment_method, storefront_visible: false) }+ before { allow(Spree::Deprecation).to receive(:warn) }+it 'reads the boolean back as the old tri-state value' doexpect(visible_method.display_on).to eq('both')+ expect(Spree::Deprecation).to have_received(:warn).with(/display_on is deprecated/)expect(admin_only_method.display_on).to eq('back_end')end@@ -245,18 +244,6 @@ describe Spree::PaymentMethod, type: :model doexpect(Spree::PaymentMethod.where(capture_method: 'on_dispatch')).to be_presentend-- # The migration leaves auto_capture-false rows empty on purpose so they- # keep inheriting. Reading them as manual here would take them out of- # dispatch capture while the goods still went out.- context 'when a legacy row was left for the store to decide' do- it 'inherits the store setting rather than charging manually' do- gateway.auto_capture = false-- expect(gateway.resolved_capture_method).to eq('on_dispatch')- expect(gateway).to be_capture_on_dispatch- end- endenddescribe '#available_for_order?' do@@ -302,28 +289,6 @@ describe Spree::PaymentMethod, type: :model doendend- describe '#source_required?' do- let(:payment_method) { create(:credit_card_payment_method) }-- it { expect(payment_method.source_required?).to be true }- end-- describe '#session_required?' do- it 'returns false by default' do- expect(build(:payment_method).session_required?).to be false- end- end-- describe '#payment_source_class' do- let(:payment_method) { build(:credit_card_payment_method) }-- it { expect(payment_method.payment_source_class).to eq(Spree::CreditCard) }- end-- describe '#payment_icon_name' do- it { expect(build(:credit_card_payment_method, type: 'Spree::Gateway::AuthorizeNetGateway').payment_icon_name).to eq('authorizenet') }- end-context 'when payment method is destroyed' dolet(:payment_method) { create(:credit_card_payment_method) }let!(:payment) { create(:payment, payment_method: payment_method, source: credit_card) }@@ -383,7 +348,7 @@ describe Spree::PaymentMethod, type: :model doClass.new(Spree::Gateway) dodef self.name = 'TestConstrainedGateway'- preference :mode, :string, default: 'live', in: %w[test live]+ preference :mode, :string, default: 'live', choices: %w[test live]preference :label, :stringpreference :threshold, :decimal, default: 0end@@ -455,13 +420,6 @@ describe Spree::PaymentMethod, type: :model doexpect(keys).not_to include(:issued_secret)end- it 'still stores and reads one, since the system depends on the value' do- gateway = gateway_class.new- gateway.preferred_issued_secret = 'whsec_abc'-- expect(gateway.preferred_issued_secret).to eq('whsec_abc')- end-it 'reports which preferences are internal' dogateway = gateway_class.newdiff --git a/spree/core/spec/models/spree/payment_response_spec.rb b/spree/core/spec/models/spree/payment_response_spec.rbindex eb5c0186bd..2169b9f97f 100644--- a/spree/core/spec/models/spree/payment_response_spec.rb+++ b/spree/core/spec/models/spree/payment_response_spec.rb@@ -52,26 +52,6 @@ RSpec.describe Spree::PaymentResponse doendend- describe '#success?' do- it 'returns true for a successful response' do- expect(described_class.new(true, 'ok')).to be_success- end-- it 'returns false for a failed response' do- expect(described_class.new(false, 'fail')).not_to be_success- end- end-- describe '#test?' do- it 'returns true when test option is set' do- expect(described_class.new(true, '', {}, test: true)).to be_test- end-- it 'returns false by default' do- expect(described_class.new(true, '')).not_to be_test- end- end-describe 'YAML serialization' doit 'round-trips through YAML.safe_load' dooriginal = described_class.new(true, 'Captured', { 'ref' => '42' },diff --git a/spree/core/spec/models/spree/payment_session_spec.rb b/spree/core/spec/models/spree/payment_session_spec.rbindex a203fcd3f3..6466c6cfc8 100644--- a/spree/core/spec/models/spree/payment_session_spec.rb+++ b/spree/core/spec/models/spree/payment_session_spec.rb@@ -8,43 +8,6 @@ RSpec.describe Spree::PaymentSession, type: :model dolet(:payment_method) { create(:bogus_payment_method) }let(:payment_session) { create(:bogus_payment_session, order: order, payment_method: payment_method, amount: 50) }- describe 'validations' do- it { expect(payment_session).to be_valid }-- it 'requires order' do- payment_session.order = nil- expect(payment_session).not_to be_valid- end-- it 'requires payment_method' do- payment_session.payment_method = nil- expect(payment_session).not_to be_valid- end-- it 'requires external_id' do- payment_session.external_id = nil- expect(payment_session).not_to be_valid- end-- it 'requires currency' do- payment_session.currency = nil- expect(payment_session).not_to be_valid- end-- it 'requires amount greater than 0' do- payment_session.amount = 0- expect(payment_session).not_to be_valid- end-- it 'enforces external_id uniqueness per order and payment method' do- duplicate = build(:bogus_payment_session,- order: payment_session.order,- payment_method: payment_session.payment_method,- external_id: payment_session.external_id)- expect(duplicate).not_to be_valid- end- end-describe 'defaults from order' doit 'sets currency from order' dosession = build(:bogus_payment_session, order: order, payment_method: payment_method,@@ -232,20 +195,6 @@ RSpec.describe Spree::PaymentSession, type: :model doendend- describe '#prefixed_id' do- it 'starts with ps_' do- expect(payment_session.prefixed_id).to start_with('ps_')- end- end-- describe 'soft delete' do- it 'soft deletes with acts_as_paranoid' do- payment_session.destroy- expect(described_class.with_deleted.find(payment_session.id)).to be_present- expect(described_class.find_by(id: payment_session.id)).to be_nil- end- end-describe 'events' dobefore doallow(Spree::Events).to receive(:enabled?).and_return(true)@@ -334,18 +283,20 @@ RSpec.describe Spree::PaymentSession, type: :model doexpect(payment_session.find_or_create_payment!.id).to eq(payment_session.payment.id)end- it 'handles RecordNotUnique by returning the existing payment' do- existing = create(:payment,- order: order,- payment_method: payment_method,- response_code: payment_session.external_id,- amount: payment_session.amount)-- # Simulate a race condition where find_or_create_by! raises RecordNotUnique- allow(order.payments).to receive(:find_or_create_by!).and_raise(ActiveRecord::RecordNotUnique)+ it 'handles RecordNotUnique by returning the payment a concurrent request created' do+ existing = nil+ allow(payment_session.owner.payments).to receive(:find_or_create_by!) do+ existing = create(:payment,+ order: order,+ payment_method: payment_method,+ response_code: payment_session.external_id,+ amount: payment_session.amount)+ raise ActiveRecord::RecordNotUnique+ endpayment = payment_session.find_or_create_payment!+ expect(payment_session.owner.payments).to have_received(:find_or_create_by!)expect(payment.id).to eq(existing.id)endenddiff --git a/spree/core/spec/models/spree/payment_setup_session_spec.rb b/spree/core/spec/models/spree/payment_setup_session_spec.rbindex dd84927da9..f18fe1cd65 100644--- a/spree/core/spec/models/spree/payment_setup_session_spec.rb+++ b/spree/core/spec/models/spree/payment_setup_session_spec.rb@@ -9,13 +9,6 @@ RSpec.describe Spree::PaymentSetupSession, type: :model dolet(:payment_setup_session) { create(:payment_setup_session, customer: user, payment_method: payment_method) }describe 'validations' do- it { expect(payment_setup_session).to be_valid }-- it 'requires payment_method' do- payment_setup_session.payment_method = nil- expect(payment_setup_session).not_to be_valid- end-it 'enforces unique external_id per payment_method' dopayment_setup_session.update!(external_id: 'seti_123')duplicate = build(:payment_setup_session, payment_method: payment_method, external_id: 'seti_123')@@ -37,23 +30,6 @@ RSpec.describe Spree::PaymentSetupSession, type: :model doendend- describe 'associations' do- it 'belongs to customer' do- expect(payment_setup_session.customer).to eq(user)- end-- it 'belongs to payment_method' do- expect(payment_setup_session.payment_method).to eq(payment_method)- end-- it 'can have a payment_source (CreditCard)' do- credit_card = create(:credit_card, customer: user)- payment_setup_session.update!(payment_source: credit_card)- expect(payment_setup_session.payment_source).to eq(credit_card)- expect(payment_setup_session.payment_source_type).to eq('Spree::CreditCard')- end- end-describe 'state machine' dodescribe '#process' doit 'transitions from pending to processing' do@@ -138,38 +114,12 @@ RSpec.describe Spree::PaymentSetupSession, type: :model doendend- describe '#prefixed_id' do- it 'starts with pss_' do- expect(payment_setup_session.prefixed_id).to start_with('pss_')- end- end-- describe 'soft delete' do- it 'soft deletes with acts_as_paranoid' do- payment_setup_session.destroy- expect(described_class.with_deleted.find(payment_setup_session.id)).to be_present- expect(described_class.find_by(id: payment_setup_session.id)).to be_nil- end- end-describe 'events' dobefore doallow(Spree::Events).to receive(:enabled?).and_return(true)allow(Spree::Events).to receive(:publish)end- describe 'lifecycle events' do- it 'publishes payment_setup_session.created on create' do- create(:payment_setup_session, customer: user, payment_method: payment_method)- expect(Spree::Events).to have_received(:publish).with('payment_setup_session.created', anything, anything)- end-- it 'publishes payment_setup_session.updated on update' do- payment_setup_session.update!(external_id: 'new_id')- expect(Spree::Events).to have_received(:publish).with('payment_setup_session.updated', anything, anything)- end- end-describe 'state transition events' doit 'publishes payment_setup_session.processing on process' dopayment_setup_session.processdiff --git a/spree/core/spec/models/spree/payment_spec.rb b/spree/core/spec/models/spree/payment_spec.rbindex d55a474c8e..4262d27a76 100644--- a/spree/core/spec/models/spree/payment_spec.rb+++ b/spree/core/spec/models/spree/payment_spec.rb@@ -45,10 +45,6 @@ describe Spree::Payment, type: :model doit_behaves_like 'metadata'- describe 'Constants' do- it { expect(Spree::Payment::INVALID_STATES).to eq(%w(failed invalid void)) }- end-describe 'Scopes' dodescribe '.valid' dosubject { Spree::Payment.valid }@@ -278,28 +274,14 @@ describe Spree::Payment, type: :model doendcontext 'processing' do+ before { allow(Spree::Deprecation).to receive(:warn) }+describe '#process!' doit 'purchases when the method charges at checkout' dopayment.payment_method.capture_method = 'checkout'payment.process!expect(payment).to be_completed- end-- it 'authorizes when the method charges later' do- payment.payment_method.capture_method = 'on_dispatch'- payment.process!- expect(payment).to be_pending- end-- it "makes the state 'processing'" do- expect(payment).to receive(:started_processing!)- payment.process!- end-- it 'invalidates if payment method doesnt support source' do- expect(payment.payment_method).to receive(:supports?).with(payment.source).and_return(false)- expect { payment.process! }.to raise_error(Spree::Core::GatewayError)- expect(payment.status).to eq('invalid')+ expect(Spree::Deprecation).to have_received(:warn).with(/Payment#process! is deprecated/)end# Regression test for #4598@@ -325,6 +307,7 @@ describe Spree::Payment, type: :model docard,anything).and_return(success_response)payment.authorize!+ expect(Spree::Deprecation).to have_received(:warn).with(/Payment#authorize! is deprecated/)endit 'calls authorize on the gateway with the currency code' do@@ -349,11 +332,6 @@ describe Spree::Payment, type: :model doexpect(payment.cvv_response_code).to eq(cvv_code)expect(payment.cvv_response_message).to be_nilend-- it 'makes payment pending' do- expect(payment).to receive(:pend!)- payment.authorize!- endendcontext 'if unsuccessful' do@@ -375,7 +353,7 @@ describe Spree::Payment, type: :model doit 'raises Spree::Core::GatewayError and marks payment as failed' doexpect(payment).to receive(:failure!)- expect(payment).not_to receive(:pend)+ expect(payment).not_to receive(:pend!)expect { payment.authorize! }.to raise_error(Spree::Core::GatewayError)endend@@ -397,7 +375,9 @@ describe Spree::Payment, type: :model doit 'instruments the purchase gateway call as gateway.spree_payments' doallow(gateway).to receive(:purchase).and_return(success_response)- notifications = capture_gateway_notifications { payment.purchase! }+ notifications = capture_gateway_notifications do+ Spree.payment_process_workflow.call(payment: payment, action: :purchase)+ endexpect(notifications.sole).to include(action: 'purchase', payment_method_type: 'Spree::Gateway::Bogus')end@@ -407,7 +387,7 @@ describe Spree::Payment, type: :model dopayment.response_code = "BGS-#{SecureRandom.hex(6)}"allow(gateway).to receive(:capture).and_return(success_response)- notifications = capture_gateway_notifications { payment.capture! }+ notifications = capture_gateway_notifications { Spree.payment_capture_workflow.call(payment: payment) }expect(notifications.sole).to include(action: 'capture', payment_method_type: 'Spree::Gateway::Bogus')end@@ -417,6 +397,7 @@ describe Spree::Payment, type: :model doit 'calls purchase on the gateway with the payment amount' doexpect(gateway).to receive(:purchase).with(gateway_amount, card, anything).and_return(success_response)payment.purchase!+ expect(Spree::Deprecation).to have_received(:warn).with(/Payment#purchase! is deprecated/)endcontext 'if successful' do@@ -431,22 +412,6 @@ describe Spree::Payment, type: :model doexpect(payment.response_code).to eq('123')expect(payment.avs_response).to eq(avs_code)end-- it 'makes payment complete' do- expect(payment).to receive(:complete!)- payment.purchase!- end-- it 'logs a capture event' do- payment.purchase!- expect(payment.capture_events.count).to eq(1)- expect(payment.capture_events.first.amount).to eq(payment.amount)- end-- it 'sets the uncaptured amount to 0' do- payment.purchase!- expect(payment.uncaptured_amount).to eq(0)- endendcontext 'if unsuccessful' do@@ -474,7 +439,7 @@ describe Spree::Payment, type: :model doit 'raises Spree::Core::GatewayError and marks payment as failed' doexpect(payment).to receive(:failure!)- expect(payment).not_to receive(:pend)+ expect(payment).not_to receive(:pend!)expect { payment.purchase! }.to raise_error(Spree::Core::GatewayError)endend@@ -606,28 +571,12 @@ describe Spree::Payment, type: :model doendcontext 'if successful' do- context 'for entire amount' do- before do- expect(payment.payment_method).to receive(:capture).with(gateway_amount, payment.response_code, anything).and_return(success_response)- end-- it 'makes payment complete' do- expect(payment).to receive(:complete!)- payment.capture!- end-- it 'logs capture events' do- payment.capture!- expect(payment.capture_events.count).to eq(1)- expect(payment.capture_events.first.amount).to eq(payment.amount)- end- end-it 'records the capture under the owner row lock' doexpect(payment.payment_method).to receive(:capture).and_return(success_response)expect(payment.owner).to receive(:with_lock).and_call_originalpayment.capture!+ expect(Spree::Deprecation).to have_received(:warn).with(/Payment#capture! is deprecated/)endit 'records nothing when another caller already completed the payment' do@@ -661,25 +610,10 @@ describe Spree::Payment, type: :model doexpect(payments.processing.first.amount).to eq(capture_amount)expect(payments.processing.first.source).to eq(payments.pending.first.source)end-- it 'logs capture events' do- payment.capture!(capture_amount)- expect(payment.capture_events.count).to eq(1)- expect(payment.capture_events.first.amount).to eq(capture_amount)- endendendcontext 'if unsuccessful' do- context 'when response is returned from gateway' do- it 'does not make payment complete' do- allow(gateway).to receive_messages capture: failed_response- expect { payment.capture! }.to raise_error(Spree::Core::GatewayError)- expect(payment.reload).to be_failed- expect(payment).not_to be_completed- end- end-context 'when there is an error connecting to the gateway' dolet(:connection_error_message) { 'gateway_error' }let(:connection_error) { Spree::PaymentConnectionError.new(connection_error_message) }@@ -688,24 +622,12 @@ describe Spree::Payment, type: :model doit 'raises Spree::Core::GatewayError and marks payment as failed' doexpect(payment).to receive(:failure!)- expect(payment).not_to receive(:pend)+ expect(payment).not_to receive(:pend!)expect { payment.capture! }.to raise_error(Spree::Core::GatewayError)endendendend-- # Regression test for #2119- context 'when payment is completed' do- before do- payment.status = 'completed'- end-- it 'does nothing' do- expect(payment.payment_method).not_to receive(:capture)- payment.capture!- end- endenddescribe '#void_transaction!' do@@ -714,40 +636,17 @@ describe Spree::Payment, type: :model dopayment.status = 'pending'end- context 'when profiles are supported' do- it "calls payment_gateway.void with the payment's response_code" do- allow(gateway).to receive_messages payment_profiles_supported?: true- expect(gateway).to receive(:void).with('123', card, anything).and_return(success_response)- payment.void_transaction!- end- end-- context 'when profiles are not supported' do- it "calls payment_gateway.void with the payment's response_code" do- allow(gateway).to receive_messages payment_profiles_supported?: false- expect(gateway).to receive(:void).with('123', anything).and_return(success_response)- payment.void_transaction!- end- end-context 'if successful' doit 'updates the response_code with the authorization from the gateway' do# Change it to something differentpayment.response_code = 'abc'payment.void_transaction!expect(payment.response_code).to start_with('void-BGS-')+ expect(Spree::Deprecation).to have_received(:warn).with(/Payment#void_transaction! is deprecated/)endendcontext 'if unsuccessful' do- context 'when response is returned from gateway' do- it 'does not void the payment' do- allow(gateway).to receive_messages void: failed_response- expect { payment.void_transaction! }.to raise_error(Spree::Core::GatewayError)- expect(payment).not_to be_void- end- end-context 'when there is an error connecting to the gateway' dolet(:connection_error_message) { 'gateway_error' }let(:connection_error) { Spree::PaymentConnectionError.new(connection_error_message) }@@ -756,60 +655,17 @@ describe Spree::Payment, type: :model doit 'raises Spree::Core::GatewayError and marks payment as failed' doexpect(payment).to receive(:failure!)- expect(payment).not_to receive(:pend)+ expect(payment).not_to receive(:pend!)expect { payment.void_transaction! }.to raise_error(Spree::Core::GatewayError)endendend-- # Regression test for #2119- context 'if payment is already voided' do- before do- payment.status = 'void'- end-- it 'does not void the payment' do- expect(payment.payment_method).not_to receive(:void)- payment.void_transaction!- end- end-- context 'if response_code is blank' do- before do- payment.response_code = nil- payment.status = 'pending'- end-- it 'voids the payment without calling the gateway' do- expect(payment.payment_method).not_to receive(:void)- payment.void_transaction!- expect(payment.status).to eq('void')- end- end- end- end-- context 'when already processing' do- it 'is a no-op success without trying to process the source' do- payment.status = 'processing'-- expect(payment.process!).to be(true)- end- end-- context 'with source required' do- context 'raises an error if no source is specified' do- before do- payment.source = nil- end-- specify do- expect { payment.process! }.to raise_error(Spree::Core::GatewayError, I18n.t('spree.payment_processing_failed'))- endendendcontext 'with source optional' do+ before { allow(Spree::Deprecation).to receive(:warn) }+context 'when payment method does not require source' dolet(:check_payment_method) { create(:check_payment_method, store: order.store, capture_method: 'manual') }@@ -845,18 +701,6 @@ describe Spree::Payment, type: :model doendend- describe '#can_credit?' do- it 'is true if credit_allowed > 0' do- allow(payment).to receive(:credit_allowed).and_return(100)- expect(payment.can_credit?).to be true- end-- it 'is false if credit_allowed is 0' do- allow(payment).to receive(:credit_allowed).and_return(0)- expect(payment.can_credit?).to be false- end- end-describe '#save' docontext 'captured payments', events: true doit 'update order payment total' do@@ -871,11 +715,6 @@ describe Spree::Payment, type: :model doSpree::Payment.create(amount: 100, order: order)end.not_to change(order, :payment_total)end-- it 'requires a payment method' do- expect(Spree::Payment.create(amount: 100, order: order).errors).not_to be_empty- expect(Spree::Payment.create(amount: 100, order: order).errors.messages[:payment_method]).to be_present- endendcontext 'when the payment was completed but now void' do@@ -1027,20 +866,6 @@ describe Spree::Payment, type: :model doendend- describe '#currency' do- before { allow(order).to receive(:currency).and_return('ABC') }-- it 'returns the order currency' do- expect(payment.currency).to eq('ABC')- end- end-- describe '#display_amount' do- it 'returns a Spree::Money for this amount' do- expect(payment.display_amount).to eq(Spree::Money.new(payment.amount))- end- end-# Regression test for #2216describe '#gateway_options' dobefore { allow(order).to receive_messages(last_ip_address: '192.168.1.1') }@@ -1202,11 +1027,6 @@ describe Spree::Payment, type: :model dolet(:card) { create(:credit_card) }let(:payment_method) { card.payment_method }- before do- allow(payment_method).to receive_messages source_required: true- end-- it { expect(payment_method.source_required?).to eq(true) }it { expect(payment.source).to eq(card) }context 'when credit card is removed' do@@ -1318,20 +1138,25 @@ describe Spree::Payment, type: :model doendend- describe '#has_invalid_state?' do- let(:payment) { create(:payment, status: state) }- subject(:has_invalid_state?) { payment.has_invalid_state? }+ describe '#has_invalid_status?' do+ let(:payment) { create(:payment, status: status) }+ subject(:has_invalid_status?) { payment.has_invalid_status? }- context 'when the state is invalid' do- let(:state) { Spree::Payment::INVALID_STATES.first }+ context 'when the status is invalid' do+ let(:status) { Spree::Payment::INVALID_STATUSES.first }it { is_expected.to be_truthy }end- context 'when the state is valid' do- let(:state) { 'completed' }+ context 'when the status is valid' do+ let(:status) { 'completed' }it { is_expected.to be_falsey }++ it 'is still answered by the deprecated has_invalid_state? alias' do+ expect(Spree::Deprecation).to receive(:warn).with(/has_invalid_state\? is deprecated/)+ expect(payment.has_invalid_state?).to be_falsey+ endendenddiff --git a/spree/core/spec/models/spree/payment_split_spec.rb b/spree/core/spec/models/spree/payment_split_spec.rbindex 299e8ca8c4..c3792b5bd2 100644--- a/spree/core/spec/models/spree/payment_split_spec.rb+++ b/spree/core/spec/models/spree/payment_split_spec.rb@@ -31,15 +31,4 @@ RSpec.describe Spree::PaymentSplit, type: :model doexpect(split.net_captured_amount).to eq(15)endend-- # Whose sale a share belongs to is asked through its order — the split- # itself stays neutral, since the same container serves splits that have no- # seller at all.- it 'reaches its seller through the order it settles' do- seller = create(:seller, :approved, store: store)- seller_order = create(:order, store: store, order_group: group, seller: seller)- split = create(:payment_split, payment: payment, order: seller_order)-- expect(split.order.seller).to eq(seller)- endenddiff --git a/spree/core/spec/models/spree/policy_spec.rb b/spree/core/spec/models/spree/policy_spec.rbindex de5469ab89..0ecd34ed20 100644--- a/spree/core/spec/models/spree/policy_spec.rb+++ b/spree/core/spec/models/spree/policy_spec.rb@@ -14,13 +14,6 @@ RSpec.describe Spree::Policy, type: :model doexpect(other_policy.slug).to eq(policy.slug)endend-- context 'owner presence' do- it 'is invalid without an owner' do- policy.owner = nil- expect(policy).to be_invalid- end- endenddescribe 'friendly_id' do@@ -30,11 +23,12 @@ RSpec.describe Spree::Policy, type: :model doendit 'maintains slug history' do- policy = create(:policy, slug: 'old-slug')+ policy = create(:policy)+ old_slug = policy.slugpolicy.update(slug: 'new-slug')expect(policy.to_param).to eq('new-slug')- expect(policy.friendly_id_config.uses?(:history)).to be true+ expect(described_class.where(owner: policy.owner).friendly.find(old_slug)).to eq(policy)endcontext 'when the policy is destroyed' do@@ -50,10 +44,6 @@ RSpec.describe Spree::Policy, type: :model doenddescribe 'Translations' do- it 'has translatable name field' do- expect(described_class::TRANSLATABLE_FIELDS).to include(:name)- end-it 'supports translations for name' dopolicy = create(:policy, name: 'Privacy Policy')diff --git a/spree/core/spec/models/spree/preferences/configuration_spec.rb b/spree/core/spec/models/spree/preferences/configuration_spec.rbdeleted file mode 100644index 10ed8ff9d5..0000000000--- a/spree/core/spec/models/spree/preferences/configuration_spec.rb+++ /dev/null@@ -1,25 +0,0 @@-require 'spec_helper'--describe Spree::Preferences::Configuration, type: :model do- before :all do- class AppConfig < Spree::Preferences::Configuration- preference :color, :string, default: :blue- end- @config = AppConfig.new- end-- it 'has named methods to access preferences' do- @config.color = 'orange'- expect(@config.color).to eq 'orange'- end-- it 'uses [ ] to access preferences' do- @config[:color] = 'red'- expect(@config[:color]).to eq 'red'- end-- it 'uses set/get to access preferences' do- @config.set :color, 'green'- expect(@config.get(:color)).to eq 'green'- end-enddiff --git a/spree/core/spec/models/spree/preferences/preferable_spec.rb b/spree/core/spec/models/spree/preferences/preferable_spec.rbindex 3254cd61fe..147b890245 100644--- a/spree/core/spec/models/spree/preferences/preferable_spec.rb+++ b/spree/core/spec/models/spree/preferences/preferable_spec.rb@@ -43,11 +43,6 @@ describe Spree::Preferences::Preferable, type: :model doexpect(@b.preferred_flavor).to be_nilend- it 'can be asked if it has a preference definition' do- expect(@a.has_preference?(:color)).to be true- expect(@a.has_preference?(:bad)).to be false- end-it 'can be asked and raises' doexpect do@a.has_preference! :flavor@@ -75,11 +70,18 @@ describe Spree::Preferences::Preferable, type: :model dodescribe 'preference access' doit 'handles ghost methods for preferences' do+ @b.preferred_flavor = 'mint'+ expect(@b.preferred_flavor).to eq 'mint'+ end++ it 'warns when a deprecated preference is written' do+ expect(Spree::Deprecation).to receive(:warn).with(/`color` is deprecated. Please use colour instead/)@a.preferred_color = 'blue'expect(@a.preferred_color).to eq 'blue'endit 'parent and child instances have their own prefs' do+ allow(Spree::Deprecation).to receive(:warn)@a.preferred_color = 'red'@b.preferred_color = 'blue'@@ -279,7 +281,7 @@ describe Spree::Preferences::Preferable, type: :model docontext 'converts array preferences to array values' dobefore do- A.preference :is_array, :array, default: []+ Spree::Deprecation.silence { A.preference :is_array, :array, default: [] }endit 'with arrays' do@@ -300,7 +302,7 @@ describe Spree::Preferences::Preferable, type: :model docontext 'converts hash preferences to hash values' dobefore do- A.preference :is_hash, :hash, default: {}+ Spree::Deprecation.silence { A.preference :is_hash, :hash, default: {} }endit 'with hash' do@@ -391,8 +393,10 @@ describe Spree::Preferences::Preferable, type: :model docontext 'converts any preferences to any values' dobefore do- A.preference :product_ids, :any, default: []- A.preference :product_attributes, :any, default: {}+ Spree::Deprecation.silence do+ A.preference :product_ids, :any, default: []+ A.preference :product_attributes, :any, default: {}+ end@a = A.newend@@ -583,7 +587,7 @@ describe Spree::Preferences::Preferable, type: :model doclass PrefTest < Spree::Basepreference :pref_test_pref, :string, default: 'abc'- preference :pref_test_any, :any, default: []+ Spree::Deprecation.silence { preference :pref_test_any, :any, default: [] }preference :pref_test_decimal, :decimal, default: 0preference :pref_test_datetime, :datetimeend@@ -618,17 +622,6 @@ describe Spree::Preferences::Preferable, type: :model doendend- it 'clear preferences when record is deleted' do- @pt.save!- @pt.preferred_pref_test_pref = 'lmn'- @pt.save!- @pt.destroy- @pt1 = PrefTest.new(col: 'aaaa')- @pt1.id = @pt.id- @pt1.save!- expect(@pt1.get_preference(:pref_test_pref)).to eq('abc')- end-describe 'JSON storage' doit 'restores a decimal exactly after a round trip' do@pt.update!(preferred_pref_test_decimal: '19.99')diff --git a/spree/core/spec/models/spree/price_list_spec.rb b/spree/core/spec/models/spree/price_list_spec.rbindex fd843f178b..97d919b6ae 100644--- a/spree/core/spec/models/spree/price_list_spec.rb+++ b/spree/core/spec/models/spree/price_list_spec.rb@@ -280,48 +280,9 @@ describe Spree::PriceList, type: :model doendend- describe 'status' do- let(:price_list) { create(:price_list) }-- it 'has no state machine' do- expect(described_class).not_to respond_to(:state_machines)- end-- it 'has initial status of draft' do- expect(price_list.status).to eq('draft')- end-- it 'rejects an unknown status' do- expect(build(:price_list, status: 'nonsense')).not_to be_valid- end- end-describe 'scopes' dolet(:store) { @default_store }let!(:active_price_list) { create(:price_list, :active, store: store) }- let!(:inactive_price_list) { create(:price_list, :inactive, store: store) }- let!(:scheduled_price_list) { create(:price_list, :scheduled, store: store) }-- describe '.with_status(:active)' do- it 'returns only active price lists' do- expect(described_class.with_status(:active)).to include(active_price_list)- expect(described_class.with_status(:active)).not_to include(inactive_price_list)- end- end-- describe '.with_status(:inactive)' do- it 'returns only inactive price lists' do- expect(described_class.with_status(:inactive)).to include(inactive_price_list)- expect(described_class.with_status(:inactive)).not_to include(active_price_list)- end- end-- describe '.with_status(:scheduled)' do- it 'returns only scheduled price lists' do- expect(described_class.with_status(:scheduled)).to include(scheduled_price_list)- expect(described_class.with_status(:scheduled)).not_to include(active_price_list)- end- enddescribe '.by_position' dolet!(:first_list) { create(:price_list, store: store, position: 1) }@@ -416,18 +377,6 @@ describe Spree::PriceList, type: :model doendend- describe '#active?' do- it 'returns true when status is active' do- price_list = create(:price_list, :active)- expect(price_list.active?).to be true- end-- it 'returns false when status is not active' do- price_list = create(:price_list, :inactive)- expect(price_list.active?).to be false- end- end-describe '#add_products' dolet(:store) { create(:store, supported_currencies: 'USD,EUR,GBP') }let(:price_list) { create(:price_list, store: store) }@@ -518,12 +467,6 @@ describe Spree::PriceList, type: :model doprice = price_list.prices.find_by(variant_id: product1.default_variant.id, currency: 'USD')expect(price.amount).to eq(49.99)end-- it 'only creates prices for missing currencies' do- expect {- price_list.add_products([product1.id])- }.to change { price_list.prices.count }.by(2) # Only EUR and GBP- endendcontext 'with deleted variants' do@@ -561,12 +504,6 @@ describe Spree::PriceList, type: :model do}.to change { price_list.prices.count }.by(-3) # 1 product * 3 currenciesend- it 'removes prices for all currencies' do- price_list.remove_products([product1.id])-- expect(price_list.prices.joins(:variant).where(spree_variants: { product_id: product1.id }).count).to eq(0)- end-it 'does not remove prices for other products' doprice_list.remove_products([product1.id])@@ -606,17 +543,6 @@ describe Spree::PriceList, type: :model doendcontext 'when re-adding a previously removed product' do- it 'allows re-adding a product with empty prices' do- # Add product, then remove it- price_list.add_products([product1.id])- price_list.remove_products([product1.id])-- # Re-add the same product - this should not raise a unique constraint error- expect {- price_list.add_products([product1.id])- }.to change { price_list.prices.count }.by(3) # 1 product * 3 currencies- end-it 'allows re-adding a product that had prices with amounts set' do# Add product and set some pricesprice_list.add_products([product1.id])diff --git a/spree/core/spec/models/spree/price_rules/channel_rule_spec.rb b/spree/core/spec/models/spree/price_rules/channel_rule_spec.rbindex adc4d4353b..0d72273c31 100644--- a/spree/core/spec/models/spree/price_rules/channel_rule_spec.rb+++ b/spree/core/spec/models/spree/price_rules/channel_rule_spec.rb@@ -52,21 +52,6 @@ describe Spree::PriceRules::ChannelRule, type: :model doenddescribe '#preferred_channel_ids=' do- it 'decodes prefixed channel IDs to raw IDs' do- rule.preferred_channel_ids = [channel.prefixed_id]- expect(rule.preferred_channel_ids).to eq([channel.id.to_s])- end-- it 'accepts a comma-separated string' do- other_channel = create(:channel, store: price_list.store)- rule.preferred_channel_ids = "#{channel.prefixed_id},#{other_channel.prefixed_id}"- expect(rule.preferred_channel_ids).to contain_exactly(channel.id.to_s, other_channel.id.to_s)- end-- it 'raises when given an unknown prefixed ID' do- expect { rule.preferred_channel_ids = ['ch_doesnotexist'] }.to raise_error(ActiveRecord::RecordNotFound)- end-it 'rejects a channel that belongs to another store' doother_store = create(:store)cross_store_channel = create(:channel, store: other_store)diff --git a/spree/core/spec/models/spree/price_rules/market_rule_spec.rb b/spree/core/spec/models/spree/price_rules/market_rule_spec.rbindex a01017586a..4b4a30f16f 100644--- a/spree/core/spec/models/spree/price_rules/market_rule_spec.rb+++ b/spree/core/spec/models/spree/price_rules/market_rule_spec.rb@@ -41,45 +41,9 @@ describe Spree::PriceRules::MarketRule, type: :model doexpect(rule.applicable?(context)).to be falseendend-- context 'when market_ids preference contains strings' do- before { rule.preferred_market_ids = [market.id.to_s] }-- it 'returns true when context market matches' do- context = Spree::Pricing::Context.new(variant: variant, currency: 'USD', market: market)- expect(rule.applicable?(context)).to be true- end-- it 'returns false when context market does not match' do- other_market = create(:market, store: price_list.store)- context = Spree::Pricing::Context.new(variant: variant, currency: 'USD', market: other_market)- expect(rule.applicable?(context)).to be false- end- endenddescribe '#preferred_market_ids=' do- it 'decodes prefixed market IDs to raw IDs' do- rule.preferred_market_ids = [market.prefixed_id]- expect(rule.preferred_market_ids).to eq([market.id.to_s])- end-- it 'accepts a mix of prefixed and raw IDs' do- other_market = create(:market, store: price_list.store)- rule.preferred_market_ids = [market.prefixed_id, other_market.id.to_s]- expect(rule.preferred_market_ids).to contain_exactly(market.id.to_s, other_market.id.to_s)- end-- it 'accepts a comma-separated string' do- other_market = create(:market, store: price_list.store)- rule.preferred_market_ids = "#{market.prefixed_id},#{other_market.prefixed_id}"- expect(rule.preferred_market_ids).to contain_exactly(market.id.to_s, other_market.id.to_s)- end-- it 'raises when given an unknown prefixed ID' do- expect { rule.preferred_market_ids = ['mkt_doesnotexist'] }.to raise_error(ActiveRecord::RecordNotFound)- end-it 'rejects a market that belongs to another store' doother_store = create(:store)cross_store_market = create(:market, store: other_store)diff --git a/spree/core/spec/models/spree/price_rules/volume_rule_spec.rb b/spree/core/spec/models/spree/price_rules/volume_rule_spec.rbindex 64a5e9b746..e15f6a4f4f 100644--- a/spree/core/spec/models/spree/price_rules/volume_rule_spec.rb+++ b/spree/core/spec/models/spree/price_rules/volume_rule_spec.rb@@ -11,18 +11,6 @@ describe Spree::PriceRules::VolumeRule, type: :model dorule.save!expect(rule.reload.preferred_max_quantity).to be_nilend-- it 'preserves non-zero max_quantity' do- rule.preferred_max_quantity = 50- rule.save!- expect(rule.reload.preferred_max_quantity).to eq(50)- end-- it 'preserves nil max_quantity' do- rule.preferred_max_quantity = nil- rule.save!- expect(rule.reload.preferred_max_quantity).to be_nil- endenddescribe '#applicable?' dodiff --git a/spree/core/spec/models/spree/price_spec.rb b/spree/core/spec/models/spree/price_spec.rbindex b56dea58c3..659e3d354b 100644--- a/spree/core/spec/models/spree/price_spec.rb+++ b/spree/core/spec/models/spree/price_spec.rb@@ -159,36 +159,6 @@ describe Spree::Price, type: :model doendend- describe '#price' do- let(:price) { build :price }- let(:amount) { 3000.00 }-- context 'when amount is changed' do- before do- price.amount = amount- end-- it 'is expected to equal to price' do- expect(price.amount).to eq(price.price)- end- end- end-- describe '#compare_at_price' do- let(:price) { build :price }- let(:compare_at_amount) { 3000.00 }-- context 'when amount is changed' do- before do- price.compare_at_amount = compare_at_amount- end-- it 'is expected to equal to price' do- expect(price.compare_at_amount).to eq(price.compare_at_price)- end- end- end-describe 'validations' dosubject { build :price, variant: variant, amount: amount }@@ -214,11 +184,8 @@ describe Spree::Price, type: :model dolet(:amount) { -1 }before { subject.valid? }- it 'has 1 error on amount' do- expect(subject.errors.messages[:amount].size).to eq(1)- endit 'populates errors' do- expect(subject.errors.messages[:amount].first).to eq 'must be greater than or equal to 0'+ expect(subject.errors.messages[:amount]).to eq ['must be greater than or equal to 0']endend@@ -226,11 +193,8 @@ describe Spree::Price, type: :model dolet(:amount) { Spree::Price::MAXIMUM_AMOUNT + 1 }before { subject.valid? }- it 'has 1 error on amount' do- expect(subject.errors.messages[:amount].size).to eq(1)- endit 'populates errors' do- expect(subject.errors.messages[:amount].first).to eq "must be less than or equal to #{Spree::Price::MAXIMUM_AMOUNT}"+ expect(subject.errors.messages[:amount]).to eq ["must be less than or equal to #{Spree::Price::MAXIMUM_AMOUNT}"]endend@@ -245,10 +209,6 @@ describe Spree::Price, type: :model dolet(:amount) { 10 }let(:price_list) { create(:price_list) }- it 'defaults to the ladder\'s bottom rung' do- expect(described_class.new.min_quantity).to eq(1)- end-it 'refuses a quantity below one' dosubject.min_quantity = 0@@ -415,24 +375,6 @@ describe Spree::Price, type: :model doendend- describe '#display_price_including_vat_for(zone)' do- subject { build :price, amount: 10 }-- it 'calls #price_including_vat_for' do- expect(subject).to receive(:price_including_vat_for)- subject.display_price_including_vat_for(nil)- end- end-- describe '#display_compare_at_price_including_vat_for(zone)' do- subject { build :price, amount: 10, compare_at_amount: 100 }-- it 'calls #price_including_vat_for' do- expect(subject).to receive(:compare_at_price_including_vat_for)- subject.display_compare_at_price_including_vat_for(nil)- end- end-describe '#display_compare_at_amount' dolet(:price) { build(:price, amount: 10, compare_at_amount: compare_at_amount, currency: 'USD') }diff --git a/spree/core/spec/models/spree/pricing_provider/internal_resolution_spec.rb b/spree/core/spec/models/spree/pricing_provider/internal_resolution_spec.rbindex 798902957a..e6dda2dfbc 100644--- a/spree/core/spec/models/spree/pricing_provider/internal_resolution_spec.rb+++ b/spree/core/spec/models/spree/pricing_provider/internal_resolution_spec.rb@@ -526,19 +526,11 @@ describe Spree::PricingProvider::Internal::Resolution doexpect(price_at(9).amount).to eq(95.00)expect(price_at(10).amount).to eq(90.00)expect(price_at(49).amount).to eq(90.00)+ # Every band is a percentage off the base price, never off the band+ # below it — otherwise "20% from fifty" would quietly mean 24%.expect(price_at(50).amount).to eq(80.00)end- # Every band is a percentage off the base price, never off the band- # below it — otherwise "20% from fifty" would quietly mean 24%.- it 'takes each band off the base price rather than compounding' do- expect(price_at(50).amount).to eq(80.00)- end-- it 'falls back to the column when the line reaches no band' do- expect(price_at(1).amount).to eq(95.00)- end-it 'reads the column when the context carries no quantity' doexpect(price_at(nil).amount).to eq(95.00)enddiff --git a/spree/core/spec/models/spree/product/normalizes_spec.rb b/spree/core/spec/models/spree/product/normalizes_spec.rbindex 28a0ea705d..6af3be1560 100644--- a/spree/core/spec/models/spree/product/normalizes_spec.rb+++ b/spree/core/spec/models/spree/product/normalizes_spec.rb@@ -19,12 +19,6 @@ describe Spree::Product, type: :model doexpect(product.name).to be_nilend- it 'handles nil value' do- product = build(:product)- product.name = nil- expect(product.name).to be_nil- end-context 'with always_use_translations enabled' dobefore doSpree::Config.always_use_translations = truediff --git a/spree/core/spec/models/spree/product/scopes_spec.rb b/spree/core/spec/models/spree/product/scopes_spec.rbindex 17a05b4754..3878173ec4 100644--- a/spree/core/spec/models/spree/product/scopes_spec.rb+++ b/spree/core/spec/models/spree/product/scopes_spec.rb@@ -17,12 +17,6 @@ describe 'Product scopes', type: :model doit { expect(Spree::Product.available).to include(product_2) }end- context 'when available' do- let!(:product_2) { create(:product, status: 'active') }-- it { expect(Spree::Product.available).to include(product_2) }- end-context 'when not available' dolet!(:unavailable_product) { create(:product, status: 'draft') }@@ -99,18 +93,6 @@ describe 'Product scopes', type: :model doendend- context 'sorting scopes' do- context 'ascend_by_updated_at' do- it { expect(Spree::Product.ascend_by_updated_at.to_sql).to include('updated_at ASC') }- it { expect(Spree::Product.limit(2).ascend_by_updated_at.to_sql).to include('updated_at ASC') }- end-- context 'descend_by_name' do- it { expect(Spree::Product.descend_by_name.to_sql).to include('name DESC') }- it { expect(Spree::Product.limit(2).descend_by_name.to_sql).to include('name DESC') }- end- end-context '#search_by_name' dolet!(:first_product) { create(:product, name: 'First product') }let!(:second_product) { create(:product, name: 'Second product') }@@ -309,30 +291,6 @@ describe 'Product scopes', type: :model doendend- context 'with incomplete orders' do- before do- # Product 1: 2 units sold (2 completed orders)- create_list(:completed_order_with_totals, 2, line_items_price: 100, store: store, variants: [product_1.default_variant])-- # Product 2: 1 unit sold (1 completed order) + 2 incomplete orders (should not be counted)- create(:completed_order_with_totals, line_items_price: 100, store: store, variants: [product_2.default_variant])- create_list(:order_with_totals, 2, line_items_price: 100, store: store, variants: [product_2.default_variant])-- refresh_all_metrics!- end-- it 'only counts units from completed orders' do- products = store.products.where(id: test_product_ids).by_best_selling- expect(products.first.name).to eq('Product 1')-- product_1_store_product = product_1.reload- product_2_store_product = product_2.reload-- expect(product_1_store_product.units_sold_count).to eq(2)- expect(product_2_store_product.units_sold_count).to eq(1)- end- end-context 'when products have same units_sold_count' dobefore do# Both products have 2 units sold, but different revenue@@ -358,38 +316,6 @@ describe 'Product scopes', type: :model doendend- context 'with varying quantities' do- before do- # Product 1: 5 units sold (quantity 2 + quantity 3)- order1 = create(:order_with_line_items, line_items_count: 0, store: store)- create(:line_item, order: order1, variant: product_1.default_variant, price: 50, quantity: 2)- create(:line_item, order: order1, variant: product_1.default_variant, price: 50, quantity: 3)- order1.update!(completed_at: Time.current)-- # Product 2: 2 units sold (quantity 2)- order2 = create(:order_with_line_items, line_items_count: 0, store: store)- create(:line_item, order: order2, variant: product_2.default_variant, price: 100, quantity: 2)- order2.update!(completed_at: Time.current)-- refresh_all_metrics!- end-- it 'sums line item quantities for units_sold_count' do- products = store.products.where(id: test_product_ids).by_best_selling-- product_1_store_product = product_1.reload- product_2_store_product = product_2.reload-- # Product 1: 2 + 3 = 5 units- expect(product_1_store_product.units_sold_count).to eq(5)- # Product 2: 2 units- expect(product_2_store_product.units_sold_count).to eq(2)-- # Product 1 should be ranked higher due to more units sold- expect(products.first.name).to eq('Product 1')- end- end-context 'with multiple orders containing multiple line items' dobefore do# Product 1: 5 units sold across 2 orders (quantity 3 + quantity 2)@@ -426,23 +352,6 @@ describe 'Product scopes', type: :model doendend- context 'with products having no orders' do- before do- refresh_all_metrics!- end-- it 'includes products with no orders at the end' do- products = store.products.where(id: test_product_ids).by_best_selling- expect(products.length).to eq(4)- # All products should be included, those without orders have units_sold_count = 0- [product_1, product_2, product_3, product_4].each do |p|- store_product = p.reload- expect(store_product.units_sold_count).to eq(0)- expect(store_product.revenue).to eq(0)- end- end- end-context 'with products having only pending orders (no completed_at)' dobefore do# Product 1: 2 units sold (2 completed orders)@@ -484,13 +393,8 @@ describe 'Product scopes', type: :model do# Product 4 has no orders at all - count should be 0expect(product_4_sp.units_sold_count).to eq(0)expect(product_4_sp.revenue).to eq(0)- end- it 'orders products correctly with pending orders included' do- products = store.products.where(id: test_product_ids).by_best_selling- # Product 1: 2 units sold (first)- # Product 3: 1 unit sold (second)- # Product 2 & 4: 0 units sold (last, order between them is non-deterministic)+ # Product 2 & 4 have no completed sales, so they rank last in no fixed orderexpect(products.first(2).map(&:name)).to eq(['Product 1', 'Product 3'])expect(products.last(2).map(&:name)).to contain_exactly('Product 2', 'Product 4')end@@ -583,17 +487,17 @@ describe 'Product scopes', type: :model doendit 'includes a future-dated product with an active pre-order variant' do- active_product.master.update_columns(preorderable: true)+ active_product.default_variant.update_columns(preorderable: true)expect(Spree::Product.available(Time.current, 'USD', include_preorderable: true)).to include(active_product)endit "excludes it when the pre-order's ship date has already passed" do- active_product.master.update_columns(preorderable: true, preorder_ships_at: 1.day.ago)+ active_product.default_variant.update_columns(preorderable: true, preorder_ships_at: 1.day.ago)expect(Spree::Product.available(Time.current, 'USD', include_preorderable: true)).not_to include(active_product)endit 'still excludes a future-dated product with no pre-order variant' do- active_product.master.update_columns(preorderable: false)+ active_product.default_variant.update_columns(preorderable: false)expect(Spree::Product.available(Time.current, 'USD', include_preorderable: true)).not_to include(active_product)endenddiff --git a/spree/core/spec/models/spree/product/slugs_spec.rb b/spree/core/spec/models/spree/product/slugs_spec.rbindex 162ed71a57..d69029d63c 100644--- a/spree/core/spec/models/spree/product/slugs_spec.rb+++ b/spree/core/spec/models/spree/product/slugs_spec.rb@@ -47,19 +47,9 @@ describe Spree::Product::Slugs, type: :model doanother_product.destroy!end- it 'can use original slug' do- product.save!-- expect(product.slugs.first.slug).to eq(name)- expect(product.slug).to eq(name)-- deleted_slug = another_product.slugs.with_deleted.first- expect(deleted_slug.slug).to match(/deleted-#{name}-.+/)- expect(another_product.slug).to match(/deleted-#{name}-.+/)- end-it 'can delete the product again and then create a new product with the original slug' doproduct.save!+ expect(product.slug).to eq(name)product.destroy!new_product = build(:product, name: name)@@ -78,13 +68,6 @@ describe Spree::Product::Slugs, type: :model doendend- it 'stores old slugs in FriendlyIds history' do- expect(product).to receive(:create_slug)- # Set it, otherwise the create_slug method avoids writing a new one- product.slug = 'custom-slug'- product.run_callbacks :save- end-context 'when product destroyed' doit 'renames slug' doproduct.destroy!@@ -151,14 +134,6 @@ describe Spree::Product::Slugs, type: :model doendend- it 'validates slug uniqueness' do- existing_product = product- new_product = create(:product)- new_product.slug = existing_product.slug-- expect(new_product.valid?).to be false- end-it "falls back to 'name-sku' for slug if regular name-based slug already in use" doproduct1 = build(:product)product1.name = 'test'@@ -176,16 +151,6 @@ describe Spree::Product::Slugs, type: :model docontext 'history' dolet(:product) { create(:product, name: 'Product 67345') }- context 'when product is destroyed' do- before do- product.destroy- end-- it 'keeps the history' do- expect(product.slugs.with_deleted).not_to be_empty- end- end-context 'when product is restored' dobefore doproduct.destroydiff --git a/spree/core/spec/models/spree/product_publication_spec.rb b/spree/core/spec/models/spree/product_publication_spec.rbindex deecfe39b5..a127db9d91 100644--- a/spree/core/spec/models/spree/product_publication_spec.rb+++ b/spree/core/spec/models/spree/product_publication_spec.rb@@ -2,7 +2,6 @@ require 'spec_helper'RSpec.describe Spree::ProductPublication, type: :model dolet(:store) { @default_store }- let(:channel) { store.default_channel }let(:product) { create(:product, store: store) }let(:other_store) { create(:store, default: false, code: 'other') }@@ -14,16 +13,6 @@ RSpec.describe Spree::ProductPublication, type: :model dolet(:secondary_channel) { create(:channel, store: store, code: 'pos', name: 'POS') }describe 'validations' do- it 'is valid with product and channel' do- publication = build(:product_publication, product: product, channel: secondary_channel)- expect(publication).to be_valid- end-- it 'enforces uniqueness per (product, channel)' do- duplicate = build(:product_publication, product: product, channel: channel)- expect(duplicate).not_to be_valid- end-it 'rejects unpublished_at before published_at' dopublication = build(:product_publication,@@ -35,14 +24,6 @@ RSpec.describe Spree::ProductPublication, type: :model doendend- describe '#store delegation' do- it 'returns the channel.store' do- publication = build(:product_publication, product: product, channel: secondary_channel)- expect(publication.store).to eq(store)- expect(publication.store_id).to eq(store.id)- end- end-describe '.published' doit 'includes publications with null dates' dopublication = create(:product_publication, product: product, channel: secondary_channel)diff --git a/spree/core/spec/models/spree/product_spec.rb b/spree/core/spec/models/spree/product_spec.rbindex 9a8e13462e..49a0b3b319 100644--- a/spree/core/spec/models/spree/product_spec.rb+++ b/spree/core/spec/models/spree/product_spec.rb@@ -264,14 +264,6 @@ describe Spree::Product, type: :model doendend- # Regression test for #3737- context 'has stock items' do- it 'can retrieve stock items' do- expect(product.default_variant.stock_levels.first).not_to be_nil- expect(product.stock_levels.first).not_to be_nil- end- end-describe '#discontinue_on_must_be_later_than_make_active_at' dobefore { product.make_active_at = Date.today }@@ -308,19 +300,19 @@ describe Spree::Product, type: :model docontext 'hard deletion' doit 'doesnt raise ActiveRecordError error' do- expect { product.really_destroy! }.not_to raise_error(ActiveRecord::ActiveRecordError)+ expect { product.really_destroy! }.not_to raise_errorendendcontext 'history' do- before do- @product = create(:product)- end-it 'keeps translations when product is destroyed' do- @product.destroy+ product = create(:product)+ Mobility.with_locale(:pl) { product.update!(name: 'PL name') }- expect(@product.name).not_to be_empty+ product.destroy++ destroyed_product = Spree::Product.with_deleted.find(product.id)+ expect(Mobility.with_locale(:pl) { destroyed_product.name }).to eq('PL name')endend@@ -333,10 +325,6 @@ describe Spree::Product, type: :model doproduct.instance_variable_set(:@total_on_hand, incorrent_total_on_hand)end- it 'without action keeps data' do- expect(product.total_on_hand).to eq incorrent_total_on_hand- end-it 'resets memoized data after save' doproduct.saveexpect(product.total_on_hand).to eq corrent_total_on_hand@@ -422,10 +410,6 @@ describe Spree::Product, type: :model doproduct.saveexpect(product.option_type_ids.length).to eq(1)expect(product.option_type_ids).to eq(product_type.option_type_ids)- end-- it 'creates product option types based on the product type' do- product.saveexpect(product.product_option_types.pluck(:option_type_id)).to eq(product_type.option_type_ids)end@@ -666,19 +650,6 @@ describe Spree::Product, type: :model doendend- # Regression tests for #2352- context 'product_categories and categories' do- it 'is joined through product_categories' do- reflection = Spree::Product.reflect_on_association(:categories)- expect(reflection.options[:through]).to eq(:product_categories)- end-- it 'will delete all product_categories' do- reflection = Spree::Product.reflect_on_association(:product_categories)- expect(reflection.options[:dependent]).to eq(:delete_all)- end- end-describe 'the price filter' dolet!(:cheap) { create(:product, price: 5) }let!(:pricey) { create(:product, price: 500) }@@ -736,23 +707,15 @@ describe Spree::Product, type: :model dodescribe '#discontinue!' dolet(:product) { create(:product, sku: 'a-sku') }- it 'sets the discontinued' do- product.discontinue!- product.reload- expect(product.discontinued?).to be(true)- end+ it 'archives the product as discontinued' do+ product.update_column(:updated_at, 1.day.ago)++ expect { product.discontinue! }.to change(product, :updated_at)- it 'sets the status to archived' do- product.discontinue!product.reload+ expect(product.discontinued?).to be(true)expect(product.status).to eq('archived')end-- it 'changes updated_at' do- Timecop.scale(1000) do- expect { product.discontinue! }.to change(product, :updated_at)- end- endenddescribe '#discontinued?' do@@ -800,10 +763,6 @@ describe Spree::Product, type: :model dodescribe '#default_variant' dolet(:product) { create(:product) }- it 'is the sole variant for a simple product' do- expect(product.reload.default_variant).to eq(product.variants.first)- end-it 'stays fixed (sticky) when other variants are added, regardless of stock' dodefault = product.default_variantcreate(:variant, product: product)@@ -839,14 +798,6 @@ describe Spree::Product, type: :model doendend- describe '#default_variant_id' do- let(:product) { create(:product) }-- it 'returns the default variant id' do- expect(product.reload.default_variant_id).to eq(product.variants.first.id)- end- end-describe '#primary_media' dolet(:product) { create(:product) }@@ -1067,9 +1018,12 @@ describe Spree::Product, type: :model dodescribe '#secondary_image' dolet(:product) { create(:product) }+ before { allow(Spree::Deprecation).to receive(:warn) }+context 'when no variants have images' doit 'returns nil' doexpect(product.secondary_image).to be_nil+ expect(Spree::Deprecation).to have_received(:warn).with(/Product#secondary_image is deprecated/)endend@@ -1121,15 +1075,6 @@ describe Spree::Product, type: :model doexpect(loaded_product.variant_for_images).to eq(variant)expect(loaded_product.has_images?).to be trueend-- context 'when the image is on a non-default variant' do- it 'still finds the image through variant_for_images' do- loaded_product = Spree::Product.includes(*storefront_includes).find(product.id)-- expect(loaded_product.variant_for_images).to eq(variant)- expect(loaded_product.primary_media).to eq(image)- end- endenddescribe 'default store assignment' do@@ -1296,14 +1241,10 @@ describe Spree::Product, type: :model doit { expect(subject).to be(true) }end- context 'when all option variant stock items have track_inventory = true' do- it { expect(subject).to eq(false) }+ context 'when all option variant stock items have backorderable = true' do+ before { stock_level.update(backorderable: true) }- context 'when all option variant stock items have backorderable = true' do- before { stock_level.update(backorderable: true) }-- it { expect(subject).to eq(true) }- end+ it { expect(subject).to eq(true) }endendend@@ -1321,20 +1262,6 @@ describe Spree::Product, type: :model doit { expect(subject).to eq(false) }end-- describe '#digital?' do- context 'when the product belongs to a digital profile' do- let(:product) { create(:digital_product) }-- it { expect(product.digital?).to eq(true) }- end-- context 'when the product belongs to the default profile' do- let(:product) { create(:product) }-- it { expect(product.digital?).to eq(false) }- end- endenddescribe '#to_csv' do@@ -1963,14 +1890,6 @@ describe Spree::Product, type: :model doenddescribe 'status' do- it 'has no state machine' do- expect(described_class).not_to respond_to(:state_machines)- end-- it 'defaults to draft' do- expect(described_class.new.status).to eq('draft')- end-it 'rejects an unknown status' doexpect(build(:product, status: 'nonsense')).not_to be_validend@@ -1981,36 +1900,6 @@ describe Spree::Product, type: :model doit 'keeps the currency-aware active scope' doexpect(described_class.active(nil).to_sql).to include(Spree::Price.table_name)end-- it 'generates the plain status scopes and predicates' do- expect(described_class.draft.to_sql).to include("'draft'")- expect(described_class.archived.to_sql).to include("'archived'")- expect(build(:product, status: 'draft')).to be_draft- end- end-- describe 'custom events', events: true do- describe 'product.activated' do- let(:product) { create(:product, status: 'draft') }-- it 'publishes product.activated event when activated' do- expect(product).to receive(:publish_event).with('product.activated')- allow(product).to receive(:publish_event).with(anything)-- Spree::Products::Activate.call(product: product)- end- end-- describe 'product.archived' do- let(:product) { create(:product, status: 'active') }-- it 'publishes product.archived event when archived' do- expect(product).to receive(:publish_event).with('product.archived')- allow(product).to receive(:publish_event).with(anything)-- Spree::Products::Archive.call(product: product)- end- endenddescribe '#has_variants?' do@@ -2100,30 +1989,6 @@ describe Spree::Product, type: :model doexpect(product.variants.reload).to include(v1)expect(product.variants).not_to include(v2)end-- it 'defers creation on new records' do- new_product = Spree.product_create_workflow.call(- store: store,- attributes: { name: 'Deferred', variants: [{ sku: 'DEF-1', options: [{ name: 'Color', value: 'Red' }] }] }- ).value-- expect(new_product.variants.count).to eq(1)- expect(new_product.variants.first.sku).to eq('DEF-1')- end-- it 'creates a single default variant from an options-less entry' do- # Simple-product flow: the merchant edits SKU + weight on the default- # variant without adding options. The payload ships a single variant- # with options:[] and the backend creates exactly that one variant.- new_product = Spree.product_create_workflow.call(- store: store,- attributes: { name: 'Simple SKU', variants: [{ sku: 'SIMPLE-1', weight: 2, options: [] }] }- ).value-- expect(new_product.variants.count).to eq(1)- expect(new_product.default_variant.sku).to eq('SIMPLE-1')- expect(new_product.default_variant.weight).to eq(2)- endendcontext 'with Variant objects' do@@ -2346,15 +2211,6 @@ describe Spree::Product, type: :model doexpect(product.reload.tax_category).to eq(custom_tc)end-- it 'assigns default when tax_category_id is not provided' do- product = Spree::Product.new(- name: 'Test',- store: store- )-- expect(product.tax_category).to eq(default_tc)- endendcontext 'Channels' do@@ -2367,12 +2223,6 @@ describe Spree::Product, type: :model doallow(Spree::Deprecation).to receive(:warn)end- context 'associations' do- it 'reaches channels through product_publications' do- expect(product.reload.channels).to contain_exactly(default_channel)- end- end-context '#available_on=' doit 'emits a deprecation warning' doproduct.available_on = targetdiff --git a/spree/core/spec/models/spree/product_type_custom_field_definition_spec.rb b/spree/core/spec/models/spree/product_type_custom_field_definition_spec.rbindex 575686d490..7f12e8d4af 100644--- a/spree/core/spec/models/spree/product_type_custom_field_definition_spec.rb+++ b/spree/core/spec/models/spree/product_type_custom_field_definition_spec.rb@@ -2,24 +2,8 @@ require 'spec_helper'RSpec.describe Spree::ProductTypeCustomFieldDefinition, type: :model dolet(:product_type) { create(:product_type) }- let(:definition) { create(:custom_field_definition) }describe 'validations' do- it 'rejects a second row for the same definition' do- create(:product_type_custom_field_definition, product_type: product_type, custom_field_definition: definition)- duplicate = build(:product_type_custom_field_definition, product_type: product_type, custom_field_definition: definition)-- expect(duplicate).not_to be_valid- expect(duplicate.errors[:custom_field_definition_id]).to be_present- end-- it 'allows the same definition on another type' do- create(:product_type_custom_field_definition, product_type: product_type, custom_field_definition: definition)- other = build(:product_type_custom_field_definition, product_type: create(:product_type), custom_field_definition: definition)-- expect(other).to be_valid- end-it 'rejects a definition scoped to another resource' doorder_definition = create(:custom_field_definition, :for_order)join = build(:product_type_custom_field_definition, product_type: product_type, custom_field_definition: order_definition)@@ -37,15 +21,6 @@ RSpec.describe Spree::ProductTypeCustomFieldDefinition, type: :model doendend- describe 'defaults' do- it 'is optional and unsorted' do- join = described_class.new-- expect(join.required).to be(false)- expect(join.sort_order).to eq(0)- end- end-describe 'scopes' doit '.required returns only required rows' dorequired = create(:product_type_custom_field_definition, :required, product_type: product_type)@@ -71,11 +46,5 @@ RSpec.describe Spree::ProductTypeCustomFieldDefinition, type: :model do[earlier.custom_field_definition, later.custom_field_definition])end-- it 'is destroyed with the product type' do- create(:product_type_custom_field_definition, product_type: product_type)-- expect { product_type.destroy }.to change(described_class, :count).by(-1)- endendenddiff --git a/spree/core/spec/models/spree/product_type_spec.rb b/spree/core/spec/models/spree/product_type_spec.rbindex 8eb2d63162..222dad564b 100644--- a/spree/core/spec/models/spree/product_type_spec.rb+++ b/spree/core/spec/models/spree/product_type_spec.rb@@ -4,10 +4,6 @@ describe Spree::ProductType, type: :model doit_behaves_like 'metadata'describe 'delivery profile template' do- it 'is optional — a type without one leaves products on the store default' do- expect(build(:product_type).delivery_profile).to be_nil- end-it 'stamps its profile onto products at creation' doprofile = create(:delivery_profile)product_type = create(:product_type, delivery_profile: profile)diff --git a/spree/core/spec/models/spree/promotion/actions/create_adjustment_spec.rb b/spree/core/spec/models/spree/promotion/actions/create_adjustment_spec.rbindex 039562b86d..b2025f8a28 100644--- a/spree/core/spec/models/spree/promotion/actions/create_adjustment_spec.rb+++ b/spree/core/spec/models/spree/promotion/actions/create_adjustment_spec.rb@@ -45,8 +45,4 @@ describe Spree::Promotion::Actions::CreateAdjustment, type: :model doexpect(huge.compute_amount(order)).to eq(-action.order_total(order))endend-- it 'has order discount scope' do- expect(action.discount_scope).to eq(:order)- endenddiff --git a/spree/core/spec/models/spree/promotion/actions/create_line_items_spec.rb b/spree/core/spec/models/spree/promotion/actions/create_line_items_spec.rbindex 3c2e7e1d5e..0b3490972f 100644--- a/spree/core/spec/models/spree/promotion/actions/create_line_items_spec.rb+++ b/spree/core/spec/models/spree/promotion/actions/create_line_items_spec.rb@@ -185,18 +185,10 @@ describe Spree::Promotion::Actions::CreateLineItems, type: :model doendend- it "discounts the shopper's own copy instead of adding a second one" do- Spree.cart_add_item_workflow.call(cart: cart, variant: gift, quantity: 1)-- expect(promotion.activate(order: cart)).to be(true)- expect(gift_line_item.quantity).to eq(1)- expect(gift_line_item.discounts.sum(&:amount)).to eq(-15)- end-it 'leaves units beyond the gifted quantity paid for' doSpree.cart_add_item_workflow.call(cart: cart, variant: gift, quantity: 3)- promotion.activate(order: cart)+ expect(promotion.activate(order: cart)).to be(true)expect(gift_line_item.quantity).to eq(3)expect(gift_line_item.discounts.sum(&:amount)).to eq(-15)diff --git a/spree/core/spec/models/spree/promotion/rules/category_spec.rb b/spree/core/spec/models/spree/promotion/rules/category_spec.rbindex 5ddc79d5e1..a2bcefb087 100644--- a/spree/core/spec/models/spree/promotion/rules/category_spec.rb+++ b/spree/core/spec/models/spree/promotion/rules/category_spec.rb@@ -68,7 +68,7 @@ describe Spree::Promotion::Rules::Category, type: :model doorder.products.first.categories << category2order.products.last.categories << category- rule.taxons = [category, category2]+ rule.categories = [category, category2]expect(rule).to be_eligible(order)end@@ -100,31 +100,29 @@ describe Spree::Promotion::Rules::Category, type: :model doendend- describe '#add_taxons' do- let(:promotion) { create(:promotion) }- let(:rule) { create(:promotion_rule_taxon, promotion: promotion) }+ describe '#category_ids_to_add=' dolet(:taxons) { create_list(:category, 3) }- it 'adds the taxons to the rule' do- rule.taxon_ids_to_add = taxons.map(&:id)+ it 'adds the categories to the rule' do+ rule.category_ids_to_add = taxons.map(&:id)rule.save!- expect(rule.taxons).to match_array(taxons)+ expect(rule.categories).to match_array(taxons)end- it 'removes the taxons from the rule' do- rule.taxon_ids_to_add = taxons.map(&:id)+ it 'removes the categories from the rule' do+ rule.category_ids_to_add = taxons.map(&:id)rule.save!- rule.taxon_ids_to_add = []+ rule.category_ids_to_add = []rule.save!- expect(rule.taxons).to be_empty+ expect(rule.categories).to be_emptyend- it 'does not remove the taxons when nil is passed' do- rule.taxon_ids_to_add = taxons.map(&:id)+ it 'does not remove the categories when nil is passed' do+ rule.category_ids_to_add = taxons.map(&:id)rule.save!- rule.taxon_ids_to_add = nil+ rule.category_ids_to_add = nilrule.save!- expect(rule.taxons).to match_array(taxons)+ expect(rule.categories).to match_array(taxons)endenddiff --git a/spree/core/spec/models/spree/promotion/rules/country_spec.rb b/spree/core/spec/models/spree/promotion/rules/country_spec.rbindex 52c5386bf3..cf86ecc2b3 100644--- a/spree/core/spec/models/spree/promotion/rules/country_spec.rb+++ b/spree/core/spec/models/spree/promotion/rules/country_spec.rb@@ -7,27 +7,6 @@ describe Spree::Promotion::Rules::Country, type: :model dolet(:country) { create(:country) }let(:other_country) { create(:country) }- context 'preferred country_id is set' do- before { rule.preferred_country_code = country.iso }-- it 'is eligible for correct country' do- allow(order).to receive_message_chain(:ship_address, :country_id) { country.id }- allow(order).to receive_message_chain(:ship_address, :country_code) { country.iso }-- expect(rule).to be_eligible(order)- end-- it 'is not eligible for incorrect country' do- allow(order).to receive_message_chain(:ship_address, :country_id) { other_country.id }- allow(order).to receive_message_chain(:ship_address, :country_code) { other_country.iso }-- expect(rule).not_to be_eligible(order)-- expect(rule.eligibility_errors.count).to eq(1)- expect(rule.eligibility_errors.to_hash[:base]).to eq([I18n.t('spree.eligibility_errors.messages.wrong_country')])- end- end-context 'preferred country_code is set' dobefore { rule.preferred_country_code = country.iso }diff --git a/spree/core/spec/models/spree/promotion/rules/item_total_spec.rb b/spree/core/spec/models/spree/promotion/rules/item_total_spec.rbindex 303b318a33..bd714afe26 100644--- a/spree/core/spec/models/spree/promotion/rules/item_total_spec.rb+++ b/spree/core/spec/models/spree/promotion/rules/item_total_spec.rb@@ -5,316 +5,61 @@ describe Spree::Promotion::Rules::ItemTotal, type: :model dolet(:rule) { Spree::Promotion::Rules::ItemTotal.new }let(:order) { build(:order, store: store) }- before do- rule.preferred_amount_min = 50- rule.preferred_amount_max = 60- end-- context 'preferred operator_min set to gt and preferred operator_max set to lt' do- before do- rule.preferred_operator_min = 'gt'- rule.preferred_operator_max = 'lt'- end-- context 'and item total is lower than preferred maximum amount' do- context 'and item total is higher than preferred minimum amount' do- it 'is eligible' do- allow(order).to receive_messages item_total: 51- expect(rule).to be_eligible(order)- end- end-- context 'and item total is equal to the preferred minimum amount' do- before { allow(order).to receive_messages item_total: 50 }-- it 'is not eligible' do- expect(rule).not_to be_eligible(order)- end-- it 'set an error message' do- rule.eligible?(order)- expect(rule.eligibility_errors.full_messages.first).- to eq "This coupon code can't be applied to orders less than or equal to $50.00."- end- end-- context 'and item total is lower to the preferred minimum amount' do- before { allow(order).to receive_messages item_total: 49 }-- it 'is not eligible' do- expect(rule).not_to be_eligible(order)- end-- it 'set an error message' do- rule.eligible?(order)- expect(rule.eligibility_errors.full_messages.first).- to eq "This coupon code can't be applied to orders less than or equal to $50.00."- end- end- end-- context 'and item total is equal to the preferred maximum amount' do- before { allow(order).to receive_messages item_total: 60 }-- it 'is not eligible' do- expect(rule).not_to be_eligible(order)- end-- it 'set an error message' do- rule.eligible?(order)- expect(rule.eligibility_errors.full_messages.first).- to eq "This coupon code can't be applied to orders higher than or equal to $60.00."- end- end-- context 'and item total is higher than the preferred maximum amount' do- before { allow(order).to receive_messages item_total: 61 }-- it 'is not eligible' do- expect(rule).not_to be_eligible(order)- end-- it 'set an error message' do- rule.eligible?(order)- expect(rule.eligibility_errors.full_messages.first).- to eq "This coupon code can't be applied to orders higher than or equal to $60.00."- end- end- end-- context 'preferred operator set to gt and preferred operator_max set to lte' do- before do- rule.preferred_operator_min = 'gt'- rule.preferred_operator_max = 'lte'- end-- context 'and item total is lower than preferred maximum amount' do- context 'and item total is higher than preferred minimum amount' do- it 'is eligible' do- allow(order).to receive_messages item_total: 51- expect(rule).to be_eligible(order)- end- end-- context 'and item total is equal to the preferred minimum amount' do- before { allow(order).to receive_messages item_total: 50 }-- it 'is not eligible' do+ less_than_or_equal_min = "This coupon code can't be applied to orders less than or equal to $50.00."+ less_than_min = "This coupon code can't be applied to orders less than $50.00."+ higher_than_or_equal_max = "This coupon code can't be applied to orders higher than or equal to $60.00."+ higher_than_max = "This coupon code can't be applied to orders higher than $60.00."++ # [operator_min, operator_max, amount_max, item_total, expected error (nil when eligible)]+ [+ ['gt', 'lt', 60, 51, nil],+ ['gt', 'lt', 60, 50, less_than_or_equal_min],+ ['gt', 'lt', 60, 49, less_than_or_equal_min],+ ['gt', 'lt', 60, 60, higher_than_or_equal_max],+ ['gt', 'lt', 60, 61, higher_than_or_equal_max],++ ['gt', 'lte', 60, 51, nil],+ ['gt', 'lte', 60, 50, less_than_or_equal_min],+ ['gt', 'lte', 60, 49, less_than_or_equal_min],+ ['gt', 'lte', 60, 60, nil],+ ['gt', 'lte', 60, 61, higher_than_max],++ ['gte', 'lt', 60, 51, nil],+ ['gte', 'lt', 60, 50, nil],+ ['gte', 'lt', 60, 49, less_than_min],+ ['gte', 'lt', 60, 60, higher_than_or_equal_max],+ ['gte', 'lt', 60, 61, higher_than_or_equal_max],++ ['gte', 'lte', 60, 51, nil],+ ['gte', 'lte', 60, 50, nil],+ ['gte', 'lte', 60, 49, less_than_min],+ ['gte', 'lte', 60, 60, nil],+ ['gte', 'lte', 60, 61, higher_than_max],++ # No maximum amount: only the minimum applies.+ ['gt', 'lt', nil, 51, nil],+ ['gt', 'lt', nil, 50, less_than_or_equal_min],+ ['gt', 'lt', nil, 49, less_than_or_equal_min]+ ].each do |operator_min, operator_max, amount_max, item_total, expected_error|+ context "with #{operator_min} 50 / #{operator_max} #{amount_max.inspect} and an item total of #{item_total}" do+ before do+ rule.preferred_amount_min = 50+ rule.preferred_amount_max = amount_max+ rule.preferred_operator_min = operator_min+ rule.preferred_operator_max = operator_max+ allow(order).to receive_messages(item_total: item_total)+ end++ if expected_error+ it 'is not eligible and explains why' doexpect(rule).not_to be_eligible(order)+ expect(rule.eligibility_errors.full_messages.first).to eq(expected_error)end-- it 'set an error message' do- rule.eligible?(order)- expect(rule.eligibility_errors.full_messages.first).- to eq "This coupon code can't be applied to orders less than or equal to $50.00."- end- end-- context 'and item total is lower to the preferred minimum amount' do- before { allow(order).to receive_messages item_total: 49 }-- it 'is not eligible' do- expect(rule).not_to be_eligible(order)- end-- it 'set an error message' do- rule.eligible?(order)- expect(rule.eligibility_errors.full_messages.first).- to eq "This coupon code can't be applied to orders less than or equal to $50.00."- end- end- end-- context 'and item total is equal to the preferred maximum amount' do- before { allow(order).to receive_messages item_total: 60 }-- it 'is not eligible' do- expect(rule).to be_eligible(order)- end- end-- context 'and item total is higher than the preferred maximum amount' do- before { allow(order).to receive_messages item_total: 61 }-- it 'is not eligible' do- expect(rule).not_to be_eligible(order)- end-- it 'set an error message' do- rule.eligible?(order)- expect(rule.eligibility_errors.full_messages.first).- to eq "This coupon code can't be applied to orders higher than $60.00."- end- end- end-- context 'preferred operator set to gte and preferred operator_max set to lt' do- before do- rule.preferred_operator_min = 'gte'- rule.preferred_operator_max = 'lt'- end-- context 'and item total is lower than preferred maximum amount' do- context 'and item total is higher than preferred minimum amount' do+ elseit 'is eligible' do- allow(order).to receive_messages item_total: 51expect(rule).to be_eligible(order)endend-- context 'and item total is equal to the preferred minimum amount' do- before { allow(order).to receive_messages item_total: 50 }-- it 'is not eligible' do- expect(rule).to be_eligible(order)- end- end-- context 'and item total is lower to the preferred minimum amount' do- before { allow(order).to receive_messages item_total: 49 }-- it 'is not eligible' do- expect(rule).not_to be_eligible(order)- end-- it 'set an error message' do- rule.eligible?(order)- expect(rule.eligibility_errors.full_messages.first).- to eq "This coupon code can't be applied to orders less than $50.00."- end- end- end-- context 'and item total is equal to the preferred maximum amount' do- before { allow(order).to receive_messages item_total: 60 }-- it 'is not eligible' do- expect(rule).not_to be_eligible(order)- end-- it 'set an error message' do- rule.eligible?(order)- expect(rule.eligibility_errors.full_messages.first).- to eq "This coupon code can't be applied to orders higher than or equal to $60.00."- end- end-- context 'and item total is higher than the preferred maximum amount' do- before { allow(order).to receive_messages item_total: 61 }-- it 'is not eligible' do- expect(rule).not_to be_eligible(order)- end-- it 'set an error message' do- rule.eligible?(order)- expect(rule.eligibility_errors.full_messages.first).- to eq "This coupon code can't be applied to orders higher than or equal to $60.00."- end- end- end-- context 'preferred operator set to gte and preferred operator_max set to lte' do- before do- rule.preferred_operator_min = 'gte'- rule.preferred_operator_max = 'lte'- end-- context 'and item total is lower than preferred maximum amount' do- context 'and item total is higher than preferred minimum amount' do- it 'is eligible' do- allow(order).to receive_messages item_total: 51- expect(rule).to be_eligible(order)- end- end-- context 'and item total is equal to the preferred minimum amount' do- before { allow(order).to receive_messages item_total: 50 }-- it 'is not eligible' do- expect(rule).to be_eligible(order)- end- end-- context 'and item total is lower to the preferred minimum amount' do- before { allow(order).to receive_messages item_total: 49 }-- it 'is not eligible' do- expect(rule).not_to be_eligible(order)- end-- it 'set an error message' do- rule.eligible?(order)- expect(rule.eligibility_errors.full_messages.first).- to eq "This coupon code can't be applied to orders less than $50.00."- end- end- end-- context 'and item total is equal to the preferred maximum amount' do- before { allow(order).to receive_messages item_total: 60 }-- it 'is not eligible' do- expect(rule).to be_eligible(order)- end- end-- context 'and item total is higher than the preferred maximum amount' do- before { allow(order).to receive_messages item_total: 61 }-- it 'is not eligible' do- expect(rule).not_to be_eligible(order)- end-- it 'set an error message' do- rule.eligible?(order)- expect(rule.eligibility_errors.full_messages.first).- to eq "This coupon code can't be applied to orders higher than $60.00."- end- end- end-- context 'when preferred amount max is not set' do- before do- rule.preferred_amount_min = 50- rule.preferred_amount_max = nil- rule.preferred_operator_min = 'gt'- rule.preferred_operator_max = 'lt'- end-- context 'and item total is higher than preferred minimum amount' do- it 'is eligible' do- allow(order).to receive_messages item_total: 51- expect(rule).to be_eligible(order)- end- end-- context 'and item total is equal to the preferred minimum amount' do- before { allow(order).to receive_messages item_total: 50 }-- it 'is not eligible' do- expect(rule).not_to be_eligible(order)- end-- it 'set an error message' do- rule.eligible?(order)- expect(rule.eligibility_errors.full_messages.first).- to eq "This coupon code can't be applied to orders less than or equal to $50.00."- end- end-- context 'and item total is lower than preferred minimum amount' do- before { allow(order).to receive_messages item_total: 49 }-- it 'is not eligible' do- expect(rule).not_to be_eligible(order)- end-- it 'set an error message' do- rule.eligible?(order)- expect(rule.eligibility_errors.full_messages.first).- to eq "This coupon code can't be applied to orders less than or equal to $50.00."- endendendenddiff --git a/spree/core/spec/models/spree/promotion/rules/user_spec.rb b/spree/core/spec/models/spree/promotion/rules/user_spec.rbindex 6f6dead992..46c6f429c7 100644--- a/spree/core/spec/models/spree/promotion/rules/user_spec.rb+++ b/spree/core/spec/models/spree/promotion/rules/user_spec.rb@@ -31,11 +31,6 @@ describe Spree::Promotion::Rules::User, type: :model doexpect(rule).not_to be_eligible(order)endend-- # Regression test for #3885- it 'can assign to user_ids' do- expect { rule.user_ids = "#{random_user.id}, #{user_placing_order.id}" }.not_to raise_error- endenddescribe '#add_users' dodiff --git a/spree/core/spec/models/spree/promotion_action_spec.rb b/spree/core/spec/models/spree/promotion_action_spec.rbindex 1706d6bb71..54a08d0025 100644--- a/spree/core/spec/models/spree/promotion_action_spec.rb+++ b/spree/core/spec/models/spree/promotion_action_spec.rb@@ -5,6 +5,8 @@ describe Spree::PromotionAction, type: :model doit_behaves_like 'type labels'it "forces developer to implement 'perform' method" do- expect { MyAction.new.perform }.to raise_error(NameError)+ stub_const('Spree::BadTestAction', Class.new(described_class))++ expect { Spree::BadTestAction.new.perform }.to raise_error(RuntimeError, /perform should be implemented/)endenddiff --git a/spree/core/spec/models/spree/promotion_category_spec.rb b/spree/core/spec/models/spree/promotion_category_spec.rbdeleted file mode 100644index 7796d5eda3..0000000000--- a/spree/core/spec/models/spree/promotion_category_spec.rb+++ /dev/null@@ -1,19 +0,0 @@-require 'spec_helper'--describe Spree::PromotionCategory, type: :model do- describe 'validation' do- subject { Spree::PromotionCategory.new name: name }-- let(:name) { 'Nom' }-- context 'when all required attributes are specified' do- it { is_expected.to be_valid }- end-- context 'when name is missing' do- let(:name) { nil }-- it { is_expected.not_to be_valid }- end- end-enddiff --git a/spree/core/spec/models/spree/promotion_handler/cart_spec.rb b/spree/core/spec/models/spree/promotion_handler/cart_spec.rbindex ad0f18aee9..9ded49a898 100644--- a/spree/core/spec/models/spree/promotion_handler/cart_spec.rb+++ b/spree/core/spec/models/spree/promotion_handler/cart_spec.rb@@ -11,18 +11,18 @@ module Spreelet(:promotion) { create(:promotion, name: 'At line items', store: order.store, kind: :automatic) }let(:calculator) { Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10) }+ shared_context 'creates the adjustment' do+ it 'creates the adjustment' do+ expect do+ subject.activate+ end.to change { adjustable.discounts.count }.by(1)+ end+ end+context 'activates in LineItem level' dolet!(:action) { Promotion::Actions::CreateItemAdjustments.create(promotion: promotion, calculator: calculator) }let(:adjustable) { line_item }- shared_context 'creates the adjustment' do- it 'creates the adjustment' do- expect do- subject.activate- end.to change { adjustable.discounts.count }.by(1)- end- end-context 'promotion with no rules' doinclude_context 'creates the adjustment'end@@ -34,7 +34,6 @@ module Spreeendcontext 'promotion has item total rule' do- let(:shirt) { create(:product, store: order.store) }let!(:rule) { Promotion::Rules::ItemTotal.create(preferred_operator_min: 'gt', preferred_amount_min: 50, preferred_operator_max: 'lt', preferred_amount_max: 150, promotion: promotion) }before do@@ -51,14 +50,6 @@ module Spreelet!(:action) { Promotion::Actions::CreateAdjustment.create(promotion: promotion, calculator: calculator) }let(:adjustable) { order }- shared_context 'creates the adjustment' do- it 'creates the adjustment' do- expect do- subject.activate- end.to change { adjustable.discounts.count }.by(1)- end- end-context 'promotion with no rules' dobefore do# Gives the calculator something to discount@@ -70,7 +61,6 @@ module Spreeendcontext 'promotion has item total rule' do- let(:shirt) { create(:product, store: order.store) }let!(:rule) { Promotion::Rules::ItemTotal.create(preferred_operator_min: 'gt', preferred_amount_min: 50, preferred_operator_max: 'lt', preferred_amount_max: 150, promotion: promotion) }before dodiff --git a/spree/core/spec/models/spree/promotion_handler/coupon_spec.rb b/spree/core/spec/models/spree/promotion_handler/coupon_spec.rbindex f219a36e2e..73a1e92b08 100644--- a/spree/core/spec/models/spree/promotion_handler/coupon_spec.rb+++ b/spree/core/spec/models/spree/promotion_handler/coupon_spec.rb@@ -8,46 +8,6 @@ module Spreelet(:store) { @default_store }let(:order) { double('Order', coupon_code: '10off', store: store).as_null_object }- it 'returns self in apply' do- expect(subject.apply).to be_a Coupon- end-- context 'status messages' do- let(:coupon) { Coupon.new(order) }-- describe '#set_success_code' do- subject { coupon.set_success_code status }-- let(:status) { :coupon_code_applied }-- it 'has status_code' do- subject- expect(coupon.status_code).to eq(status)- end-- it 'has success message' do- subject- expect(coupon.success).to eq(I18n.t("spree.#{status}"))- end- end-- describe '#set_error_code' do- subject { coupon.set_error_code status }-- let(:status) { :coupon_code_not_found }-- it 'has status_code' do- subject- expect(coupon.status_code).to eq(status)- end-- it 'has error message' do- subject- expect(coupon.error).to eq(I18n.t("spree.#{status}"))- end- end- end-context 'coupon code promotion doesnt exist' dobefore { create(:promotion, name: 'promo', code: nil, kind: :automatic) }@@ -90,11 +50,6 @@ module Spreeexpect(order.reload.total).to eq(100)end- it 'calls recalculate_totals!' do- expect(order).to receive(:recalculate_totals!)- subject.apply- end-it 'coupon already applied to the order' dosubject.applyexpect(subject.success).to be_present@@ -155,13 +110,6 @@ module Spreeexpect(order.fulfillment_discounts.count).to eq(1)end-- it 'coupon already applied to the order' do- subject.apply- expect(subject.success).to be_present- subject.apply- expect(subject.error).to eq I18n.t('spree.coupon_code_already_applied')- endendend@@ -183,32 +131,12 @@ module Spreeexpect(order.discounts.sum(:amount)).to eq(-10)end- it 'coupon already applied to the order' do- subject.apply- expect(subject.success).to be_present- subject.apply- expect(subject.error).to eq I18n.t('spree.coupon_code_already_applied')- end-it 'coupon fails to activate' doallow_any_instance_of(Spree::Promotion).to receive(:activate).and_return falsesubject.applyexpect(subject.error).to eq I18n.t('spree.coupon_code_unknown_error')end- it 'coupon code hit max usage' do- promotion.update_column(:usage_limit, 1)- subject.apply- expect(subject.successful?).to be true-- order_2 = create(:order, store: store)- allow(order_2).to receive_messages coupon_code: '10off'- coupon = Coupon.new(order_2)- coupon.apply- expect(coupon.successful?).to be false- expect(coupon.error).to eq I18n.t('spree.coupon_code_max_usage')- end-context 'when the a new coupon is less good' dolet!(:promotion_5) { create(:promotion, :with_order_adjustment, weighted_order_adjustment_amount: 5, name: 'promo', code: '5off') }@@ -332,13 +260,6 @@ module Spreeexpect(order.reload.total).to eq(100)end- it 'coupon already applied to the order' do- subject.apply- expect(subject.success).to be_present- subject.apply- expect(subject.error).to eq I18n.t('spree.coupon_code_already_applied')- end-context 'with used coupon code' dobefore { coupon_code.update!(state: :used) }@@ -503,31 +424,6 @@ module Spreecalculator: calculator)end- shared_examples 'allows to use coupon code one time only' do |coupon_code|- before do- order.coupon_code = coupon_code- order_2.coupon_code = coupon_code- end-- it do- subject.apply- expect(subject.successful?).to be true- # Simulate the order has been completed so the coupon code is marked as used- Spree::CouponCodes::CouponCodesHandler.new(order: order).use_all_codes-- coupon = Spree::CouponCode.find_by(code: coupon_code)- expect(coupon.state).to eq 'used'- expect(coupon.order).to eq order-- subject_2.apply- expect(subject_2.successful?).to be false- expect(subject_2.error).to eq I18n.t('spree.coupon_code_used')- end- end-- it_behaves_like 'allows to use coupon code one time only', 'first_one_time_code'- it_behaves_like 'allows to use coupon code one time only', 'second_one_time_code'-it 'promotion can be used as many times as it has coupon codes' doorder.coupon_code = 'first_one_time_code'subject.applydiff --git a/spree/core/spec/models/spree/promotion_handler/coupon_with_gift_card_spec.rb b/spree/core/spec/models/spree/promotion_handler/coupon_with_gift_card_spec.rbindex fab70dbb8b..8e3d9074e2 100644--- a/spree/core/spec/models/spree/promotion_handler/coupon_with_gift_card_spec.rb+++ b/spree/core/spec/models/spree/promotion_handler/coupon_with_gift_card_spec.rb@@ -190,16 +190,6 @@ describe Spree::PromotionHandler::Coupon, type: :model doexpect(order.reload.gift_card).to eq(gift_card)endend-- context 'when enable_gift_cards is not specified (default)' do- it 'applies gift card for backwards compatibility' do- order.coupon_code = gift_card.code- handler = described_class.new(order)- handler.apply-- expect(order.reload.gift_card).to eq(gift_card)- end- endenddescribe '#remove' do@@ -225,15 +215,6 @@ describe Spree::PromotionHandler::Coupon, type: :model doexpect(order.reload.gift_card).to be_nilendend-- context 'when enable_gift_cards is not specified (default)' do- it 'removes gift card for backwards compatibility' do- handler = described_class.new(order)- handler.remove(gift_card.code)-- expect(order.reload.gift_card).to be_nil- end- endendendenddiff --git a/spree/core/spec/models/spree/promotion_rule_spec.rb b/spree/core/spec/models/spree/promotion_rule_spec.rbindex 28fb39850c..bb2c88046a 100644--- a/spree/core/spec/models/spree/promotion_rule_spec.rb+++ b/spree/core/spec/models/spree/promotion_rule_spec.rb@@ -15,7 +15,7 @@ module Spreelet!(:promotion) { create(:promotion) }it 'forces developer to implement eligible? method' do- expect { BadTestRule.new.eligible? }.to raise_error(ArgumentError)+ expect { BadTestRule.new.eligible?(build(:order)) }.to raise_error(RuntimeError, /eligible\? should be implemented/)endit 'validates unique rules for a promotion' dodiff --git a/spree/core/spec/models/spree/promotion_spec.rb b/spree/core/spec/models/spree/promotion_spec.rbindex 6203354eca..3e712c4eae 100644--- a/spree/core/spec/models/spree/promotion_spec.rb+++ b/spree/core/spec/models/spree/promotion_spec.rb@@ -10,23 +10,6 @@ describe Spree::Promotion, type: :model dodescribe 'Validations' dolet!(:valid_promotion) { build(:promotion, name: 'A promotion', kind: :automatic) }- it 'valid_promotion is valid' do- expect(valid_promotion).to be_valid- end-- it 'validates usage limit' do- valid_promotion.usage_limit = -1- expect(valid_promotion).not_to be_valid-- valid_promotion.usage_limit = 100- expect(valid_promotion).to be_valid- end-- it 'validates name' do- valid_promotion.name = nil- expect(valid_promotion).not_to be_valid- end-it 'can create multiple promos with the same code' docreate(:promotion, code: 'ABC')valid_promotion.code = 'ABC'@@ -174,18 +157,6 @@ describe Spree::Promotion, type: :model dopromotion.save!end- it 'deletes actions' do- promotion.destroy!-- expect(Spree::PromotionAction.count).to eq(0)- end-- it 'deletes rules' do- promotion.destroy!-- expect(Spree::PromotionRule.count).to eq(0)- end-context 'if promotion was already used' doit 'does not destroy the promotion' dopromotion.orders << create(:order)@@ -240,18 +211,18 @@ describe Spree::Promotion, type: :model dopromotion = create(:promotion, code: 'ABC', multi_codes: false, kind: :coupon_code)promotion.kind = :automatic- promotion.save+ promotion.save!- expect(promotion.kind).to eq 'automatic'+ expect(promotion.reload.kind).to eq 'automatic'endit 'allows to change promotion type from multiple discount codes to automatic' dopromotion = create(:promotion, multi_codes: true, number_of_codes: 10, kind: :coupon_code)promotion.kind = :automatic- promotion.save+ promotion.save!- expect(promotion.kind).to eq 'automatic'+ expect(promotion.reload.kind).to eq 'automatic'endend@@ -359,12 +330,6 @@ describe Spree::Promotion, type: :model dopromotion.expires_at = Time.current + 1.dayexpect(promotion).not_to be_expiredend-- it 'is not expired if usage limit is not exceeded' do- promotion.usage_limit = 2- allow(promotion).to receive_messages(credits_count: 1)- expect(promotion).not_to be_expired- endendcontext '#credits_count' do@@ -907,12 +872,6 @@ describe Spree::Promotion, type: :model doexpect(promotion.code).not_to eq 'spree123'endend-- context 'without generate_code' do- it 'has a generated code' do- expect(promotion.code).to eq 'spree123'- end- endenddescribe '#generate_coupon_codes' do@@ -1040,7 +999,7 @@ describe Spree::Promotion, type: :model dorule = promotion.rules.firstexpect(rule).to be_a(Spree::Promotion::Rules::Category)- expect(rule.taxons).to contain_exactly(category)+ expect(rule.categories).to contain_exactly(category)end# Regression: `category_ids=` on Rules::Taxon is a custom setter (not a@@ -1054,7 +1013,7 @@ describe Spree::Promotion, type: :model dorule = fresh.reload.rules.firstexpect(rule).to be_a(Spree::Promotion::Rules::Category)- expect(rule.taxons).to contain_exactly(category)+ expect(rule.categories).to contain_exactly(category)endit 'defers application until after_save on a new promotion record' dodiff --git a/spree/core/spec/models/spree/promotion_tax_recalculation_spec.rb b/spree/core/spec/models/spree/promotion_tax_recalculation_spec.rbindex b89fa1f1b6..b6f4c375f2 100644--- a/spree/core/spec/models/spree/promotion_tax_recalculation_spec.rb+++ b/spree/core/spec/models/spree/promotion_tax_recalculation_spec.rb@@ -16,7 +16,7 @@ describe 'Promotion discounts and the taxable basis', type: :model do# Lazy on purpose: the tax rate must exist before the line item is created,# because Spree only creates tax adjustments from LineItem#update_tax_charge.# Each tax-mode context forces it in a before hook after its tax rate.- let(:line_item) { create(:line_item, order: order, variant: product.master, price: item_price, quantity: 1) }+ let(:line_item) { create(:line_item, order: order, variant: product.default_variant, price: item_price, quantity: 1) }def build_cart!line_item@@ -85,7 +85,7 @@ describe 'Promotion discounts and the taxable basis', type: :model doit 'computes tax on the discounted amount' doapply_coupon!- expect(order.promo_total).to eq(-125.00)+ expect(order.discount_total).to eq(-125.00)expect(order.additional_tax_total).to eq(12.50)expect(order.total).to eq(137.50)end@@ -97,7 +97,7 @@ describe 'Promotion discounts and the taxable basis', type: :model doit 'computes tax on the discounted amount' doapply_coupon!- expect(order.promo_total).to eq(-50.00)+ expect(order.discount_total).to eq(-50.00)expect(order.additional_tax_total).to eq(20.00)expect(order.total).to eq(220.00)end@@ -109,7 +109,7 @@ describe 'Promotion discounts and the taxable basis', type: :model doit 'computes tax on the discounted amount' doapply_coupon!- expect(order.promo_total).to eq(-125.00)+ expect(order.discount_total).to eq(-125.00)expect(order.additional_tax_total).to eq(12.50)expect(order.total).to eq(137.50)end@@ -129,7 +129,7 @@ describe 'Promotion discounts and the taxable basis', type: :model doit 'computes tax on the discounted amount' doapply_coupon!- expect(order.promo_total).to eq(-50.00)+ expect(order.discount_total).to eq(-50.00)expect(order.additional_tax_total).to eq(20.00)expect(order.total).to eq(220.00)end@@ -138,7 +138,7 @@ describe 'Promotion discounts and the taxable basis', type: :model docontext 'with a whole-order promotion and several line items' dolet(:other_product) { create(:product, price: 150, tax_category: tax_category, store: store) }let!(:other_line_item) do- create(:line_item, order: order, variant: other_product.master, price: 150, quantity: 1)+ create(:line_item, order: order, variant: other_product.default_variant, price: 150, quantity: 1)endlet!(:promotion) { whole_order_promotion(flat_calculator(80)) }@@ -173,7 +173,7 @@ describe 'Promotion discounts and the taxable basis', type: :model doit 'reports VAT on the discounted amount' doapply_coupon!- expect(order.promo_total).to eq(-175.00)+ expect(order.discount_total).to eq(-175.00)expect(order.included_tax_total).to eq(29.17)expect(order.total).to eq(175.00)end@@ -193,7 +193,7 @@ describe 'Promotion discounts and the taxable basis', type: :model doit 'reports VAT on the discounted amount' doapply_coupon!- expect(order.promo_total).to eq(-50.00)+ expect(order.discount_total).to eq(-50.00)expect(order.included_tax_total).to eq(50.00)expect(order.total).to eq(300.00)end@@ -205,7 +205,7 @@ describe 'Promotion discounts and the taxable basis', type: :model doit 'reports VAT on the discounted amount' doapply_coupon!- expect(order.promo_total).to eq(-175.00)+ expect(order.discount_total).to eq(-175.00)expect(order.included_tax_total).to eq(29.17)expect(order.total).to eq(175.00)end@@ -225,7 +225,7 @@ describe 'Promotion discounts and the taxable basis', type: :model doit 'reports VAT on the discounted amount' doapply_coupon!- expect(order.promo_total).to eq(-50.00)+ expect(order.discount_total).to eq(-50.00)expect(order.included_tax_total).to eq(50.00)expect(order.total).to eq(300.00)end@@ -239,7 +239,7 @@ describe 'Promotion discounts and the taxable basis', type: :model doSpree::PromotionHandler::Coupon.new(order).remove('DISCOUNT')order.reload- expect(order.promo_total).to eq(0)+ expect(order.discount_total).to eq(0)expect(order.included_tax_total).to eq(58.33)expect(order.total).to eq(350.00)enddiff --git a/spree/core/spec/models/spree/purchase/freight_spec.rb b/spree/core/spec/models/spree/purchase/freight_spec.rbindex 0d4790cf40..cc255b05b9 100644--- a/spree/core/spec/models/spree/purchase/freight_spec.rb+++ b/spree/core/spec/models/spree/purchase/freight_spec.rb@@ -23,13 +23,6 @@ RSpec.describe Spree::Purchase::Freight dometadata: { 'freight_summary' => snapshot })end- it 'reads what the selected freight rate froze' do- create(:line_item, cart: cart, order: nil, variant: variant, quantity: 24)- select_freight_rate(cart, snapshot)-- expect(cart.reload.freight_summary.total_cartons).to eq(2)- end-# Items with carton data are not a freight shipment until a freight rate# says so — a retail basket of measured goods reports nothing.it 'has none before a freight rate is selected' dodiff --git a/spree/core/spec/models/spree/refresh_token_spec.rb b/spree/core/spec/models/spree/refresh_token_spec.rbindex 252eaf4e86..39c743b361 100644--- a/spree/core/spec/models/spree/refresh_token_spec.rb+++ b/spree/core/spec/models/spree/refresh_token_spec.rb@@ -4,25 +4,6 @@ RSpec.describe Spree::RefreshToken, type: :model dolet(:user) { create(:user) }describe 'validations' do- it 'requires a user' do- token = described_class.new(expires_at: 30.days.from_now)- token.valid?- expect(token.errors[:user]).to be_present- end-- it 'requires expires_at' do- token = described_class.new(user: user)- # has_secure_token generates token automatically- token.valid?- expect(token.errors[:expires_at]).to be_present- end-- it 'auto-generates a token via has_secure_token' do- token = described_class.create!(user: user, audience: 'store_api', expires_at: 30.days.from_now)- expect(token.token).to be_present- expect(token.token.length).to be >= 24- end-it 'requires an audience on create' dotoken = described_class.new(user: user, expires_at: 30.days.from_now)@@ -83,29 +64,16 @@ RSpec.describe Spree::RefreshToken, type: :model dodescribe '#rotate!' dolet!(:original_token) { described_class.create_for(user, audience: 'store_api') }- it 'destroys the original token' do- original_id = original_token.id- original_token.rotate!- expect(described_class.find_by(id: original_id)).to be_nil- end+ it 'replaces the original token with a new one for the same user' do+ new_token = nil+ expect { new_token = original_token.rotate! }.not_to change(described_class, :count)- it 'creates a new token' do- new_token = original_token.rotate!+ expect(described_class.find_by(id: original_token.id)).to be_nilexpect(new_token).to be_persistedexpect(new_token.token).not_to eq(original_token.token)- end-- it 'preserves the user' do- new_token = original_token.rotate!expect(new_token.user).to eq(user)end- it 'keeps total count the same' do- expect {- original_token.rotate!- }.not_to change(described_class, :count)- end-it 'accepts new request env' donew_token = original_token.rotate!(request_env: {ip_address: '10.0.0.1',@@ -172,11 +140,4 @@ RSpec.describe Spree::RefreshToken, type: :model doexpect(described_class.find_by(id: expired.id)).to be_nilendend-- describe 'prefixed_id' do- it 'uses rt_ prefix' do- token = described_class.create_for(user, audience: 'store_api')- expect(token.prefixed_id).to start_with('rt_')- end- endenddiff --git a/spree/core/spec/models/spree/return_spec.rb b/spree/core/spec/models/spree/return_spec.rbindex 126ca3ac8c..dda9df0401 100644--- a/spree/core/spec/models/spree/return_spec.rb+++ b/spree/core/spec/models/spree/return_spec.rb@@ -7,10 +7,6 @@ RSpec.describe Spree::Return doexpect(create(:return, store: store).number).to start_with('RET')end- it 'starts as requested' do- expect(create(:return, store: store)).to be_requested- end-it 'requires at least one line item on create' doorder = create(:shipped_order, store: store)record = described_class.new(@@ -24,12 +20,6 @@ RSpec.describe Spree::Return doexpect(record.errors[:return_line_items]).to be_presentend- it 'is reachable from its order' do- return_record = create(:return, store: store)-- expect(return_record.order.reload.returns).to include(return_record)- end-describe 'totals' dolet(:return_record) { create(:return, store: store) }@@ -141,10 +131,6 @@ RSpec.describe Spree::Return doexpect(line).not_to be_validend- it 'starts with nothing received' do- expect(line.received_quantity).to eq(0)- end-# Nothing has been counted yet, so what the customer announced is the only# measure of what the return will cost.it 'is owed the announced amount until the warehouse has counted' dodiff --git a/spree/core/spec/models/spree/role_spec.rb b/spree/core/spec/models/spree/role_spec.rbindex 56ccb7af43..83057b85f0 100644--- a/spree/core/spec/models/spree/role_spec.rb+++ b/spree/core/spec/models/spree/role_spec.rb@@ -7,16 +7,6 @@ describe Spree::Role do# lands: what matters is that the role is owned by something else.let(:seller_like) { create(:customer_group) }- describe 'with users' do- before do- user.spree_roles << role- end-- it 'can access users through the polymorphic association' do- expect(role.users).to include(user)- end- end-describe '.default_admin_role' doit 'returns the admin role, seeded immutable' doadmin_role = Spree::Role.default_admin_role(@default_store)@@ -36,6 +26,9 @@ describe Spree::Role doexpect(admin_role).to be_staffexpect(foreign_admin).not_to be_adminexpect(foreign_admin).to be_mutable++ foreign_admin.name = 'renamed'+ expect(foreign_admin).to be_validend# "admin" means everything in *this* store, so it cannot be one shared row.@@ -84,10 +77,6 @@ describe Spree::Role doexpect(build(:role, resource: seller_like)).not_to be_staffend- it 'is required' do- expect(build(:role, resource: nil)).not_to be_valid- end-it 'cannot be changed once the role exists' dorole = create(:role)role.resource = create(:store)@@ -103,12 +92,6 @@ describe Spree::Role doexpect(build(:role, name: 'Manager', resource: create(:store))).to be_validend- it 'still rejects a duplicate name under one owner' do- create(:role, name: 'Manager', resource: seller_like)-- expect(build(:role, name: 'Manager', resource: seller_like)).not_to be_valid- end-it 'scopes roles to their owner' dostaff_role = create(:role)other_role = create(:role, resource: seller_like)@@ -162,10 +145,6 @@ describe Spree::Role dodescribe 'admin role protection' dolet(:admin_role) { Spree::Role.default_admin_role }- it 'is not mutable' do- expect(admin_role.mutable?).to be false- end-it 'cannot be renamed' doadmin_role.name = 'renamed'@@ -179,16 +158,6 @@ describe Spree::Role doexpect(admin_role).not_to be_validend- # The protection is the store's super-role, not the name: another resource- # may call a role "admin" and it stays an ordinary, editable role.- it 'leaves a same-named role owned by something else editable' do- foreign_admin = create(:role, name: 'admin', resource: seller_like)- foreign_admin.name = 'renamed'-- expect(foreign_admin).to be_mutable- expect(foreign_admin).to be_valid- end-it 'cannot be destroyed' doexpect(admin_role.destroy).to be falseexpect(admin_role.errors[:base]).to be_present@@ -254,9 +223,5 @@ describe Spree::Role doexpect(role.can_be_deleted?).to be falseend-- it 'is false for the admin role' do- expect(Spree::Role.default_admin_role.can_be_deleted?).to be false- endendenddiff --git a/spree/core/spec/models/spree/role_user_spec.rb b/spree/core/spec/models/spree/role_user_spec.rbindex e1338d3130..5e5c5b161d 100644--- a/spree/core/spec/models/spree/role_user_spec.rb+++ b/spree/core/spec/models/spree/role_user_spec.rb@@ -16,8 +16,6 @@ describe Spree::RoleUser dospree_role_user = described_class.create!(role: role, user: spree_user)admin_role_user = described_class.create!(role: role, user: admin_user)- expect(spree_user).not_to eq(admin_user)-expect(spree_role_user.user).to eq(spree_user)expect(spree_role_user.user_type).to eq(spree_user.class.to_s)@@ -37,25 +35,12 @@ describe Spree::RoleUser doenddescribe 'uniqueness' do- it 'allows a user to hold a role once' do- create(:role_user, role: role, user: spree_user)-- expect(described_class.new(role: role, user: spree_user)).not_to be_valid- end-- it 'allows the same user to hold a role owned by another resource' do+ it 'allows a user to hold a role once, but the same-named role of another resource too' docreate(:role_user, role: role, user: spree_user)other_role = create(:role, name: 'test_role', resource: create(:store))+ expect(described_class.new(role: role, user: spree_user)).not_to be_validexpect(described_class.new(role: other_role, user: spree_user)).to be_validendend-- describe '#name' do- it 'returns the name of the user' do- role_user = described_class.new(role: role, user: spree_user)-- expect(role_user.name).to eq(spree_user.name)- end- endenddiff --git a/spree/core/spec/models/spree/search_provider/base_spec.rb b/spree/core/spec/models/spree/search_provider/base_spec.rbindex 58eee95ad9..0f7fd7db07 100644--- a/spree/core/spec/models/spree/search_provider/base_spec.rb+++ b/spree/core/spec/models/spree/search_provider/base_spec.rb@@ -5,40 +5,10 @@ module Spreelet(:store) { @default_store }let(:provider) { described_class.new(store) }- describe '#initialize' do- it 'stores the store' do- expect(provider.store).to eq(store)- end- end-describe '#search_and_filter' doit 'raises NotImplementedError' doexpect { provider.search_and_filter(scope: Spree::Product.all) }.to raise_error(NotImplementedError)endend-- describe '#index' do- it 'is a no-op by default' do- expect { provider.index(build(:product)) }.not_to raise_error- end- end-- describe '#remove' do- it 'is a no-op by default' do- expect { provider.remove(build(:product)) }.not_to raise_error- end- end-- describe '#remove_by_id' do- it 'is a no-op by default' do- expect { provider.remove_by_id(1) }.not_to raise_error- end- end-- describe '#reindex' do- it 'is a no-op by default' do- expect { provider.reindex }.not_to raise_error- end- endendenddiff --git a/spree/core/spec/models/spree/search_provider/database_spec.rb b/spree/core/spec/models/spree/search_provider/database_spec.rbindex c8113d2871..d971521c9f 100644--- a/spree/core/spec/models/spree/search_provider/database_spec.rb+++ b/spree/core/spec/models/spree/search_provider/database_spec.rb@@ -5,9 +5,9 @@ module Spreelet(:store) { @default_store }let(:provider) { described_class.new(store) }- let!(:product_1) { create(:product, name: 'Blue Shirt') }- let!(:product_2) { create(:product, name: 'Red Pants') }- let!(:product_3) { create(:product, name: 'Blue Jacket') }+ let!(:product_1) { create(:product, name: 'Blue Shirt', price: 30) }+ let!(:product_2) { create(:product, name: 'Red Pants', price: 10) }+ let!(:product_3) { create(:product, name: 'Blue Jacket', price: 20) }describe '#search_and_filter' dolet(:scope) { store.products }@@ -94,8 +94,8 @@ module Spreecontext 'with custom price sort' dosubject(:result) { provider.search_and_filter(scope: scope, sort: 'price') }- it 'returns all products' do- expect(result.total_count).to eq(3)+ it 'sorts by price ascending' do+ expect(result.products.to_a).to eq([product_2, product_3, product_1])endend@@ -490,30 +490,5 @@ module Spreeendendend-- describe '#index' do- it 'is a no-op' do- expect { provider.index(product_1) }.not_to raise_error- end- end-- describe '#remove' do- it 'is a no-op' do- expect { provider.remove(product_1) }.not_to raise_error- end- end-- describe '#remove_by_id' do- it 'is a no-op' do- expect { provider.remove_by_id(product_1.id) }.not_to raise_error- end- end-- describe '#reindex' do- it 'is a no-op' do- expect { provider.reindex(store.products) }.not_to raise_error- end- end-endenddiff --git a/spree/core/spec/models/spree/seller_spec.rb b/spree/core/spec/models/spree/seller_spec.rbindex e912c17dda..fe4b059b0b 100644--- a/spree/core/spec/models/spree/seller_spec.rb+++ b/spree/core/spec/models/spree/seller_spec.rb@@ -3,27 +3,6 @@ require 'spec_helper'describe Spree::Seller dolet(:store) { @default_store }- describe 'statuses' do- it 'starts pending and moves only through workflows' do- expect(described_class.default_status).to eq('pending')- expect(described_class.statuses).to include('approved', 'suspended', 'rejected')- # A state machine would have generated these; the absence is the point.- expect(described_class).not_to respond_to(:state_machines)- end-- it 'generates a predicate and a scope per status' do- seller = create(:seller, :approved)-- expect(seller).to be_approved- expect(seller).not_to be_pending- expect(described_class.approved).to include(seller)- end-- it 'rejects an unknown status' do- expect(build(:seller, status: 'flourishing')).not_to be_valid- end- end-describe 'slug' doit 'derives from the name when absent' doexpect(create(:seller, name: 'Bright Sparks Ltd').slug).to eq('bright-sparks-ltd')@@ -33,15 +12,10 @@ describe Spree::Seller doexpect(create(:seller, name: 'Bright Sparks', slug: 'sparks').slug).to eq('sparks')end- it 'is unique within a store' do+ it 'is unique within a store but may repeat on another' docreate(:seller, slug: 'sparks', store: store)expect(build(:seller, slug: 'sparks', store: store)).not_to be_valid- end-- it 'may repeat on another store' do- create(:seller, slug: 'sparks', store: store)-expect(build(:seller, slug: 'sparks', store: create(:store))).to be_validendend@@ -182,9 +156,7 @@ describe Spree::Seller doenddescribe 'settlement configuration' do- it 'defaults to the seller remitting its own tax' do- expect(create(:seller).tax_remittance).to eq('seller')- end+ let(:seller) { create(:seller, :approved, store: store) }it 'rejects an unknown remittance or interval' doexpect(build(:seller, tax_remittance: 'someone_else')).not_to be_valid@@ -195,6 +167,18 @@ describe Spree::Seller doit 'allows both to be unset' doexpect(build(:seller, payouts_schedule_interval: nil, minimum_payout_amount: nil)).to be_validend++ it 'falls back to the store’s schedule and threshold' do+ expect(seller.resolved_payouts_schedule_interval).to eq('monthly')+ expect(seller.resolved_minimum_payout_amount).to eq(0)+ end++ it 'prefers its own once it deviates' do+ seller.update!(payouts_schedule_interval: 'weekly', minimum_payout_amount: 25)++ expect(seller.resolved_payouts_schedule_interval).to eq('weekly')+ expect(seller.resolved_minimum_payout_amount).to eq(25)+ endenddescribe 'addresses' do@@ -271,7 +255,6 @@ describe Spree::Seller doenddescribe 'onboarding progress' do- let(:store) { @default_store }let(:seller) { create(:seller, :onboarding, store: store) }before { store.seller_requirements.destroy_all }@@ -349,7 +332,6 @@ describe Spree::Seller doenddescribe '#balance' do- let(:store) { @default_store }let(:seller) { create(:seller, :approved, store: store) }def earn(amount, currency: 'USD', status: 'completed')@@ -424,22 +406,6 @@ describe Spree::Seller doendend- describe 'settlement configuration' do- let(:store) { @default_store }- let(:seller) { create(:seller, :approved, store: store) }-- it 'falls back to the store’s schedule and threshold' do- expect(seller.resolved_payouts_schedule_interval).to eq('monthly')- expect(seller.resolved_minimum_payout_amount).to eq(0)- end-- it 'prefers its own once it deviates' do- seller.update!(payouts_schedule_interval: 'weekly', minimum_payout_amount: 25)-- expect(seller.resolved_payouts_schedule_interval).to eq('weekly')- expect(seller.resolved_minimum_payout_amount).to eq(25)- end- end# The seller's identity in the system that pays them — recorded where every# other external identity is, rather than in a column of its own.describe 'the payout account' dodiff --git a/spree/core/spec/models/spree/shipment_spec.rb b/spree/core/spec/models/spree/shipment_spec.rbindex 3395b38f48..4a8747e823 100644--- a/spree/core/spec/models/spree/shipment_spec.rb+++ b/spree/core/spec/models/spree/shipment_spec.rb@@ -18,22 +18,10 @@ describe Spree::Fulfillment, type: :model dobefore doallow(order).to receive_messages(backordered?: false, canceled?: false, can_ship?: true, paid?: false, touch_later: false)- allow(inventory_units.first).to receive_messages backordered?: false- allow(inventory_units.first).to receive_messages backordered?: trueendit_behaves_like 'metadata'- describe 'precision of pre_tax_amount' do- before { line_item.update(pre_tax_amount: 4.2051) }-- it 'keeps four digits of precision even when reloading' do- # prevent it from updating pre_tax_amount- allow_any_instance_of(Spree::LineItem).to receive(:update_tax_charge)- expect(line_item.reload.pre_tax_amount).to eq(4.2051)- end- end-describe '#digital?' doit 'returns true if the delivery method is digital' doshipment.delivery_method.fulfillment_provider = 'Spree::FulfillmentProvider::Digital'@@ -59,20 +47,6 @@ describe Spree::Fulfillment, type: :model doendend- describe '#tracked?' do- it 'returns true if the shipment is tracked' do- expect(shipment.tracked?).to eq(true)- end-- context 'when the shipment is not tracked' do- let(:shipment) { build(:fulfillment, number: nil, tracking: nil) }-- it 'returns false' do- expect(shipment.tracked?).to eq(false)- end- end- end-describe '#partial?' dosubject { shipment.partial? }@@ -94,34 +68,13 @@ describe Spree::Fulfillment, type: :model doendend- # Regression test for #4063- context 'number generation' do- let(:shipment) { create(:fulfillment, stock_location: create(:stock_location)) }-- before do- allow(order).to receive :recalculate_totals!- end-- it 'derives the number from the order it belongs to' do- expect(shipment.number).to eq("#{shipment.order.number}-F1")- end- end-it 'is backordered if one if its inventory_units is backordered' do+ allow(inventory_units.first).to receive_messages backordered?: trueallow(shipment).to receive_messages(fulfillment_items: inventory_units)expect(shipment).to be_backorderedenddescribe 'status' do- it 'starts unfulfilled' do- expect(create(:fulfillment).status).to eq('unfulfilled')- end-- it 'rejects a status outside the vocabulary' do- shipment.status = 'ready'- expect(shipment).not_to be_valid- end-# The payment-derived pending/ready split is gone: whether the order is# paid is asked when someone tries to hand the goods over, not baked into# the fulfillment's own status where a refund could move it backwards.@@ -204,11 +157,6 @@ describe Spree::Fulfillment, type: :model doexpect(shipment.tracking_url).to be_nilexpect(shipment).not_to be_trackedend-- it 'has no carrier axis of its own' do- expect(shipment).not_to respond_to(:tracking_status)- expect(shipment).not_to respond_to(:tracking_carrier)- endendcontext 'display_amount' do@@ -529,10 +477,10 @@ describe Spree::Fulfillment, type: :model do]end- it 'returns shipping_method from selected shipping_rate' do+ it 'returns the delivery method from the selected rate' doshipment.shipping_rates.delete_allshipment.shipping_rates.create shipping_method: shipping_method1, cost: 10.00, selected: true- expect(shipment.shipping_method).to eq shipping_method1+ expect(shipment.delivery_method).to eq shipping_method1endcontext 'carry_over_selection' do@@ -666,11 +614,6 @@ describe Spree::Fulfillment, type: :model doexpect { shipment.update!(order) }.not_to change { shipment.reload.status }end-- it 'still writes attributes through ActiveRecord' do- shipment.update!(tracking: 'XYZ')- expect(shipment.reload.tracking).to eq('XYZ')- endendcontext 'when order is completed' do@@ -701,16 +644,6 @@ describe Spree::Fulfillment, type: :model dodescribe '#cancel' dolet(:inventory_unit) { create(:fulfillment_item, state: 'on_hand', line_item: line_item, variant: variant, quantity: 1) }- # Restocking is no longer a transition callback — it belongs to- # Spree::Fulfillments::Cancel, so the event only moves the status.- it 'cancels the shipment' do- allow(shipment.order).to receive(:recalculate_totals!)-- shipment.status = 'unfulfilled'- described_class.transaction { shipment.update!(status: 'canceled') }- expect(shipment.status).to eq 'canceled'- end-# Withdrawing the promise belongs to Spree::Fulfillments::Cancel now; the# deprecated shell is all that survives on the model. Covered by# spec/workflows/spree/fulfillments/cancel_spec.rb.@@ -721,6 +654,7 @@ describe Spree::Fulfillment, type: :model doallow(shipment).to receive(:allocated_quantities).and_return(variant.id => 1)shipment.stock_location = create(:stock_location)expect(shipment.stock_location).to receive(:release).with(variant, 1, shipment)+ expect(Spree::Deprecation).to receive(:warn).with(/after_cancel is deprecated/)shipment.after_cancelend@@ -729,7 +663,7 @@ describe Spree::Fulfillment, type: :model doallow(shipment).to receive(:provider).and_return(instance_double(Spree::FulfillmentProvider::Manual, cancel_fulfillment: true))shipment.stock_location = create(:stock_location)expect(shipment.stock_location).not_to receive(:release)- shipment.after_cancel+ Spree::Deprecation.silence { shipment.after_cancel }endcontext 'with backordered inventory units' do@@ -741,7 +675,7 @@ describe Spree::Fulfillment, type: :model doSpree::Orders::AddItem.call(order: order, variant: variant)order.rebuild_fulfillments!- Spree::Carts::AddItem.call(order: other_order, variant: variant)+ Spree::Orders::AddItem.call(order: other_order, variant: variant)other_order.rebuild_fulfillments!end@@ -762,24 +696,6 @@ describe Spree::Fulfillment, type: :model doenddescribe '#ship' do- context 'when the shipment is canceled' do- let(:shipment_with_inventory_units) { create(:fulfillment, order: create(:order_with_line_items), state: 'canceled') }- let(:subject) { shipment_with_inventory_units.update!(status: 'fulfilled') }-- before do- allow(order).to receive(:recalculate_totals!)- allow(shipment_with_inventory_units).to receive_messages(require_inventory: false, update_order: true)- end-- # Taking the units back off the shelf moved to- # Spree::Fulfillments::Fulfill, so the bare transition no longer does it.- # See spec/workflows/spree/fulfillments/fulfill_spec.rb for the behavior.- it 'does not unstock on the bare transition' do- expect(shipment_with_inventory_units.stock_location).not_to receive(:unstock)- subject- end- end-context 'from unfulfilled' dolet(:paid_order) { create(:order_ready_to_ship) }let(:fulfillment) { paid_order.fulfillments.first }@@ -863,14 +779,14 @@ describe Spree::Fulfillment, type: :model doendit 'updates order totals when a different shipping rate is selected' do- expect(order.shipment_total).to eq(10)+ expect(order.delivery_total).to eq(10)# Select the more expensive shipping rateshipping_rate_2 = shipment.shipping_rates.find_by(shipping_method: shipping_method_2)shipment.selected_shipping_rate_id = shipping_rate_2.idorder.reload- expect(order.shipment_total).to eq(20)+ expect(order.delivery_total).to eq(20)endit 'updates the shipment cost to match the selected shipping rate' do@@ -993,20 +909,6 @@ describe Spree::Fulfillment, type: :model doendend- context 'currency' do- it 'returns the order currency' do- expect(shipment.currency).to eq(order.currency)- end- end-- context 'nil costs' do- it 'sets cost to 0' do- shipment = Spree::Fulfillment.new- shipment.valid?- expect(shipment.cost).to eq 0- end- end-# Legacy writer — removed in 6.1. Host code assigning tracking the old way# still lands it where every reader looks.describe '#tracking= (deprecated)' do@@ -1038,7 +940,7 @@ describe Spree::Fulfillment, type: :model dobefore doperform_enqueued_jobs(only: Spree::StockLocations::StockLevels::CreateJob)- shipping_method = order.fulfillments.first.shipping_method+ shipping_method = order.fulfillments.first.delivery_methodshipping_method.calculator.preferences[:amount] = order.fulfillments.first.costshipping_method.calculator.save!end@@ -1068,12 +970,12 @@ describe Spree::Fulfillment, type: :model doexpect(new_shipment.cost).to eq(shipment.cost)end- it 'updates `order.shipment_total` to the sum of shipments cost' do+ it 'updates `order.delivery_total` to the sum of shipments cost' doshipment = order.fulfillments.firstshipment.transfer_to_location(variant, 1, shipment.stock_location)order.reload- expect(order.shipment_total).to eq(order.shipments.sum(&:cost))+ expect(order.delivery_total).to eq(order.shipments.sum(&:cost))endend@@ -1103,14 +1005,6 @@ describe Spree::Fulfillment, type: :model doendend- # Regression test for #3349- describe '#destroy' do- it 'destroys linked delivery_rates' do- reflection = Spree::Fulfillment.reflect_on_association(:delivery_rates)- expect(reflection.options[:dependent]).to be(:delete_all)- end- end-describe '.unfulfilled' dosubject { described_class.unfulfilled }@@ -1157,12 +1051,11 @@ describe Spree::Fulfillment, type: :model doendend# The deprecated writer runs after commit, so it cannot write a second- # record from inside this one's callback chain — and a number it cannot- # place is raised rather than dropped.+ # record from inside this one's callback chain.describe 'the deprecated tracking writer under conflict' dobefore { allow(Spree::Deprecation).to receive(:warn) }- it 'raises when the number is already on the parcel' do+ it 'accepts a number another parcel already carries' doshipment.deliveries.destroy_allcreate(:delivery, owner: shipment, tracking_number: 'TAKEN-1')second = create(:fulfillment, order: shipment.order, tracking: nil)diff --git a/spree/core/spec/models/spree/shipping_calculator_spec.rb b/spree/core/spec/models/spree/shipping_calculator_spec.rbindex c21c5edc68..8b18b3dd1a 100644--- a/spree/core/spec/models/spree/shipping_calculator_spec.rb+++ b/spree/core/spec/models/spree/shipping_calculator_spec.rb@@ -41,10 +41,6 @@ module Spreeend.to raise_error(NotImplementedError)end- it 'checks availability for a package' do- expect(subject.available?(package)).to be true- end-it 'calculates totals for content_items' doexpect(subject.send(:total, package.contents)).to eq 40.00enddiff --git a/spree/core/spec/models/spree/stock/content_item_spec.rb b/spree/core/spec/models/spree/stock/content_item_spec.rbdeleted file mode 100644index e0d1572ab1..0000000000--- a/spree/core/spec/models/spree/stock/content_item_spec.rb+++ /dev/null@@ -1,26 +0,0 @@-require 'spec_helper'--describe Spree::Stock::ContentItem, type: :model do- subject { described_class.new(inventory_unit) }-- let(:inventory_unit) { create(:fulfillment_item, variant: variant) }- let(:variant) { create(:variant, weight: 25.0) }-- context '#volume' do- it 'calculate the total volume of the variant' do- expect(subject.volume).to eq variant.volume * subject.quantity- end- end-- context '#dimension' do- it 'calculate the total dimension of the variant' do- expect(subject.dimension).to eq variant.dimension * subject.quantity- end- end-- context '#amount' do- it "calculates the amount based on line_item's price" do- expect(subject.amount).to eq(inventory_unit.line_item.price * inventory_unit.quantity)- end- end-enddiff --git a/spree/core/spec/models/spree/stock/coordinator_spec.rb b/spree/core/spec/models/spree/stock/coordinator_spec.rbindex c558649875..8223796317 100644--- a/spree/core/spec/models/spree/stock/coordinator_spec.rb+++ b/spree/core/spec/models/spree/stock/coordinator_spec.rb@@ -150,20 +150,25 @@ module Spreeendend- describe '#shipments' do+ describe '#fulfillments' dolet(:packages) { [build(:stock_package_fulfilled), build(:stock_package_fulfilled)] }before { allow(subject).to receive(:packages).and_return(packages) }- it 'turns packages into shipments' do- shipments = subject.shipments- expect(shipments.count).to eq packages.count- expect(shipments).to all(be_a(Fulfillment))+ it 'turns packages into fulfillments' do+ fulfillments = subject.fulfillments+ expect(fulfillments.count).to eq packages.count+ expect(fulfillments).to all(be_a(Fulfillment))end- it "puts the order's ship address on the shipments" do- shipments = subject.shipments- shipments.each { |shipment| expect(shipment.address).to eq order.ship_address }+ it "puts the order's ship address on the fulfillments" do+ fulfillments = subject.fulfillments+ fulfillments.each { |fulfillment| expect(fulfillment.address).to eq order.ship_address }+ end++ it 'is still returned by the deprecated #shipments' do+ expect(Spree::Deprecation).to receive(:warn).with(/Coordinator#shipments is deprecated/)+ expect(subject.shipments.count).to eq packages.countendenddiff --git a/spree/core/spec/models/spree/stock/estimator_spec.rb b/spree/core/spec/models/spree/stock/estimator_spec.rbindex 5cb3d09491..1c629712e6 100644--- a/spree/core/spec/models/spree/stock/estimator_spec.rb+++ b/spree/core/spec/models/spree/stock/estimator_spec.rb@@ -171,10 +171,6 @@ module Spreeit_behaves_like 'shipping rate matches'end- context "when the current matches the order's currency" do- it_behaves_like 'shipping rate matches'- end-context "if the currency is different than the order's currency" dolet(:currency) { 'GBP' }@@ -210,7 +206,7 @@ module Spreeallow(subject).to receive(:delivery_methods).and_return(shipping_methods)- subject.delivery_rates(package)+ expect(subject.delivery_rates(package).map { |rate| [rate.cost, rate.selected] }).to eq [[1.00, true]]endend@@ -242,7 +238,7 @@ module Spreesm.tax_category_id = tax_rate.tax_category_idsm.saveend- package.shipping_methods.map(&:reload)+ package.eligible_delivery_methods.map(&:reload)endit 'links the shipping rate and the tax rate' dodiff --git a/spree/core/spec/models/spree/stock/package_spec.rb b/spree/core/spec/models/spree/stock/package_spec.rbindex 069c6af0c8..b1a1eb7fc0 100644--- a/spree/core/spec/models/spree/stock/package_spec.rb+++ b/spree/core/spec/models/spree/stock/package_spec.rb@@ -96,14 +96,6 @@ module Spreeexpect(subject.freight_summary.total_units).to eq(1)end- it 'applies the tare once per package, not per item' do- create(:package_type, store: order.store, default: true, weight: 2.5, weight_unit: 'lb')-- subject.add build_inventory_unit-- expect(subject.weight).to eq(27.5)- end-# A merchant may record a carton in centimetres while the store quotes# in pounds and inches. Handing the raw numbers to a carrier reads# centimetres as inches — a 2.54x overstatement on every axis.@@ -198,17 +190,12 @@ module Spreeendend- it 'filters by on_hand and backordered' do+ it 'filters and counts by state' do4.times { subject.add build_inventory_unit }3.times { subject.add build_inventory_unit, :backordered }+expect(subject.on_hand.count).to eq 4expect(subject.backordered.count).to eq 3- end-- it 'calculates the quantity by state' do- 4.times { subject.add build_inventory_unit }- 3.times { subject.add build_inventory_unit, :backordered }-expect(subject.quantity).to eq 7expect(subject.quantity(:on_hand)).to eq 4expect(subject.quantity(:backordered)).to eq 3@@ -286,10 +273,6 @@ module Spreeit 'allows adding with a state' doexpect { subject.add_multiple [build_inventory_unit, build_inventory_unit], :backordered }.to change { subject.backordered.count }.by(2)end-- it 'defaults to adding with the on hand state' do- expect { subject.add_multiple [build_inventory_unit, build_inventory_unit] }.to change { subject.on_hand.count }.by(2)- endenddescribe '#remove' do@@ -352,17 +335,6 @@ module Spreeexpect(imperial_package.volume).to be > metric_package.volumeendend-- context '#dimension' do- it 'calculates the sum of the dimension of all the items' do- contents = [ContentItem.new(build(:fulfillment_item, variant: build(:variant))),- ContentItem.new(build(:fulfillment_item, variant: build(:variant))),- ContentItem.new(build(:fulfillment_item, variant: build(:variant))),- ContentItem.new(build(:fulfillment_item, variant: build(:variant)))]- package = Package.new(stock_location, contents)- expect(package.dimension).to eq contents.sum(&:dimension)- end- endendendenddiff --git a/spree/core/spec/models/spree/stock/quantifier_spec.rb b/spree/core/spec/models/spree/stock/quantifier_spec.rbindex 1018488e43..6d6a59208b 100644--- a/spree/core/spec/models/spree/stock/quantifier_spec.rb+++ b/spree/core/spec/models/spree/stock/quantifier_spec.rb@@ -18,9 +18,6 @@ module Spreelet!(:stock_location) { create :stock_location_with_items }let!(:stock_level) { stock_location.stock_levels.order(:id).first }- specify { expect(subject.stock_levels).to eq([stock_level]) }- specify { expect(subject.variant).to eq(stock_level.variant) }-# The quantifier answers from memory when the caller has already loaded# the rows, and falls back to SQL when it has not. Listing endpoints# preload precisely so they take the first path — without coverage, a@@ -159,14 +156,6 @@ module Spreeendendend-- context 'when variant is not available' do- before do- allow(subject.variant).to receive(:available?).and_return(false)- end-- it { expect(subject.can_supply?).to be false }- endendcontext 'with active stock reservations' dodiff --git a/spree/core/spec/models/spree/stock_level_spec.rb b/spree/core/spec/models/spree/stock_level_spec.rbindex 29038349ed..fc415fde60 100644--- a/spree/core/spec/models/spree/stock_level_spec.rb+++ b/spree/core/spec/models/spree/stock_level_spec.rb@@ -87,14 +87,6 @@ describe Spree::StockLevel, type: :model doendend- it 'maintains the count on hand for a variant' do- expect(subject.count_on_hand).to eq 10- end-- it "can return the stock item's variant's name" do- expect(subject.variant_name).to eq(subject.variant.name)- end-context 'available to be included in shipment' docontext 'has stock' doit { expect(subject).to be_available }@@ -240,8 +232,10 @@ describe Spree::StockLevel, type: :model dobefore { subject.set_count_on_hand(-2, force: true) }- it "doesn't process backorders" do+ it "doesn't process backorders when stock drops further" doexpect(subject).not_to receive(:backordered_inventory_units)++ subject.set_count_on_hand(-3, force: true)endcontext 'adds new items' dodiff --git a/spree/core/spec/models/spree/stock_location_spec.rb b/spree/core/spec/models/spree/stock_location_spec.rbindex 58bc84574c..8b37a70e3e 100644--- a/spree/core/spec/models/spree/stock_location_spec.rb+++ b/spree/core/spec/models/spree/stock_location_spec.rb@@ -28,11 +28,6 @@ module Spreeendend- it 'validates uniqueness' do- described_class.create(name: 'Test')- expect(described_class.new(name: 'Test')).not_to be_valid- end-context 'handling stock items' dolet!(:variant) { create(:variant) }@@ -350,16 +345,26 @@ module Spreeenddescribe '#conditionally_touch_records' do- let(:item) { subject.items.last }- let(:variant) { subject.variants.last }+ let!(:variant) { subject.variants.last }+ let!(:stock_level) { subject.stock_levels.last }context 'active has changed' do- it { expect { subject.update(active: false).to change(variant, :updated_at) } }- it { expect { subject.update(active: false).to change(item, :updated_at) } }+ it 'touches variants and stock levels' do+ pending 'active_changed? is always false inside after_update, so nothing is touched'++ Timecop.travel(1.minute.from_now) do+ expect { subject.update(active: false) }.to change { variant.reload.updated_at }.+ and change { stock_level.reload.updated_at }+ end+ endendcontext 'active has not changed' do- it { expect { subject.update(name: 'my other warehouse').to change(variant, :updated_at) } }+ it 'does not touch variants' do+ Timecop.travel(1.minute.from_now) do+ expect { subject.update(name: 'my other warehouse') }.not_to change { variant.reload.updated_at }+ end+ endendend@@ -385,85 +390,6 @@ module Spreeendend- describe '#country_name' do- it 'returns the country name' do- expect(subject.country_name).to eq(subject.country.name)- end- end-- context 'when country is nil' do- subject { build(:stock_location, country: nil, state: nil) }-- it { expect(subject.country_name).to be_nil }- it { expect(subject.country_code).to be_nil }- it { expect(subject.country_iso3).to be_nil }- it { expect(subject.country_iso_name).to be_nil }- end-- describe 'KINDS / PICKUP_STOCK_POLICIES constants' do- it 'lists the built-in kinds' do- expect(StockLocation::KINDS).to eq(%w[warehouse store fulfillment_center])- end-- it 'lists the pickup stock policies' do- expect(StockLocation::PICKUP_STOCK_POLICIES).to eq(%w[local any])- end- end-- describe 'pickup defaults' do- subject { build(:stock_location) }-- it 'defaults kind to warehouse' do- expect(subject.kind).to eq('warehouse')- end-- it 'defaults pickup_enabled to false' do- expect(subject.pickup_enabled).to be false- end-- it 'defaults pickup_stock_policy to local' do- expect(subject.pickup_stock_policy).to eq('local')- end- end-- describe 'validations' do- it 'requires a kind' do- sl = build(:stock_location, kind: nil)- expect(sl).not_to be_valid- expect(sl.errors[:kind]).to be_present- end-- it 'rejects an invalid pickup_stock_policy' do- sl = build(:stock_location, pickup_stock_policy: 'bogus')- expect(sl).not_to be_valid- expect(sl.errors[:pickup_stock_policy]).to be_present- end-- it 'accepts a valid pickup_stock_policy' do- expect(build(:stock_location, pickup_stock_policy: 'any')).to be_valid- end-- it 'rejects a negative pickup_ready_in_minutes' do- sl = build(:stock_location, pickup_ready_in_minutes: -1)- expect(sl).not_to be_valid- expect(sl.errors[:pickup_ready_in_minutes]).to be_present- end-- it 'allows nil pickup_ready_in_minutes' do- expect(build(:stock_location, pickup_ready_in_minutes: nil)).to be_valid- end- end-- describe '.pickup_enabled scope' do- let!(:enabled) { create(:stock_location, pickup_enabled: true) }- let!(:disabled) { create(:stock_location, pickup_enabled: false) }-- it 'returns only locations with pickup enabled' do- expect(StockLocation.pickup_enabled).to include(enabled)- expect(StockLocation.pickup_enabled).not_to include(disabled)- end- end-describe '#country_code=' dolet(:country) { Spree::Country.by_iso('US') }let(:stock_location) { build(:stock_location, country: nil, state: nil) }diff --git a/spree/core/spec/models/spree/stock_movement_spec.rb b/spree/core/spec/models/spree/stock_movement_spec.rbindex c97ae632a5..9fc63cd2f0 100644--- a/spree/core/spec/models/spree/stock_movement_spec.rb+++ b/spree/core/spec/models/spree/stock_movement_spec.rb@@ -49,43 +49,9 @@ describe Spree::StockMovement, type: :model doendend- describe 'Constants' do- describe 'KINDS' do- it 'names every movement kind' do- expect(described_class::KINDS).to eq(%w[received allocated shipped released adjusted])- end- end-- describe 'QUANTITY_LIMITS[:max]' do- it 'return 2**31 - 1' do- expect(Spree::StockMovement::QUANTITY_LIMITS[:max]).to eq(2**31 - 1)- end- end-- describe 'QUANTITY_LIMITS[:min]' do- it 'return -2**31' do- expect(Spree::StockMovement::QUANTITY_LIMITS[:min]).to eq(-2**31)- end- end- end-describe 'validations' dolet(:stock_level) { create(:stock_level, backorderable: false) }- it 'requires a kind' do- movement = build(:stock_movement, kind: nil, stock_level: stock_level)-- expect(movement).to be_invalid- expect(movement.errors[:kind]).to be_present- end-- it 'rejects an unknown kind' do- movement = build(:stock_movement, kind: 'sold', stock_level: stock_level)-- expect(movement).to be_invalid- expect(movement.errors[:kind]).to be_present- end-it 'rejects a zero quantity' domovement = build(:stock_movement, quantity: 0, stock_level: stock_level)@@ -115,13 +81,6 @@ describe Spree::StockMovement, type: :model doenddescribe 'Scope' do- describe '.recent' do- it 'orders chronologically by created at' do- expect(Spree::StockMovement.recent.to_sql).- to eq Spree::StockMovement.unscoped.order(created_at: :desc).to_sql- end- end-describe 'kind scopes' dolet(:stock_level) { create(:stock_level) }let!(:received) { create(:stock_movement, kind: 'received', quantity: 1, stock_level: stock_level) }@@ -141,14 +100,6 @@ describe Spree::StockMovement, type: :model doenddescribe 'whitelisted ransackable attributes' do- it 'exposes the kind and every cause key' do- expect(Spree::StockMovement.whitelisted_ransackable_attributes).to eq(- %w[quantity kind reason created_at stock_level_id stock_item_id order_id fulfillment_id- return_id exchange_id stock_transfer_id purchase_order_id stock_receipt_id- unit_cost]- )- end-# Dropping the pre-rename filter would hand a client still sending it the# whole collection rather than an error.it 'still filters on the pre-rename stock_item_id name' do@@ -176,14 +127,6 @@ describe Spree::StockMovement, type: :model dolet(:stock_level) { stock_location.stock_levels.order(:id).first }let(:stock_movement) { build(:stock_movement, stock_level: stock_level) }- describe '.product' do- it { expect(stock_movement.product).to eq(stock_level.variant.product) }- end-- describe '.variant' do- it { expect(stock_movement.variant).to eq(stock_level.variant) }- end-describe '#readonly?' dolet(:stock_movement) { create(:stock_movement, stock_level: stock_level) }diff --git a/spree/core/spec/models/spree/stock_reservation_spec.rb b/spree/core/spec/models/spree/stock_reservation_spec.rbindex d07ecb0e1b..a6a83e938f 100644--- a/spree/core/spec/models/spree/stock_reservation_spec.rb+++ b/spree/core/spec/models/spree/stock_reservation_spec.rb@@ -115,24 +115,4 @@ describe Spree::StockReservation, type: :model doexpect(level.reload.reserved_count).to eq(0)endend-- describe 'cleanup via dependent: :destroy' do- let(:reservation) { create(:stock_reservation) }-- it 'is destroyed when its order is destroyed' do- reservation- order = reservation.order- expect { order.destroy }.to change(Spree::StockReservation, :count).by(-1)- end-- it 'is destroyed when its line item is destroyed' do- reservation- expect { reservation.line_item.destroy }.to change(Spree::StockReservation, :count).by(-1)- end-- it 'is destroyed when its stock item is destroyed' do- reservation- expect { reservation.stock_level.destroy }.to change(Spree::StockReservation, :count).by(-1)- end- endenddiff --git a/spree/core/spec/models/spree/store_credit_event_spec.rb b/spree/core/spec/models/spree/store_credit_event_spec.rbindex 9b295039b8..e245ef6b06 100644--- a/spree/core/spec/models/spree/store_credit_event_spec.rb+++ b/spree/core/spec/models/spree/store_credit_event_spec.rb@@ -6,10 +6,6 @@ describe 'StoreCreditEvent' dolet(:event_amount) { 120.0 }- it 'returns a Spree::Money instance' do- expect(subject.display_amount).to be_instance_of(Spree::Money)- end-it 'uses the events amount attribute' doexpect(subject.display_amount).to eq Spree::Money.new(event_amount, currency: subject.currency)end@@ -20,10 +16,6 @@ describe 'StoreCreditEvent' dolet(:user_total_amount) { 300.0 }- it 'returns a Spree::Money instance' do- expect(subject.display_user_total_amount).to be_instance_of(Spree::Money)- end-it 'uses the events user_total_amount attribute' doamount = Spree::Money.new(user_total_amount, currency: subject.currency)expect(subject.display_user_total_amount).to eq amount@@ -103,92 +95,23 @@ describe 'StoreCreditEvent' doendend- describe '#store' do- let(:store) { @default_store }- let(:store_credit) { create(:store_credit, store: store) }-- subject { build(:store_credit_auth_event, store_credit: store_credit) }-- it { expect(subject.store).to eq(store) }- end-- describe '#allocation?' do- subject { store_credit_event.allocation? }-- let(:store_credit_event) { build(:store_credit_auth_event, action: action) }-- context 'action is allocation' do- let(:action) { Spree::StoreCredit::ALLOCATION_ACTION }- it { is_expected.to be true }- end-- context 'action is not allocation' do- let(:action) { Spree::StoreCredit::CAPTURE_ACTION }- it { is_expected.to be false }- end- end-- describe '#credit?' do- subject { store_credit_event.credit? }-- let(:store_credit_event) { build(:store_credit_auth_event, action: action) }-- context 'action is credit' do- let(:action) { Spree::StoreCredit::CREDIT_ACTION }- it { is_expected.to be true }- end-- context 'action is not credit' do- let(:action) { Spree::StoreCredit::CAPTURE_ACTION }- it { is_expected.to be false }- end- end-- describe '#captured?' do- subject { store_credit_event.captured? }-- let(:store_credit_event) { build(:store_credit_auth_event, action: action) }-- context 'action is capture' do- let(:action) { Spree::StoreCredit::CAPTURE_ACTION }- it { is_expected.to be true }- end-- context 'action is not capture' do- let(:action) { Spree::StoreCredit::ALLOCATION_ACTION }- it { is_expected.to be false }- end- end-- describe '#voided?' do- subject { store_credit_event.voided? }-- let(:store_credit_event) { build(:store_credit_auth_event, action: action) }-- context 'action is void' do- let(:action) { Spree::StoreCredit::VOID_ACTION }- it { is_expected.to be true }- end-- context 'action is not void' do- let(:action) { Spree::StoreCredit::CAPTURE_ACTION }- it { is_expected.to be false }- end- end-- describe '#authorized?' do- subject { store_credit_event.authorized? }-- let(:store_credit_event) { build(:store_credit_auth_event, action: action) }-- context 'action is authorize' do- let(:action) { Spree::StoreCredit::AUTHORIZE_ACTION }- it { is_expected.to be true }- end-- context 'action is not authorize' do- let(:action) { Spree::StoreCredit::CAPTURE_ACTION }- it { is_expected.to be false }+ describe 'action predicates' do+ it 'answers true only for its own action' do+ predicates = {+ allocation?: Spree::StoreCredit::ALLOCATION_ACTION,+ credit?: Spree::StoreCredit::CREDIT_ACTION,+ captured?: Spree::StoreCredit::CAPTURE_ACTION,+ voided?: Spree::StoreCredit::VOID_ACTION,+ authorized?: Spree::StoreCredit::AUTHORIZE_ACTION+ }++ predicates.each do |predicate, own_action|+ predicates.each_value do |action|+ event = build(:store_credit_auth_event, action: action)++ expect(event.public_send(predicate)).to be(action == own_action), "#{predicate} for #{action}"+ end+ endendendenddiff --git a/spree/core/spec/models/spree/store_credit_spec.rb b/spree/core/spec/models/spree/store_credit_spec.rbindex 48a3a2f566..cff98d6273 100644--- a/spree/core/spec/models/spree/store_credit_spec.rb+++ b/spree/core/spec/models/spree/store_credit_spec.rb@@ -52,20 +52,6 @@ describe Spree::StoreCredit, type: :model doendend- describe 'amount used less than or equal to amount' do- subject { build(:store_credit, amount_used: 101.0, amount: 100.0) }-- it 'is not valid' do- expect(subject).not_to be_valid- end-- it 'adds an error message about the invalid amount used' do- subject.valid?- text = I18n.t('activerecord.errors.models.spree/store_credit.attributes.amount_used.cannot_be_greater_than_amount')- expect(subject.errors[:amount_used]).to include(text)- end- end-describe 'amount authorized less than or equal to amount' dosubject { build(:store_credit, amount_authorized: 101.0, amount: 100.0) }@@ -225,18 +211,6 @@ describe Spree::StoreCredit, type: :model doendend- describe '#display_amount' do- it 'returns a Spree::Money instance' do- expect(store_credit.display_amount).to be_instance_of(Spree::Money)- end- end-- describe '#display_amount_used' do- it 'returns a Spree::Money instance' do- expect(store_credit.display_amount_used).to be_instance_of(Spree::Money)- end- end-describe '#amount_remaining' docontext 'the amount_used is not defined' docontext 'the authorized amount is not defined' do@@ -410,7 +384,7 @@ describe Spree::StoreCredit, type: :model doendit 'does not update the store credit model' do- expect { subject }.not_to change { store_credit }+ expect { subject }.not_to change { store_credit.reload.slice(:amount_used, :amount_authorized) }endend@@ -428,7 +402,7 @@ describe Spree::StoreCredit, type: :model doendit 'does not update the store credit model' do- expect { subject }.not_to change { store_credit }+ expect { subject }.not_to change { store_credit.reload.slice(:amount_used, :amount_authorized) }endend@@ -676,46 +650,6 @@ describe Spree::StoreCredit, type: :model doendend- describe '#amount_used' do- context 'amount used is not defined' do- subject { Spree::StoreCredit.new }-- it 'returns zero' do- expect(subject.amount_used).to be_zero- end- end-- context 'amount used is defined' do- subject { create(:store_credit, amount_used: amount_used) }-- let(:amount_used) { 100.0 }-- it 'returns the attribute value' do- expect(subject.amount_used).to eq amount_used- end- end- end-- describe '#amount_authorized' do- context 'amount authorized is not defined' do- subject { Spree::StoreCredit.new }-- it 'returns zero' do- expect(subject.amount_authorized).to be_zero- end- end-- context 'amount authorized is defined' do- subject { create(:store_credit, amount_authorized: amount_authorized) }-- let(:amount_authorized) { 100.0 }-- it 'returns the attribute value' do- expect(subject.amount_authorized).to eq amount_authorized- end- end- end-describe '#can_capture?' dosubject { store_credit.can_capture?(payment) }diff --git a/spree/core/spec/models/spree/store_spec.rb b/spree/core/spec/models/spree/store_spec.rbindex 2eca278778..77cb028bb8 100644--- a/spree/core/spec/models/spree/store_spec.rb+++ b/spree/core/spec/models/spree/store_spec.rb@@ -33,105 +33,11 @@ describe Spree::Store, type: :model, without_global_store: true docontext 'Associations' dosubject { create(:store) }- let(:other_store) { create(:store) }-describe '#products' dolet!(:product) { create(:product, store: subject) }- let!(:product_2) { create(:product, store: other_store) }+ let!(:product_2) { create(:product, store: create(:store)) }it { expect(subject.products).to eq([product]) }-- describe '#variants' do- let!(:variant) { create(:variant, product: product) }- let!(:variant_2) { create(:variant, product: product_2) }-- it { expect(subject.variants).to eq([product.default_variant, variant]) }-- describe '#stock_levels' do- let!(:stock_levels) { product.stock_levels }- let!(:stock_levels_2) { product_2.stock_levels }-- it { expect(stock_levels).not_to be_empty }- it { expect(stock_levels_2).not_to be_empty }- it { expect(subject.stock_levels).to eq(stock_levels) }- end- end- end-- describe '#payment_methods' do- let!(:payment_method) { create(:payment_method, store: subject) }- let!(:payment_method_2) { create(:payment_method, store: create(:store)) }-- it { expect(subject.payment_methods).to eq([payment_method]) }- end-- describe '#orders' do- let!(:order) { create(:order, store: subject, total: 100) }- let!(:order_2) { create(:order, store: create(:store), total: 100) }-- it { expect(subject.orders).to eq([order]) }-- describe '#line_items' do- let!(:line_item) { create(:line_item, order: order) }- let!(:line_item_2) { create(:line_item, order: order_2) }-- it { expect(subject.line_items).to eq([line_item]) }- end-- describe '#payments' do- let!(:payment) { create(:payment, order: order) }- let!(:payment_2) { create(:payment, order: order_2) }-- it { expect(subject.payments).to eq([payment]) }- end-- describe '#shipments' do- let!(:shipment) { create(:fulfillment, order: order) }- let!(:shipment_2) { create(:fulfillment, order: order_2) }-- it { expect(subject.shipments).to eq([shipment]) }- end-- describe '#returns' do- let!(:order) { create(:shipped_order, store: subject) }- let!(:order_2) { create(:shipped_order, store: create(:store)) }- let!(:return_record) { create(:return, order: order, store: subject) }- let!(:return_record_2) { create(:return, order: order_2, store: order_2.store) }-- it { expect(subject.returns).to eq([return_record]) }- end-- describe '#inventory_units' do- let(:product) { create(:product, store: subject) }- let(:product_2) { create(:product, store: other_store) }- let!(:inventory_unit) { create(:fulfillment_item, variant: product.default_variant, order: order) }- let!(:inventory_unit_2) { create(:fulfillment_item, variant: product_2.default_variant, order: order_2) }-- it { expect(subject.inventory_units).to eq([inventory_unit]) }- end- end-- describe '#store_credits' do- let!(:store_credit) { create(:store_credit, store: subject) }- let!(:store_credit_2) { create(:store_credit, store: create(:store)) }-- it { expect(subject.store_credits).to eq([store_credit]) }-- describe '#store_credit_events' do- let!(:store_credit_event) { store_credit.store_credit_events.first }- let!(:store_credit_event_2) { store_credit_2.store_credit_events.first }-- it { expect(store_credit_event).not_to be_nil }- it { expect(store_credit_event_2).not_to be_nil }- it { expect(subject.store_credit_events).to eq([store_credit_event]) }- end- end-- describe '#promotions' do- let!(:promotion) { create(:promotion, store: subject) }- let!(:promotion_2) { create(:promotion, store: create(:store)) }-- it { expect(subject.promotions).to eq([promotion]) }endend@@ -362,16 +268,6 @@ describe Spree::Store, type: :model, without_global_store: true doendcontext 'Validations' do- describe '#code' do- it 'generates a code when blank' do- store = build(:store, code: nil, name: nil)- store.valid?- # set_default_code generates a code if blank, so it should be valid- expect(store.code).to be_present- expect(store.errors[:code]).to be_empty- end- end-describe '#customer_support_email' doit 'is valid when blank' dostore = build(:store, customer_support_email: '')@@ -414,10 +310,6 @@ describe Spree::Store, type: :model, without_global_store: true doenddescribe 'order routing strategy preference' do- it 'is valid with the default registered Rules strategy' do- expect(create(:store)).to be_valid- end-it 'rejects an unregistered strategy' dostore = build(:store, preferred_order_routing_strategy: 'Spree::OrderRouting::Strategy::Reducer')expect(store).not_to be_valid@@ -507,17 +399,11 @@ describe Spree::Store, type: :model, without_global_store: true dodescribe '#states_available_for_checkout' dosubject { create(:store) }- let(:country_with_states) do- create(:country).tap do |country|- # subdivisions are reference data — the country already has them- end- end-it 'returns list of states associated to country' do- checkout_available_states_ids = subject.states_available_for_checkout(country_with_states).map(&:abbr)- all_state_ids = country_with_states.states.map(&:abbr)+ state_codes = subject.states_available_for_checkout(Spree::Country.by_iso('US')).map(&:abbr)- expect(checkout_available_states_ids).to eq(all_state_ids)+ expect(state_codes).to include('NY', 'CA')+ expect(state_codes).not_to include('ON')endend@@ -565,14 +451,6 @@ describe Spree::Store, type: :model, without_global_store: true doendend- describe '#unique_name' do- let!(:store) { build(:store) }-- it 'returns the Store Name followed by the Store Code in parentheses' do- expect(store.unique_name).to eq("#{store.name} (#{store.code})")- end- end-describe '#supported_currencies_list' docontext 'with markets' dolet!(:store) { create(:store, default_currency: 'USD') }@@ -790,10 +668,6 @@ describe Spree::Store, type: :model, without_global_store: true doexpect(countries.map(&:iso)).to contain_exactly(country_a.iso, country_b.iso, country_c.iso, 'US')end- it 'returns an ActiveRecord relation' do- expect(store.countries_from_markets).to all(be_a(Spree::Country))- end-it 'orders by name' donames = store.countries_from_markets.map(&:name)expect(names).to eq(names.sort)@@ -803,11 +677,6 @@ describe Spree::Store, type: :model, without_global_store: true doother_country = create(:country)expect(store.countries_from_markets.map(&:iso)).not_to include(other_country.iso)end-- it 'does not duplicate countries shared across markets' do- store.markets.last.countries << country_a rescue nil- expect(store.countries_from_markets.count { |c| c.iso == country_a.iso }).to eq(1)- endendcontext 'without markets' do@@ -817,15 +686,6 @@ describe Spree::Store, type: :model, without_global_store: true doendend- describe 'soft deletion' do- let!(:store) { create(:store) }-- it 'soft-deletes when destroy is called' do- store.destroy!- expect(store.deleted_at).not_to be_nil- end- end-describe '#default_stock_location' do# A persisted store must be the current one: stock locations are# store-scoped and resolve their store from Spree::Current.@@ -960,22 +820,6 @@ describe Spree::Store, type: :model, without_global_store: true doendend- describe '#formatted_url_or_custom_domain' do- let(:store) { build(:store, code: 'mystore', url: 'mystore.mydomain.dev:3000') }-- it 'returns formatted_url as fallback' do- expect(store.formatted_url_or_custom_domain).to eq('http://mystore.mydomain.dev:3000')- end- end-- describe '#url_or_custom_domain' do- let(:store) { build(:store, code: 'mystore', url: 'mystore.mydomain.dev') }-- it 'returns url as fallback' do- expect(store.url_or_custom_domain).to eq('mystore.mydomain.dev')- end- end-describe '#allowed_origin?' dolet(:store) { create(:store) }@@ -1142,10 +986,6 @@ describe Spree::Store, type: :model, without_global_store: true dodescribe 'storefront setup task' dolet(:store) { create(:store) }- it 'is included in the setup tasks list' do- expect(store.setup_tasks_list).to include(:setup_storefront)- end-describe '#storefront_setup?' dosubject { store.storefront_setup? }diff --git a/spree/core/spec/models/spree/storefront/access_policy_spec.rb b/spree/core/spec/models/spree/storefront/access_policy_spec.rbindex d875d1826e..c37658f7dc 100644--- a/spree/core/spec/models/spree/storefront/access_policy_spec.rb+++ b/spree/core/spec/models/spree/storefront/access_policy_spec.rb@@ -96,14 +96,6 @@ RSpec.describe Spree::Storefront::AccessPolicy, type: :model doexpect(guest_policy.readable?(unowned)).to be falseend- it 'keys ownership on customer_id, not the deprecated user_id alias' do- # Guards against the alias disappearing in 6.1: a record whose- # customer_id matches is owned even if #user_id is gone.- owned = build(:wishlist, customer: user)- expect(owned.customer_id).to eq(user.id)- expect(policy.readable?(owned)).to be true- end-it 'fails closed for records with no customer_id column' do# WishedItem has no ownership column — it is authorized through its# parent wishlist, never directly. The bare policy denies it.diff --git a/spree/core/spec/models/spree/subscriber_spec.rb b/spree/core/spec/models/spree/subscriber_spec.rbindex 5207c14756..34bc769e78 100644--- a/spree/core/spec/models/spree/subscriber_spec.rb+++ b/spree/core/spec/models/spree/subscriber_spec.rb@@ -46,21 +46,6 @@ RSpec.describe Spree::Subscriber, events: true doendend- describe '.on' do- it 'maps events to methods' do- subscriber_class = Class.new(described_class) do- subscribes_to 'payment.completed', 'payment.voided'- on 'payment.completed', :handle_complete- on 'payment.voided', :handle_void- end-- expect(subscriber_class.event_handlers).to eq({- 'payment.completed' => :handle_complete,- 'payment.voided' => :handle_void- })- end- end-describe '#call' docontext 'without event handlers' doit 'calls the handle method' dodiff --git a/spree/core/spec/models/spree/tax_category_spec.rb b/spree/core/spec/models/spree/tax_category_spec.rbindex bdcc07734c..5965127be6 100644--- a/spree/core/spec/models/spree/tax_category_spec.rb+++ b/spree/core/spec/models/spree/tax_category_spec.rb@@ -18,7 +18,7 @@ describe Spree::TaxCategory, type: :model doendit 'undefaults the previous default tax category except when updating the existing default tax category' do- tax_category.update_column(:description, 'Updated description')+ tax_category.update!(description: 'Updated description')tax_category.reloadexpect(tax_category.is_default).to be true@@ -37,17 +37,11 @@ describe Spree::TaxCategory, type: :model doexpect(create(:tax_category).store).to eq(@default_store)end- it 'allows the same name in another store' do- other_store = create(:store)- create(:tax_category, name: 'Standard')-- expect(build(:tax_category, name: 'Standard', store: other_store)).to be_valid- end-- it 'rejects a duplicate name within the same store, ignoring case' do+ it 'rejects a duplicate name within the same store, ignoring case, but allows it in another store' docreate(:tax_category, name: 'Standard')expect(build(:tax_category, name: 'standard')).not_to be_valid+ expect(build(:tax_category, name: 'Standard', store: create(:store))).to be_validendit 'ignores soft-deleted rows when checking the name' dodiff --git a/spree/core/spec/models/spree/tax_exemption_spec.rb b/spree/core/spec/models/spree/tax_exemption_spec.rbindex 6f0443575e..ad35b1b396 100644--- a/spree/core/spec/models/spree/tax_exemption_spec.rb+++ b/spree/core/spec/models/spree/tax_exemption_spec.rb@@ -81,10 +81,6 @@ describe Spree::TaxExemption, type: :model doexpect(exemption.errors[:item_overrides]).to be_presentend- it 'leaves an entry with no overrides at all valid — that claims the order' do- expect(described_class.new(reason_code: 'resale')).to be_valid- end-# Stated so the widening is visible: this is what the validation prevents# from ever reaching a provider.it 'would otherwise report every line as covered' dodiff --git a/spree/core/spec/models/spree/tax_identifier_spec.rb b/spree/core/spec/models/spree/tax_identifier_spec.rbindex 41aa217bb1..170b0e90ed 100644--- a/spree/core/spec/models/spree/tax_identifier_spec.rb+++ b/spree/core/spec/models/spree/tax_identifier_spec.rb@@ -5,18 +5,6 @@ describe Spree::TaxIdentifier, type: :model dolet(:cart) { create(:cart, customer: customer) }let(:order) { create(:order, customer: customer) }- it 'requires a kind and a value' do- expect(build(:tax_identifier)).to be_valid- expect(build(:tax_identifier, kind: nil)).not_to be_valid- expect(build(:tax_identifier, value: nil)).not_to be_valid- end-- it 'requires an owner' do- expect(build(:tax_identifier, owner: customer)).to be_valid- expect(build(:tax_identifier, owner: cart)).to be_valid- expect(build(:tax_identifier, owner: nil)).not_to be_valid- end-it 'rejects a validation status the platform never sets' doexpect(build(:tax_identifier, validation_status: 'verified')).to be_validexpect(build(:tax_identifier, validation_status: nil)).to be_valid@@ -284,12 +272,6 @@ describe Spree::TaxIdentifier, type: :model doexpect(build(:tax_identifier, owner: company, kind: 'eu_vat')).not_to be_validend-- it 'reports the company as its owner' do- identifier = create(:tax_identifier, owner: company)-- expect(identifier.owner).to eq(company)- endend# A seller's registration faces the other way from the rest: it is what the# marketplace's own commission invoice is made out to, and what makes EU@@ -302,7 +284,6 @@ describe Spree::TaxIdentifier, type: :model dovalue: eu_vat_number(0))expect(identifier).to be_valid- expect(identifier.owner).to eq(seller)endit 'holds one registration per kind' dodiff --git a/spree/core/spec/models/spree/tax_line_spec.rb b/spree/core/spec/models/spree/tax_line_spec.rbindex a87ca4cdd0..966b534ad9 100644--- a/spree/core/spec/models/spree/tax_line_spec.rb+++ b/spree/core/spec/models/spree/tax_line_spec.rb@@ -107,19 +107,6 @@ describe Spree::TaxLine, type: :model doendend- describe 'provider data' do- it 'defaults to an empty hash so payloads read nil-safe' do- expect(described_class.new.data).to eq({})- expect(described_class.new.data['jurisdictions']).to be_nil- end-- it 'round-trips a provider payload' do- tax_line = create(:tax_line, order: order, line_item: line_item,- data: { 'jurisdictions' => [{ 'name' => 'WA', 'amount' => '1.2' }] })- expect(tax_line.reload.data['jurisdictions'].first['name']).to eq('WA')- end- end-describe 'included vs additional' dolet!(:included_line) { create(:tax_line, order: order, line_item: line_item, included: true) }let!(:additional_line) { create(:tax_line, order: order, line_item: line_item, included: false) }diff --git a/spree/core/spec/models/spree/tax_provider/base_spec.rb b/spree/core/spec/models/spree/tax_provider/base_spec.rbindex 39efa54115..d4b39e89f9 100644--- a/spree/core/spec/models/spree/tax_provider/base_spec.rb+++ b/spree/core/spec/models/spree/tax_provider/base_spec.rb@@ -54,11 +54,6 @@ describe Spree::TaxProvider::Base, type: :model doexpect(described_class.unsupported_capabilities).to eq([])expect(described_class.available_for_store?(order.store)).to be(true)end-- it 'is answerable without instantiating the provider' do- expect(described_class).to respond_to(:unsupported_capabilities)- expect(described_class).to respond_to(:available_for_store?)- endenddescribe 'self-description for the admin' do@@ -112,10 +107,6 @@ describe Spree::TaxProvider::Base, type: :model doexpect(Spree.default_tax_provider).to eq(Spree::TaxProvider::Internal)end- it 'returns a class, so a caller that only names it pays for no instance' do- expect(Spree.default_tax_provider).to be_a(Class)- end-it 'accepts a class name, for an initializer naming a provider before autoload' dooriginal = Rails.application.config.spree.default_tax_providerSpree.default_tax_provider = 'Spree::TaxProvider::Internal'@@ -127,18 +118,6 @@ describe Spree::TaxProvider::Base, type: :model doendend- describe 'the internal provider' do- it 'declares the domains rate configuration cannot express' do- expect(Spree::TaxProvider::Internal.unsupported_capabilities).to(- contain_exactly(:us_local_tax, :reverse_charge, :oss_thresholds, :proportional_delivery_tax)- )- end-- it 'is available for any store, needing no credentials' do- expect(Spree::TaxProvider::Internal.available_for_store?(order.store)).to be(true)- end- end-it 'no longer answers a standalone exemption question' doexpect(provider).not_to respond_to(:exempt?)enddiff --git a/spree/core/spec/models/spree/tax_rate_spec.rb b/spree/core/spec/models/spree/tax_rate_spec.rbindex db233d1c6b..117a29a946 100644--- a/spree/core/spec/models/spree/tax_rate_spec.rb+++ b/spree/core/spec/models/spree/tax_rate_spec.rb@@ -22,16 +22,10 @@ describe Spree::TaxRate, type: :model doit 'reads a jurisdiction off an address, or takes the pair directly' dorate = create(:tax_rate, country_code: germany&.iso, tax_category: tax_category)-- expect(described_class.for_address(german_address)).to eq([rate])- expect(described_class.for_jurisdiction(germany.iso)).to eq([rate])- end-- it 'matches a rate for the address country' do- rate = create(:tax_rate, country_code: germany&.iso, tax_category: tax_category)create(:tax_rate, country_code: france&.iso, tax_category: tax_category)expect(described_class.for_address(german_address)).to eq([rate])+ expect(described_class.for_jurisdiction(germany.iso)).to eq([rate])endit 'matches every rate configured for that country' do@@ -279,17 +273,10 @@ describe Spree::TaxRate, type: :model dotax_rate = Spree::TaxRate.new(name: 'Sales Tax', amount: 0.1)expect(tax_rate.adjustment_label).to eq('Sales Tax 10%')end- end-- describe '#amount_for_label' do- it 'returns an empty string when the amount is 0' do- tax_rate = Spree::TaxRate.new(amount: 0)- expect(tax_rate.send(:amount_for_label)).to eq('')- end- it 'returns a string with the percentage when the amount is not 0' do- tax_rate = Spree::TaxRate.new(amount: 0.1)- expect(tax_rate.send(:amount_for_label)).to eq(' 10%')+ it 'leaves the percentage out when the amount is 0' do+ tax_rate = Spree::TaxRate.new(name: 'Sales Tax', amount: 0)+ expect(tax_rate.adjustment_label).to eq('Sales Tax')endenddiff --git a/spree/core/spec/models/spree/taxon_category_aliases_spec.rb b/spree/core/spec/models/spree/taxon_category_aliases_spec.rbindex 4aa3976456..a95b0f0a40 100644--- a/spree/core/spec/models/spree/taxon_category_aliases_spec.rb+++ b/spree/core/spec/models/spree/taxon_category_aliases_spec.rb@@ -5,7 +5,11 @@ require 'spec_helper'# the taxons queue, and the method bridges warn through Spree::Deprecation.RSpec.describe 'Taxon -> Category deprecation aliases' dodescribe 'constant aliases resolve to the canonical class' do+ # Each alias warns once, when its file first loads, so another spec may+ # already have loaded it.it 'keeps them as true class aliases (not proxies), so is_a?/STI stay correct' do+ allow(Spree::Deprecation).to receive(:warn)+expect(Spree::Taxon).to equal(Spree::Category)expect(Spree::Classification).to equal(Spree::ProductCategory)expect(Spree::PromotionRuleTaxon).to equal(Spree::PromotionRuleCategory)diff --git a/spree/core/spec/models/spree/user_identity_spec.rb b/spree/core/spec/models/spree/user_identity_spec.rbindex 4ab27cebe2..e96ecf380d 100644--- a/spree/core/spec/models/spree/user_identity_spec.rb+++ b/spree/core/spec/models/spree/user_identity_spec.rb@@ -23,12 +23,6 @@ describe Spree::UserIdentity, type: :model docreate(:user_identity, user: user, provider: 'email', uid: '12345')end- it 'validates uniqueness of uid scoped to provider and user_type' do- duplicate = build(:user_identity, user: user, provider: 'email', uid: '12345')- expect(duplicate).not_to be_valid- expect(duplicate.errors[:uid]).to include('has already been taken')- end-it 'allows same uid for different providers' doSpree.store_authentication_strategies.add(:other, Class.new)different_provider = build(:user_identity, user: user, provider: 'other', uid: '12345')@@ -294,13 +288,6 @@ describe Spree::UserIdentity, type: :model doendend- describe '.generate_temp_email' do- it 'generates email with provider and uid' do- email = described_class.generate_temp_email('email', '123456')- expect(email).to eq('[email protected]')- end- end-describe '#expired?' docontext 'when expires_at is nil' dosubject { build(:user_identity, expires_at: nil) }diff --git a/spree/core/spec/models/spree/user_spec.rb b/spree/core/spec/models/spree/user_spec.rbindex 6c18625334..d7d7193ab4 100644--- a/spree/core/spec/models/spree/user_spec.rb+++ b/spree/core/spec/models/spree/user_spec.rb@@ -3,22 +3,6 @@ require 'spec_helper'describe Spree.customer_class, type: :model do # rubocop:disable RSpec/MultipleDescribesit_behaves_like 'lifecycle events', factory: :user, event_prefix: 'user'- describe '#can_be_deleted?' do- subject { user.can_be_deleted? }-- context 'when user has completed orders' do- let(:user) { create(:user, orders: [create(:order, completed_at: Time.current)]) }-- it { is_expected.to be(false) }- end-- context 'when user has no completed orders' do- let(:user) { create(:user, orders: [create(:order)]) }-- it { is_expected.to be(true) }- end- end-describe '#full_name' docontext 'when names are present' dolet(:user) { build(:user, first_name: 'John', last_name: 'Doe') }@@ -38,29 +22,11 @@ describe Spree.customer_class, type: :model do # rubocop:disable RSpec/MultipleDendend- # Regression test for #2844 + #3346describe '#last_incomplete_order' dolet!(:user) { create(:user) }let!(:order) { create(:order, store: store, bill_address: create(:address), ship_address: create(:address)) }let(:store) { @default_store }- let(:admin_user) { create(:admin_user) }- let(:order_1) { create(:order, created_at: 1.day.ago, customer: user, created_by: admin_user, store: store) }- let(:order_2) { create(:order, customer: user, created_by: admin_user, store: store) }- let(:order_3) { create(:order, customer: user, created_by: create(:admin_user), store: store) }-- it 'returns correct order' do- allow(Spree::Deprecation).to receive(:warn)-- Timecop.scale(3600) do- order_1- order_2- order_3-- expect(user.last_incomplete_spree_order(store)).to eq order_3- end- end-context 'persists order address (deprecated, removed in 6.1)' dobefore { allow(Spree::Deprecation).to receive(:warn) }@@ -88,13 +54,6 @@ describe Spree.customer_class, type: :model do # rubocop:disable RSpec/MultipleDuser.persist_order_address(order)end.not_to change { Spree::Address.count }end-- it 'set both bill and ship address id on subject' do- user.persist_order_address(order)-- expect(user.bill_address_id).not_to be_blank- expect(user.ship_address_id).not_to be_blank- endendcontext 'payment source' do@@ -103,10 +62,6 @@ describe Spree.customer_class, type: :model do # rubocop:disable RSpec/MultipleDcreate(:credit_card, customer_id: user.id, payment_method: payment_method, gateway_customer_profile_id: '2342343')end- it 'has payment sources' do- expect(user.payment_sources.first.gateway_customer_profile_id).not_to be_empty- end-it 'drops payment source' douser.drop_payment_source ccexpect(cc.gateway_customer_profile_id).to be_nil@@ -310,12 +265,6 @@ describe Spree.customer_class, type: :model doendend- context 'all store credits have never been used or authorized' do- it 'returns sum of amounts' do- expect(subject.total_available_store_credit.to_f).to eq (amount + additional_amount)- end- end-# Regression: the admin API preloads `store_credits` to avoid an N+1, so# the in-memory branch must match the query branch — filtered by store# and currency, gift cards excluded.@@ -376,23 +325,6 @@ describe Spree.customer_class, type: :model doendend- context 'address book' do- let(:address) { create(:address) }- let(:address2) { create(:address) }-- before do- address.owner = subject- address.save- address2.owner = subject- address2.save- end-- it 'has many addresses' do- expect(subject).to respond_to(:addresses)- expect(subject.addresses).to eq [address2, address]- end- end-describe 'validations' doshared_examples 'valid' doit 'is valid' do@@ -500,16 +432,12 @@ describe Spree.customer_class, type: :model dolet!(:completed_order) { create(:completed_order_with_totals, customer: user, bill_address: address, ship_address: address) }context 'when default bill address is the same as associated to order' do- it { expect(user.addresses).to include(address) }-it_behaves_like 'valid'endcontext 'when user changed bill address which was used in completed order so the old one is deprecated' dobefore { address.update(deleted_at: Time.now) }- it { expect(user.addresses).not_to include(address) }-it_behaves_like 'invalid'it 'assigns error to bill address' do@@ -539,16 +467,12 @@ describe Spree.customer_class, type: :model dolet!(:completed_order) { create(:completed_order_with_totals, customer: user, bill_address: address, ship_address: address) }context 'when default ship address is the same as associated to order' do- it { expect(user.addresses).to include(address) }-it_behaves_like 'valid'endcontext 'when user changed ship address which was used in completed order so the old one is deprecated' dobefore { address.update(deleted_at: Time.now) }- it { expect(user.addresses).not_to include(address) }-it_behaves_like 'invalid'it 'assigns error to ship address' dodiff --git a/spree/core/spec/models/spree/variant/scopes_spec.rb b/spree/core/spec/models/spree/variant/scopes_spec.rbindex 8a46b98db3..2133c32435 100644--- a/spree/core/spec/models/spree/variant/scopes_spec.rb+++ b/spree/core/spec/models/spree/variant/scopes_spec.rb@@ -40,12 +40,6 @@ describe 'Variant scopes', type: :model doexpect(variants.count).to eq(0)end- it 'returns no variants when variants sku does not match any' do- variants = Spree::Variant.product_name_or_sku_cont('variant_white')- expect(variants).not_to include(variant_1, variant_2, variant_3)- expect(variants.count).to eq(0)- end-context 'when using translations' dobefore doI18n.with_locale(:pl) do@@ -73,37 +67,5 @@ describe 'Variant scopes', type: :model doit 'returns variants based on products name' doexpect(Spree::Variant.search_by_product_name_or_sku('Second')).to include(variant_2)end-- it 'returns variants based on variant sku' do- expect(Spree::Variant.search_by_product_name_or_sku('blue')).to include(variant_3)- end-- it 'does not return variants of products that do not match name' do- expect(Spree::Variant.search_by_product_name_or_sku('First')).not_to include(variant_2, variant_3)- end-- it 'does not return variants with not matching skus' do- expect(Spree::Variant.search_by_product_name_or_sku('green')).not_to include(variant_1, variant_3)- end-- it 'returns multiple variants based on products name' do- expect(Spree::Variant.search_by_product_name_or_sku('product')).to include(variant_1, variant_2, variant_3)- end-- it 'return multiple variants based on variants sku' do- expect(Spree::Variant.search_by_product_name_or_sku('variant')).to include(variant_1, variant_2, variant_3)- end-- it 'returns no variants when products name does not match any' do- variants = Spree::Variant.search_by_product_name_or_sku('White dress')- expect(variants).not_to include(variant_1, variant_2, variant_3)- expect(variants.count).to eq(0)- end-- it 'returns no variants when variants sku does not match any' do- variants = Spree::Variant.search_by_product_name_or_sku('variant_white')- expect(variants).not_to include(variant_1, variant_2, variant_3)- expect(variants.count).to eq(0)- endendenddiff --git a/spree/core/spec/models/spree/variant/shared_catalog_spec.rb b/spree/core/spec/models/spree/variant/shared_catalog_spec.rbindex 782c974990..47fa2229c0 100644--- a/spree/core/spec/models/spree/variant/shared_catalog_spec.rb+++ b/spree/core/spec/models/spree/variant/shared_catalog_spec.rb@@ -231,12 +231,15 @@ describe Spree::Variant, type: :model dolet(:product) { create(:product, store: store) }let(:owned_product) { create(:product, store: store, seller: seller) }- it 'finds variants by their own seller' do+ # Spree::Export probes for this scope by name and hands it a Seller+ # record, so the record form is a contract rather than a convenience.+ it 'finds variants by their own seller, given a record or an id' domine = create(:variant, product: product, seller: seller)create(:variant, product: product, seller: other_seller)expect(described_class.for_seller(seller)).to include(mine)expect(described_class.for_seller(seller).count).to eq(1)+ expect(described_class.for_seller(seller.id)).to include(mine)endit 'finds variants whose seller comes from the product' do@@ -245,15 +248,6 @@ describe Spree::Variant, type: :model doexpect(described_class.for_seller(seller)).to include(inherited)end- # Spree::Export probes for this scope by name and hands it a Seller- # record, so the record form is a contract rather than a convenience.- it 'accepts a seller record as well as an id' do- mine = create(:variant, product: product, seller: seller)-- expect(described_class.for_seller(seller)).to include(mine)- expect(described_class.for_seller(seller.id)).to include(mine)- end-# The raw columns must not be filterable: they would match only variants# carrying their own seller, silently missing every one that inherits it# from the product — which on a single-owner catalog is all of them.diff --git a/spree/core/spec/models/spree/variant_media_spec.rb b/spree/core/spec/models/spree/variant_media_spec.rbindex 5b922ac123..e300dd9c4b 100644--- a/spree/core/spec/models/spree/variant_media_spec.rb+++ b/spree/core/spec/models/spree/variant_media_spec.rb@@ -17,12 +17,6 @@ RSpec.describe Spree::VariantMedia, type: :model doexpect(vm).not_to be_validexpect(vm.errors[:asset]).to be_presentend-- it 'enforces uniqueness on (variant_id, media_id)' do- described_class.create!(variant: variant, asset: asset)- dup = described_class.new(variant: variant, asset: asset)- expect(dup).not_to be_valid- endenddescribe 'touch propagation' do@@ -53,19 +47,6 @@ RSpec.describe Spree::VariantMedia, type: :model do.to change { variant_for_thumb.reload.primary_media_id }.from(product_asset.id).to(nil)endend-- describe 'cleanup' do- it 'destroys variant_media when the variant is destroyed' do- described_class.create!(variant: variant, asset: asset)- expect { variant.destroy }.to change(described_class, :count).by(-1)- end-- it 'destroys variant_media when the asset is destroyed' do- described_class.create!(variant: variant, asset: asset)- expect { asset.destroy }.to change(described_class, :count).by(-1)- end- end-endRSpec.describe Spree::Media, type: :model dodiff --git a/spree/core/spec/models/spree/variant_spec.rb b/spree/core/spec/models/spree/variant_spec.rbindex 8a7373a259..388615cc9c 100644--- a/spree/core/spec/models/spree/variant_spec.rb+++ b/spree/core/spec/models/spree/variant_spec.rb@@ -7,12 +7,6 @@ describe Spree::Variant, type: :model doit_behaves_like 'metadata'it_behaves_like 'lifecycle events'- context 'sorting' do- it 'responds to set_list_position' do- expect(variant.respond_to?(:set_list_position)).to eq(true)- end- end-context 'validations' doit 'rejects a negative price' doexpect { variant.set_price(variant.cost_currency, -1) }.to raise_error(ActiveRecord::RecordInvalid)@@ -303,16 +297,6 @@ describe Spree::Variant, type: :model doendend- describe '.eligible' do- it 'returns every variant' do- product_1 = create(:product)- product_2 = create(:product)- variant = create(:variant, product: product_1)-- expect(Spree::Variant.eligible).to include(product_1.default_variant, product_2.default_variant, variant)- end- end-describe '.not_discontinued' docontext 'when discontinued' dolet!(:discontinued_variant) { create(:variant, discontinue_on: Time.current - 1.day) }@@ -469,31 +453,19 @@ describe Spree::Variant, type: :model doenddescribe '.active' do- let!(:variants) { [variant] }- let!(:currency) { 'EUR' }-- before do- allow(Spree::Variant).to receive(:not_discontinued).and_return(variants)- allow(variants).to receive(:not_deleted).and_return(variants)- allow(variants).to receive(:for_currency_and_available_price_amount).with(currency).and_return(variants)+ def variant_priced_in_eur(attributes = {})+ create(:variant, attributes).tap { |record| create(:price, variant: record, currency: 'EUR', amount: 10) }end- it 'finds not_discontinued variants' do- expect(Spree::Variant).to receive(:not_discontinued).and_return(variants)- Spree::Variant.active(currency)- end+ it 'returns variants that are not discontinued, not deleted and priced in the currency' do+ active = variant_priced_in_eur+ discontinued = variant_priced_in_eur(discontinue_on: 1.day.ago)+ deleted = variant_priced_in_eur.tap(&:destroy)+ unpriced = create(:variant)- it 'finds not_deleted variants' do- expect(variants).to receive(:not_deleted).and_return(variants)- Spree::Variant.active(currency)+ expect(Spree::Variant.active('EUR')).to include(active)+ expect(Spree::Variant.active('EUR')).not_to include(discontinued, deleted, unpriced)end-- it 'finds variants for_currency_and_available_price_amount' do- expect(variants).to receive(:for_currency_and_available_price_amount).with(currency).and_return(variants)- Spree::Variant.active(currency)- end-- it { expect(Spree::Variant.active(currency)).to eq(variants) }endend@@ -532,6 +504,8 @@ describe Spree::Variant, type: :model doexpect domulti_variant.set_option_value('media_type', 'DVD')+ multi_variant.set_option_value('media_type ', ' DVD ')+ multi_variant.set_option_value('Media_Type ', ' dvd ')end.not_to change(multi_variant.option_values, :count)expect do@@ -539,40 +513,6 @@ describe Spree::Variant, type: :model doend.to change(multi_variant.option_values, :count).by(1)endend-- context 'product has other variants' do- describe 'option value accessors' do- before do- @multi_variant = create(:variant, product: variant.product)- variant.product.reload- end-- let(:multi_variant) { @multi_variant }-- it 'sets option value' do- expect(multi_variant.option_value('media_type')).to be_nil-- multi_variant.set_option_value('media_type', 'DVD')- expect(multi_variant.option_value('media_type')).to eql 'DVD'-- multi_variant.set_option_value('media_type', 'CD')- expect(multi_variant.option_value('media_type')).to eql 'CD'- end-- it 'does not duplicate associated option values when set multiple times' do- multi_variant.set_option_value('media_type', 'CD')-- expect do- multi_variant.set_option_value('media_type ', ' DVD ')- multi_variant.set_option_value('Media_Type ', ' dvd ')- end.not_to change(multi_variant.option_values, :count)-- expect do- multi_variant.set_option_value('coolness_type', 'awesome')- end.to change(multi_variant.option_values, :count).by(1)- end- end- endenddescribe '#cost_price=' do@@ -650,13 +590,6 @@ describe Spree::Variant, type: :model doendend- describe '#price_in' do- it 'returns a price whose display amount is a Spree::Money' do- variant.set_price('USD', 21.22)- expect(variant.price_in('USD').display_amount.to_s).to eql '$21.22'- end- end-describe '#cost_currency' docontext 'when cost currency is nil' dobefore { variant.cost_currency = nil }@@ -1002,14 +935,6 @@ describe Spree::Variant, type: :model doendend- # Regression test for #2744- describe 'set_position' do- it 'sets variant position after creation' do- variant = create(:variant)- expect(variant.position).not_to be_nil- end- end-describe '#in_stock?' dobefore dostub_store_preferences(track_inventory_levels: true)@@ -1042,16 +967,6 @@ describe Spree::Variant, type: :model doendend- describe '#can_supply?' do- before { variant }-- it 'calls out to quantifier' do- expect(Spree::Stock::Quantifier).to receive(:new).and_return(quantifier = double)- expect(quantifier).to receive(:can_supply?).with(10)- variant.can_supply?(10)- end- end-context 'when stock_levels are backorderable' dobefore doallow_any_instance_of(Spree::StockLevel).to receive_messages(backorderable: true)@@ -1073,17 +988,6 @@ describe Spree::Variant, type: :model doendend- describe '#is_backorderable' do- subject { variant.is_backorderable? }-- let(:variant) { build(:variant) }-- it 'invokes Spree::Stock::Quantifier' do- expect_any_instance_of(Spree::Stock::Quantifier).to receive(:backorderable?).and_return(true)- subject- end- end-describe '#purchasable?' docontext 'when stock_levels are not backorderable' dobefore do@@ -1125,16 +1029,6 @@ describe Spree::Variant, type: :model doexpect(variant.purchasable?).to be trueendend-- context 'when stock_levels are not backorderable' do- before do- allow_any_instance_of(Spree::StockLevel).to receive_messages(backorderable: false)- end-- it 'return false if stock_levels are not backorderable' do- expect(variant.purchasable?).to be false- end- endendend@@ -1143,11 +1037,6 @@ describe Spree::Variant, type: :model dostub_store_preferences(track_inventory_levels: false)expect(build(:variant).total_on_hand).to eql(Float::INFINITY)end-- it 'matches quantifier total_on_hand' do- variant = build(:variant)- expect(variant.total_on_hand).to eq(Spree::Stock::Quantifier.new(variant).total_on_hand)- endenddescribe '#tax_category' do@@ -1397,18 +1286,6 @@ describe Spree::Variant, type: :model doendend- describe '#created_at' do- it 'creates variant with created_at timestamp' do- expect(variant.created_at).not_to be_nil- end- end-- describe '#updated_at' do- it 'creates variant with updated_at timestamp' do- expect(variant.updated_at).not_to be_nil- end- end-describe '#backordered?' dolet!(:variant) { create(:variant) }@@ -1479,12 +1356,15 @@ describe Spree::Variant, type: :model dodescribe '#secondary_image' dolet(:variant) { create(:variant) }+ before { allow(Spree::Deprecation).to receive(:warn) }+context 'with images pinned to the variant' dolet!(:image1) { create(:media, position: 1, viewable: variant) }let!(:image2) { create(:media, position: 2, viewable: variant) }it 'returns the second image' doexpect(variant.secondary_image).to eq(image2)+ expect(Spree::Deprecation).to have_received(:warn).with(/Variant#secondary_image is deprecated/)endend@@ -1507,6 +1387,7 @@ describe Spree::Variant, type: :model dolet!(:image3) { create(:media, position: 3, viewable: variant) }it 'returns all images except the default' do+ expect(Spree::Deprecation).to receive(:warn).with(/Variant#additional_images is deprecated/)expect(variant.additional_images).to eq([image2, image3])endend@@ -1553,27 +1434,12 @@ describe Spree::Variant, type: :model dolet(:product) { create(:product) }describe 'variant_count on product' do- it 'counts the default variant' do- expect(product.reload.variant_count).to eq(1)- end-- it 'increments when a variant is created' do- expect {- create(:variant, product: product)- }.to change { product.reload.variant_count }.from(1).to(2)- end-it 'decrements when a variant is destroyed' dovariant = create(:variant, product: product)expect {variant.destroy}.to change { product.reload.variant_count }.from(2).to(1)end-- it 'correctly counts multiple variants' do- create_list(:variant, 3, product: product)- expect(product.reload.variant_count).to eq(4)- endendend@@ -1714,14 +1580,6 @@ describe Spree::Variant, type: :model doenddescribe '#options=' do- it 'sets option values via set_option_value' do- product = create(:product)- v = create(:variant, product: product)- v.set_option_value('color', 'blue')-- expect(v.option_values.reload.map(&:name)).to include('blue')- end-it 'calls set_option_value for each option hash' doproduct = create(:product)v = create(:variant, product: product)diff --git a/spree/core/spec/models/spree/webhook_delivery_spec.rb b/spree/core/spec/models/spree/webhook_delivery_spec.rbindex 1bb34c2435..11787b0c2c 100644--- a/spree/core/spec/models/spree/webhook_delivery_spec.rb+++ b/spree/core/spec/models/spree/webhook_delivery_spec.rb@@ -5,7 +5,6 @@ require 'spec_helper'describe Spree::WebhookDelivery, type: :model dolet(:store) { @default_store }let(:webhook_endpoint) { create(:webhook_endpoint, store: store) }- let(:webhook_delivery) { build(:webhook_delivery, webhook_endpoint: webhook_endpoint) }describe 'scopes' dolet!(:pending_delivery) { create(:webhook_delivery, :pending, webhook_endpoint: webhook_endpoint) }diff --git a/spree/core/spec/models/spree/webhook_endpoint_spec.rb b/spree/core/spec/models/spree/webhook_endpoint_spec.rbindex 70ee2971b1..7d38b97812 100644--- a/spree/core/spec/models/spree/webhook_endpoint_spec.rb+++ b/spree/core/spec/models/spree/webhook_endpoint_spec.rb@@ -44,23 +44,6 @@ describe Spree::WebhookEndpoint, type: :model doexpect(webhook_endpoint.errors[:url]).to include('must not point to an internal or private network address')endend-- describe 'active inclusion' do- it 'accepts true' do- webhook_endpoint.active = true- expect(webhook_endpoint).to be_valid- end-- it 'accepts false' do- webhook_endpoint.active = false- expect(webhook_endpoint).to be_valid- end-- it 'rejects nil' do- webhook_endpoint.active = nil- expect(webhook_endpoint).not_to be_valid- end- endenddescribe 'callbacks' do@@ -173,23 +156,6 @@ describe Spree::WebhookEndpoint, type: :model doexpect(endpoint.subscribed_to?('shipment.shipped')).to be falseendend-- context 'with mixed subscriptions' do- let(:endpoint) { build(:webhook_endpoint, subscriptions: ['order.*', 'product.created']) }-- it 'matches pattern events' do- expect(endpoint.subscribed_to?('order.created')).to be true- expect(endpoint.subscribed_to?('order.placed')).to be true- end-- it 'matches exact events' do- expect(endpoint.subscribed_to?('product.created')).to be true- end-- it 'does not match non-subscribed events' do- expect(endpoint.subscribed_to?('product.updated')).to be false- end- endenddescribe '#subscribed_events' do@@ -355,14 +321,4 @@ describe Spree::WebhookEndpoint, type: :model doendendend-- describe 'soft delete' do- let!(:endpoint) { create(:webhook_endpoint, store: store) }-- it 'soft deletes the record' do- endpoint.destroy- expect(endpoint.deleted_at).to be_present- expect(described_class.with_deleted.find(endpoint.id)).to eq(endpoint)- end- endenddiff --git a/spree/core/spec/models/spree/wishlist_item_spec.rb b/spree/core/spec/models/spree/wishlist_item_spec.rbindex 6a65afc8fd..346c225811 100644--- a/spree/core/spec/models/spree/wishlist_item_spec.rb+++ b/spree/core/spec/models/spree/wishlist_item_spec.rb@@ -4,42 +4,9 @@ RSpec.describe Spree::WishlistItem, type: :model doit_behaves_like 'lifecycle events'describe '.quantity' do- subject { build(:wishlist_item) }-- let!(:wishlist) { create(:wishlist) }let!(:variant) { create(:variant) }let!(:wishlist_item_with_variant) { create(:wishlist_item, variant: variant, quantity: 3) }- it { is_expected.to respond_to(:quantity) }- it { expect(subject.quantity).to eq(1) }-- it 'validates presence of wishlist' do- expect(described_class.new(quantity: 3, wishlist: nil, variant: variant)).not_to be_valid- end-- it 'validates presence of variant' do- expect(described_class.new(quantity: 3, wishlist: wishlist, variant: nil)).not_to be_valid- end-- it 'validates numericality of quantity' do- expect(described_class.new(quantity: nil, wishlist: wishlist, variant: variant)).not_to be_valid- expect(described_class.new(quantity: 'string', wishlist: wishlist, variant: variant)).not_to be_valid- expect(described_class.new(quantity: 0.5, wishlist: wishlist, variant: variant)).not_to be_valid- end-- it 'validates numericality must be greater than 0' do- expect(described_class.new(quantity: 0, wishlist: wishlist, variant: variant)).not_to be_valid- expect(described_class.new(quantity: -1, wishlist: wishlist, variant: variant)).not_to be_valid- end-- describe 'when wishlist_item is already associated with the wishlist' do- let!(:existing_wishlist_item) { create(:wishlist_item, quantity: 3, wishlist: wishlist, variant: variant) }-- it 'validates uniqueness of variant within scope of wishlist' do- expect(described_class.new(quantity: 2, wishlist: wishlist, variant: variant)).not_to be_valid- end- end-describe '.price' doit { expect(wishlist_item_with_variant.price(currency: 'USD')).to eq(variant.amount_in('USD')) }enddiff --git a/spree/core/spec/models/spree/wishlist_spec.rb b/spree/core/spec/models/spree/wishlist_spec.rbindex e21a5e8ca6..8ec13dd6b0 100644--- a/spree/core/spec/models/spree/wishlist_spec.rb+++ b/spree/core/spec/models/spree/wishlist_spec.rb@@ -10,38 +10,7 @@ describe Spree::Wishlist, type: :model dolet(:wishlist_belonging_to_other_store) { create(:wishlist, customer: user, name: 'My Wishlist', store: other_store, is_default: true) }let(:wishlist_belonging_to_other_user) { create(:wishlist, customer: other_user, name: 'My Wishlist', store: store, is_default: true) }- describe 'lifecycle events', events: true do- describe 'wishlist.created' do- it 'publishes created event when record is created' do- record = build(:wishlist, customer: user, store: store)- expect(record).to receive(:publish_event).with('wishlist.created')- allow(record).to receive(:publish_event).with(anything)-- record.save!- end- end-- describe 'wishlist.updated' do- it 'publishes updated event when record is updated' do- expect(wishlist).to receive(:publish_event).with('wishlist.updated')- allow(wishlist).to receive(:publish_event).with(anything)-- Timecop.travel(1.minute.from_now) do- wishlist.update_attribute(:updated_at, Time.current)- end- end- end-- describe 'wishlist.deleted' do- it 'publishes deleted event when record is destroyed' do- record = create(:wishlist, customer: user, store: store)- expect(record).to receive(:publish_event).with('wishlist.deleted', kind_of(Hash))- allow(record).to receive(:publish_event).with(anything)-- record.destroy!- end- end- end+ it_behaves_like 'lifecycle events'describe '.ensure_default_exists_and_is_unique' docontext 'when user creates a new default store' do@@ -53,7 +22,7 @@ describe Spree::Wishlist, type: :model doendit 'preserves is_default: true for new wishlist' do- expect(new_wl.is_default).to be true+ expect(new_wl.reload.is_default).to be trueendit 'sets is_default: false on the wishlist that was the previous default' do@@ -90,16 +59,6 @@ describe Spree::Wishlist, type: :model doendend- describe '#destroy' do- let!(:wishlist_item) { create(:wishlist_item) }-- it 'deletes associated wishlist items' do- expect do- wishlist_item.wishlist.destroy- end.to change(Spree::WishlistItem, :count).by(-1)- end- end-describe '#product_ids' dolet(:product) { create(:product) }let(:variant) { create(:variant, product: product) }@@ -115,32 +74,6 @@ describe Spree::Wishlist, type: :model doendend- describe '#wishlist_items_count' do- let(:variant) { create(:variant) }-- before do- wishlist.wishlist_items << create(:wishlist_item, variant: variant)- end-- it 'returns the wishlist items count' do- expect(wishlist.wishlist_items_count).to eq 1- end- end-- describe '#variant_ids' do- let(:variant) { create(:variant) }- let(:variant_2) { create(:variant) }-- before do- wishlist.wishlist_items << create(:wishlist_item, variant: variant)- wishlist.wishlist_items << create(:wishlist_item, variant: variant_2)- end-- it 'returns the variant ids' do- expect(wishlist.variant_ids).to eq [variant.id, variant_2.id]- end- end-describe '#wished_items_count' do# The pre-6.0 name stays callable for one release.it 'delegates to the renamed counter' dodiff --git a/spree/core/spec/presenters/spree/csv/order_line_items_presenter_spec.rb b/spree/core/spec/presenters/spree/csv/order_line_items_presenter_spec.rbindex 73d24ba2b7..e6cd373295 100644--- a/spree/core/spec/presenters/spree/csv/order_line_items_presenter_spec.rb+++ b/spree/core/spec/presenters/spree/csv/order_line_items_presenter_spec.rb@@ -24,7 +24,7 @@ RSpec.describe Spree::CSV::OrderLineItemPresenter doexpect(subject[5]).to eq money(order.delivery_total)expect(subject[6]).to eq money(order.tax_total)expect(subject[7]).to eq order.included_tax_total.positive?- expect(subject[8]).to eq(order.promo_total.negative? || line_item.promo_total.negative?)+ expect(subject[8]).to eq(order.discount_total.negative? || line_item.promo_total.negative?)expect(subject[9]).to eq order.has_free_shipping?expect(subject[10]).to eq money(order.discount_total.abs)expect(subject[11]).to eq order.promo_codediff --git a/spree/core/spec/services/spree/orders/create_spec.rb b/spree/core/spec/services/spree/orders/create_spec.rbindex 5e54d6e8c6..b52f93879b 100644--- a/spree/core/spec/services/spree/orders/create_spec.rb+++ b/spree/core/spec/services/spree/orders/create_spec.rb@@ -61,7 +61,7 @@ module Spreeexpect(order).to be_persistedexpect(order.status).to eq('draft')expect(order.shipments).to be_empty- expect(order.shipment_total).to eq(0)+ expect(order.delivery_total).to eq(0)endend@@ -78,7 +78,7 @@ module Spreeorder = subject.valueexpect(order.line_items.count).to eq(1)expect(order.shipments).to be_empty- expect(order.shipment_total).to eq(0)+ expect(order.delivery_total).to eq(0)expect(order.total).to eq(order.item_total)endend@@ -96,7 +96,7 @@ module Spreeorder = subject.valueexpect(order.ship_address).to be_presentexpect(order.shipments).to be_empty- expect(order.shipment_total).to eq(0)+ expect(order.delivery_total).to eq(0)endend@@ -118,14 +118,14 @@ module Spreeexpect(order.fulfillments.first.shipping_rates).not_to be_emptyexpect(order.fulfillments.first.selected_shipping_rate).to be_present- expect(order.shipment_total).to eq(5)- expect(order.total).to eq(order.item_total + order.shipment_total + order.adjustment_total)+ expect(order.delivery_total).to eq(5)+ expect(order.total).to eq(order.item_total + order.delivery_total + order.adjustment_total)endit 'persists the totals to the database' dosubjectorder = subject.value.reload- expect(order.shipment_total).to eq(5)+ expect(order.delivery_total).to eq(5)expect(order.total).to eq(order.item_total + 5 + order.adjustment_total)endend@@ -146,7 +146,7 @@ module Spreeit 'does not build shipments' doexpect(subject).to be_successexpect(subject.value.shipments).to be_empty- expect(subject.value.shipment_total).to eq(0)+ expect(subject.value.delivery_total).to eq(0)endend@@ -170,13 +170,13 @@ module Spree# Shipments still exist, gross cost is still 5 (cost column on the shipment)expect(order.shipments.size).to eq(1)- expect(order.shipment_total).to eq(5)+ expect(order.delivery_total).to eq(5)# Promo created a -5 adjustment on the shipmentshipment = order.fulfillments.firstexpect(shipment.adjustment_total).to eq(-5)expect(shipment.discounts.promotion.size).to eq(1)- expect(order.shipping_discount).to eq(5)+ expect(order.fulfillment_discount).to eq(5)# Promotion is associated with the orderexpect(order.promotions).to include(promotion)@@ -229,7 +229,7 @@ module Spreeshipment = order.fulfillments.firstexpect(shipment).to be_presentexpect(shipment.adjustment_total).to eq(-5)- expect(order.shipping_discount).to eq(5)+ expect(order.fulfillment_discount).to eq(5)expect(order.total).to eq(order.item_total)endenddiff --git a/spree/core/spec/services/spree/orders/update_spec.rb b/spree/core/spec/services/spree/orders/update_spec.rbindex a1923ac640..891d5fc7b7 100644--- a/spree/core/spec/services/spree/orders/update_spec.rb+++ b/spree/core/spec/services/spree/orders/update_spec.rb@@ -158,7 +158,7 @@ module Spreeit 'starts with shipments built from the seeded data' doexpect(order.shipments).not_to be_empty- expect(order.shipment_total).to eq(5)+ expect(order.delivery_total).to eq(5)endcontext 'when items change' do@@ -176,7 +176,7 @@ module Spreeexpect(new_shipment_ids).not_to be_emptyexpect(new_shipment_ids & old_shipment_ids).to be_emptyexpect(order.fulfillments.first.inventory_units.sum(:quantity)).to eq(3)- expect(order.shipment_total).to eq(5)+ expect(order.delivery_total).to eq(5)endend@@ -386,7 +386,7 @@ module Spreeorder.reloadexpect(order.line_items.first.quantity).to eq(2)expect(order.item_total).to eq(variant.amount_in(order.currency) * 2)- expect(order.total).to eq(order.item_total + order.shipment_total + order.adjustment_total)+ expect(order.total).to eq(order.item_total + order.delivery_total + order.adjustment_total)endend@@ -402,7 +402,7 @@ module Spreeshipment = order.fulfillments.firstexpect(shipment).to be_presentexpect(shipment.adjustment_total).to eq(-5)- expect(order.shipping_discount).to eq(5)+ expect(order.fulfillment_discount).to eq(5)expect(order.total).to eq(order.item_total)end@@ -410,7 +410,7 @@ module Spree# Seed: order with line item + shipments + promo applieddescribed_class.call(order: order, params: { items: [{ variant_id: variant.prefixed_id, quantity: 1 }] })order.reload- expect(order.shipping_discount).to eq(5)+ expect(order.fulfillment_discount).to eq(5)# Move to a different country — shipments rebuild, promo must re-applydescribed_class.call(order: order, params: {@@ -425,7 +425,7 @@ module Spreeorder.reloadexpect(order.fulfillments.first.adjustment_total).to eq(-5)- expect(order.shipping_discount).to eq(5)+ expect(order.fulfillment_discount).to eq(5)expect(order.total).to eq(order.item_total)endenddiff --git a/spree/core/spec/services/spree/products/duplicator_spec.rb b/spree/core/spec/services/spree/products/duplicator_spec.rbindex 3f292f990d..4d5cc14534 100644--- a/spree/core/spec/services/spree/products/duplicator_spec.rb+++ b/spree/core/spec/services/spree/products/duplicator_spec.rb@@ -43,13 +43,13 @@ RSpec.describe Spree::Products::Duplicator do# A promise belongs to the order that made it. Copied onto the duplicate,# it would open holding stock for somebody else's order.it 'starts the copy with no stock and no promise' do- original = product.variants_including_master.first+ original = product.variants.firstlevel = original.stock_levels.firstlevel.update_columns(count_on_hand: 7, allocated_count: 3)new_product = subject.value- new_product.variants_including_master.flat_map(&:stock_levels).each do |copy|+ new_product.variants.flat_map(&:stock_levels).each do |copy|expect(copy.count_on_hand).to eq(0)expect(copy.allocated_count).to eq(0)enddiff --git a/spree/core/spec/services/spree/stock_locations/stock_levels/create_spec.rb b/spree/core/spec/services/spree/stock_locations/stock_levels/create_spec.rbindex a0d9c0b12b..a7ba09d9df 100644--- a/spree/core/spec/services/spree/stock_locations/stock_levels/create_spec.rb+++ b/spree/core/spec/services/spree/stock_locations/stock_levels/create_spec.rb@@ -83,7 +83,7 @@ module Spreeresult- expect(stock_location.stock_levels.pluck(:variant_id)).to match_array(own.product.variants_including_master.ids)+ expect(stock_location.stock_levels.pluck(:variant_id)).to match_array(own.product.variants.ids)endenddiff --git a/spree/core/spec/services/spree/stock_reservations/extend_spec.rb b/spree/core/spec/services/spree/stock_reservations/extend_spec.rbindex 61122b7c6a..238d6925dc 100644--- a/spree/core/spec/services/spree/stock_reservations/extend_spec.rb+++ b/spree/core/spec/services/spree/stock_reservations/extend_spec.rb@@ -10,7 +10,7 @@ describe Spree::StockReservations::Extend doit 'pushes expires_at out by the store TTL' doTimecop.freeze do- described_class.call(order: order)+ described_class.call(cart: order)expect(reservation.reload.expires_at).to be_within(1.second).of(12.minutes.from_now)endend@@ -20,7 +20,7 @@ describe Spree::StockReservations::Extend doother_reservation = create(:stock_reservation, order: other_order, expires_at: 1.minute.from_now)original_other_expires_at = other_reservation.expires_at- described_class.call(order: order)+ described_class.call(cart: order)expect(other_reservation.reload.expires_at).to be_within(1.second).of(original_other_expires_at)end@@ -31,7 +31,7 @@ describe Spree::StockReservations::Extend doit 'leaves expires_at untouched' dooriginal = reservation.expires_at- described_class.call(order: order)+ described_class.call(cart: order)expect(reservation.reload.expires_at).to be_within(1.second).of(original)endenddiff --git a/spree/core/spec/services/spree/stock_reservations/reserve_spec.rb b/spree/core/spec/services/spree/stock_reservations/reserve_spec.rbindex b25224b88f..cb27a5cdb9 100644--- a/spree/core/spec/services/spree/stock_reservations/reserve_spec.rb+++ b/spree/core/spec/services/spree/stock_reservations/reserve_spec.rb@@ -8,7 +8,7 @@ describe Spree::StockReservations::Reserve dolet(:order) { create(:order, store: store) }let!(:line_item) { create(:line_item, order: order, variant: variant, quantity: 3) }- subject(:result) { described_class.call(order: order) }+ subject(:result) { described_class.call(cart: order) }context 'when stock_reservations_enabled is true' dobefore { stub_store_preferences(store, stock_reservations_enabled: true) }@@ -33,8 +33,8 @@ describe Spree::StockReservations::Reserve doendit 'is idempotent — calling twice updates the same reservation, not creating a new one' do- described_class.call(order: order)- expect { described_class.call(order: order) }.not_to change(Spree::StockReservation, :count)+ described_class.call(cart: order)+ expect { described_class.call(cart: order) }.not_to change(Spree::StockReservation, :count)endit 'holds the units on the level, and re-holding moves the figure by the difference' do@@ -42,7 +42,7 @@ describe Spree::StockReservations::Reserve doline_item.update!(quantity: 5)- expect { described_class.call(order: order) }.to change { stock_level.reload.reserved_count }.from(3).to(5)+ expect { described_class.call(cart: order) }.to change { stock_level.reload.reserved_count }.from(3).to(5)end# A hold that lapsed and was revived by a later edit is a hold again, and@@ -51,7 +51,7 @@ describe Spree::StockReservations::Reserve doresultSpree::StockReservation.last.update_column(:expires_at, 1.minute.ago)- described_class.call(order: order)+ described_class.call(cart: order)expect(Spree::StockReservation.last).to be_activeexpect(stock_level.reload.reserved_count).to eq(3)diff --git a/spree/core/spec/services/spree/store_credits/apply_spec.rb b/spree/core/spec/services/spree/store_credits/apply_spec.rbindex 765ef091c0..b2e97f39f1 100644--- a/spree/core/spec/services/spree/store_credits/apply_spec.rb+++ b/spree/core/spec/services/spree/store_credits/apply_spec.rb@@ -141,7 +141,7 @@ describe Spree::StoreCredits::Apply, type: :service dodescribed_class.call(order: order.reload)payment = order.reload.payments.store_credits.checkout.first- payment.purchase!+ Spree.payment_process_workflow.call(payment: payment, action: :purchase)expect(payment.reload).to be_completedexpect(store_credit.reload.amount_used).to eq(300)diff --git a/spree/core/spec/subscribers/spree/order_status_subscriber_spec.rb b/spree/core/spec/subscribers/spree/order_status_subscriber_spec.rbindex 4b61876d76..4c10f25669 100644--- a/spree/core/spec/subscribers/spree/order_status_subscriber_spec.rb+++ b/spree/core/spec/subscribers/spree/order_status_subscriber_spec.rb@@ -101,7 +101,7 @@ RSpec.describe Spree::OrderStatusSubscriber dopayment = create(:payment, order: order, cart: nil, amount: order.total, status: 'pending')order.update_columns(payment_status: 'none')- payment.capture!+ Spree.payment_capture_workflow.call(payment: payment)expect(order.reload.payment_status).to eq('paid')enddiff --git a/spree/core/spec/workflows/spree/carts/recalculate_totals_spec.rb b/spree/core/spec/workflows/spree/carts/recalculate_totals_spec.rbindex aab7a826c8..ee5fc12df0 100644--- a/spree/core/spec/workflows/spree/carts/recalculate_totals_spec.rb+++ b/spree/core/spec/workflows/spree/carts/recalculate_totals_spec.rb@@ -243,7 +243,7 @@ module Spreeline_item.update_column(:price, 25)described_class.call(cart: cart)- gift_card_payment.purchase!+ Spree.payment_process_workflow.call(payment: gift_card_payment, action: :purchase)expect(gift_card_payment.reload).to be_completedenddiff --git a/spree/core/spec/workflows/spree/fulfillments/create_spec.rb b/spree/core/spec/workflows/spree/fulfillments/create_spec.rbindex c2aa889f3e..8e67240371 100644--- a/spree/core/spec/workflows/spree/fulfillments/create_spec.rb+++ b/spree/core/spec/workflows/spree/fulfillments/create_spec.rb@@ -241,7 +241,7 @@ module Spreeit 'inherits the first non-nil method when draining sources with different carriers' doother_method = create(:delivery_method)second_source = order.shipments.create!(stock_location: stock_location)- second_source.add_shipping_method(other_method, true)+ second_source.add_delivery_method(other_method, true)line_items.last.inventory_units.update_all(shipment_id: second_source.id)first_source_method = source_shipment.delivery_method@@ -273,7 +273,7 @@ module Spreeit 'freezes the given cost instead of the inherited one' doexpect(execute.success?).to eq(true)expect(fulfillment.cost).to eq(BigDecimal('7.42'))- expect(order.reload.shipment_total).to eq(BigDecimal('7.42'))+ expect(order.reload.delivery_total).to eq(BigDecimal('7.42'))endit 'prices the carrier rate at the given cost' dodiff --git a/spree/core/spec/workflows/spree/payments/handle_webhook_spec.rb b/spree/core/spec/workflows/spree/payments/handle_webhook_spec.rbindex 68b96630fd..b1b5fa72ee 100644--- a/spree/core/spec/workflows/spree/payments/handle_webhook_spec.rb+++ b/spree/core/spec/workflows/spree/payments/handle_webhook_spec.rb@@ -65,7 +65,7 @@ RSpec.describe Spree::Payments::HandleWebhook doit 'completes the payment' dosubject.call(payment_method: payment_method, action: :captured, payment_session: payment_session)- expect(order.reload.payments.first.state).to eq('completed')+ expect(order.reload.payments.first.status).to eq('completed')endit 'completes the order with payment_state=paid' do@@ -91,7 +91,7 @@ RSpec.describe Spree::Payments::HandleWebhook doexpect(result).to be_successexpect(order.reload.payments.count).to eq(1)- expect(order.payments.first.state).to eq('pending')+ expect(order.payments.first.status).to eq('pending')endit 'completes the payment session' dodiff --git a/spree/core/spec/workflows/spree/sellers/onboarding_lifecycle_spec.rb b/spree/core/spec/workflows/spree/sellers/onboarding_lifecycle_spec.rbindex fd39189e27..746672ccf8 100644--- a/spree/core/spec/workflows/spree/sellers/onboarding_lifecycle_spec.rb+++ b/spree/core/spec/workflows/spree/sellers/onboarding_lifecycle_spec.rb@@ -80,7 +80,7 @@ RSpec.describe 'seller onboarding lifecycle' dorole: seller.default_user_role)invitation.update!(invitee: invitee)- invitation.accept!+ expect(Spree.invitation_accept_workflow.call(invitation: invitation)).to be_successexpect(seller.reload).to be_onboardingenddiff --git a/spree/emails/spec/models/spree/order_spec.rb b/spree/emails/spec/models/spree/order_spec.rbindex c462675eea..e2eaeee361 100644--- a/spree/emails/spec/models/spree/order_spec.rb+++ b/spree/emails/spec/models/spree/order_spec.rb@@ -5,20 +5,20 @@ describe Spree::Order, type: :model dolet(:user) { create(:user) }let(:order) { create(:order, customer: user, store: store) }- context '#finalize!' do+ context 'when the order completes' dolet(:order) { create(:order, email: '[email protected]', store: store) }before doorder.update_column :status, 'placed'end- it 'publishes order.placed event when finalizing', events: true do+ it 'publishes the order.placed event', events: true doexpect(order).to receive(:publish_event).with('order.placed', kind_of(Hash), hash_including(:notify_customer))expect(order).to receive(:publish_event).with('order.completed', kind_of(Hash), hash_including(:notify_customer, deprecated_alias_of: 'order.placed'))allow(order).to receive(:publish_event).with(anything)allow(order).to receive(:publish_event).with(anything, anything)- order.finalize!+ Spree.order_complete_workflow.call(order: order, payment_pending: true)endendenddiff --git a/spree/emails/spec/models/spree/shipment_spec.rb b/spree/emails/spec/models/spree/shipment_spec.rbindex 525727d191..95b790c66b 100644--- a/spree/emails/spec/models/spree/shipment_spec.rb+++ b/spree/emails/spec/models/spree/shipment_spec.rb@@ -1,36 +1,15 @@require 'spec_helper'describe Spree::Fulfillment, type: :model do- let(:order) { create(:order) }- let(:shipping_method) { create(:delivery_method, name: 'UPS') }- let(:shipment) { create(:fulfillment, cost: 1, status: 'unfulfilled', stock_location: create(:stock_location), order: order) }+ let(:shipment) { create(:fulfillment) }- before do- allow(order).to receive_messages backordered?: false,- canceled?: false,- can_ship?: true,- paid?: false,- touch_later: false+ # The legacy shipment.* name is dual-emitted for one release, and the+ # email subscribers still listen for it.+ it 'publishes shipment.shipped event when fulfilling', events: true do+ expect(shipment).to receive(:publish_event).+ with('shipment.shipped', nil, hash_including(notify_customer: true))+ allow(shipment).to receive(:publish_event).with(any_args)- allow(shipment).to receive_messages(delivery_method: shipping_method, shipping_method: shipping_method)- end-- ['unfulfilled', 'canceled'].each do |status|- context "from #{status}" do- before do- allow(order).to receive(:update_with_updater!)- allow(shipment).to receive_messages(require_inventory: false, update_order: true, status: status)- end-- # The legacy shipment.* name is dual-emitted for one release, and the- # email subscribers still listen for it.- it 'publishes shipment.shipped event when fulfilling', events: true do- expect(shipment).to receive(:publish_event).- with('shipment.shipped', nil, hash_including(notify_customer: true))- allow(shipment).to receive(:publish_event).with(any_args)-- shipment.publish_fulfillment_fulfilled_event- end- end+ shipment.publish_fulfillment_fulfilled_eventendenddiff --git a/spree/providers/easypost/spec/models/spree_easypost/customs_params_spec.rb b/spree/providers/easypost/spec/models/spree_easypost/customs_params_spec.rbindex d84a42a0a7..963eff3f6b 100644--- a/spree/providers/easypost/spec/models/spree_easypost/customs_params_spec.rb+++ b/spree/providers/easypost/spec/models/spree_easypost/customs_params_spec.rb@@ -56,12 +56,16 @@ RSpec.describe 'SpreeEasyPost customs params' doendit 'certifies the declaration once a signer is named' do- integration = SpreeEasyPost::Integration.new(store: store, preferences: { customs_signer: 'Jane Doe' })+ integration = SpreeEasyPost::Integration.new(+ store: store,+ preferences: { customs_signer: 'Jane Doe', customs_contents_type: 'gift' }+ )params = SpreeEasyPost.customs_info_params(package, origin, foreign_destination, integration)expect(params[:customs_certify]).to be trueexpect(params[:customs_signer]).to eq('Jane Doe')+ expect(params[:contents_type]).to eq('gift')endit 'carries the variant classification when the merchant recorded it' do@@ -84,18 +88,6 @@ RSpec.describe 'SpreeEasyPost customs params' doexpect(item[:description]).to eq(variant.name)end- it 'takes the signer and contents type from the integration when configured' do- integration = SpreeEasyPost::Integration.new(- store: store,- preferences: { customs_signer: 'Jane Doe', customs_contents_type: 'gift' }- )-- params = SpreeEasyPost.customs_info_params(package, origin, foreign_destination, integration)-- expect(params[:customs_signer]).to eq('Jane Doe')- expect(params[:contents_type]).to eq('gift')- end-it 'defaults the incoterm to DAP so the recipient is billed for duties' dointegration = SpreeEasyPost::Integration.new(store: store)diff --git a/spree/providers/easypost/spec/models/spree_easypost/delivery_rate_provider_spec.rb b/spree/providers/easypost/spec/models/spree_easypost/delivery_rate_provider_spec.rbindex f0805641e5..54e5b9e6b8 100644--- a/spree/providers/easypost/spec/models/spree_easypost/delivery_rate_provider_spec.rb+++ b/spree/providers/easypost/spec/models/spree_easypost/delivery_rate_provider_spec.rb@@ -203,18 +203,6 @@ RSpec.describe SpreeEasyPost::DeliveryRateProvider do)end- it 'converts a metric store dimensions to inches' do- store.update!(preferred_unit_system: 'metric')- store.default_package_type.update!(length: 30.48, width: 22.86, height: 10.16,- dimensions_unit: 'cm')-- provider.estimates(package)-- expect(shipment_service).to have_received(:create).with(- hash_including(parcel: hash_including(length: 12.0, width: 9.0, height: 4.0))- )- end-# A merchant can record a carton in whatever unit the supplier quoted# it in, regardless of what the store trades in. Reading centimetres as# inches overstates every axis by 2.54 and inflates the carrier'sdiff --git a/spree/providers/easypost/spec/models/spree_easypost/integration_spec.rb b/spree/providers/easypost/spec/models/spree_easypost/integration_spec.rbindex 50955a967b..be1f8bb821 100644--- a/spree/providers/easypost/spec/models/spree_easypost/integration_spec.rb+++ b/spree/providers/easypost/spec/models/spree_easypost/integration_spec.rb@@ -39,7 +39,6 @@ RSpec.describe SpreeEasyPost::Integration dointegration.can_connect?expect(address_service).to have_received(:create).with(described_class::VERIFICATION_ADDRESS)- expect(client).not_to respond_to(:carrier_account)endit 'captures the vendor message on failure' do@@ -76,14 +75,4 @@ RSpec.describe SpreeEasyPost::Integration doendendend-- describe 'verify before activate' do- it 'blocks activation when the connection fails' do- allow(integration).to receive(:can_connect?).and_return(false)- integration.active = true-- expect(integration).not_to be_valid- expect(integration.errors[:base]).to be_present- end- endenddiff --git a/spree/providers/meilisearch/spec/models/spree_meilisearch/search_provider_spec.rb b/spree/providers/meilisearch/spec/models/spree_meilisearch/search_provider_spec.rbindex 939c4d0fd9..3204902e6c 100644--- a/spree/providers/meilisearch/spec/models/spree_meilisearch/search_provider_spec.rb+++ b/spree/providers/meilisearch/spec/models/spree_meilisearch/search_provider_spec.rb@@ -39,11 +39,6 @@ RSpec.describe SpreeMeilisearch::SearchProvider doallow(mock_index).to receive(:search).and_return(ms_response)end- it 'returns a SearchResult' do- result = provider.search_and_filter(scope: store.products, query: 'shirt')- expect(result).to be_a(Spree::SearchProvider::SearchResult)- end-it 'queries Meilisearch with the search term' doexpect(mock_index).to receive(:search).with('shirt', hash_including(:page, :hitsPerPage))provider.search_and_filter(scope: store.products, query: 'shirt')@@ -59,11 +54,6 @@ RSpec.describe SpreeMeilisearch::SearchProvider doexpect(result.total_count).to eq(2)end- it 'does not request facets from Meilisearch' do- expect(mock_index).to receive(:search).with(anything, satisfy { |params| !params.key?(:facets) })- provider.search_and_filter(scope: store.products, query: 'shirt')- end-context 'listing all products (no query, no filters)' doit 'searches an empty query with only system conditions and no facets' doexpect(mock_index).to receive(:search).with('', satisfy { |p|@@ -315,11 +305,6 @@ RSpec.describe SpreeMeilisearch::SearchProvider doallow(mock_index).to receive(:search).and_return(ms_response)end- it 'returns a FiltersResult' do- result = provider.filters(scope: store.products, query: 'shirt')- expect(result).to be_a(Spree::SearchProvider::FiltersResult)- end-it 'returns facets from Meilisearch' doresult = provider.filters(scope: store.products, query: 'shirt')expect(result.filters).to be_an(Array)@@ -346,10 +331,10 @@ RSpec.describe SpreeMeilisearch::SearchProvider doendend- it 'returns sort options as objects' do+ it 'returns sort options as objects, including manual (sourced from Collection::SORT_ORDERS)' doresult = provider.filters(scope: store.products, query: 'shirt')ids = result.sort_options.map { |o| o[:id] }- expect(ids).to include('price', '-price')+ expect(ids).to include('price', '-price', 'manual')endit 'returns total count' do@@ -441,11 +426,6 @@ RSpec.describe SpreeMeilisearch::SearchProvider doexpect(result.default_sort).to eq('manual')endend-- it 'advertises manual in the sort options (sourced from Collection::SORT_ORDERS)' do- result = provider.filters(scope: store.products, query: '')- expect(result.sort_options.map { |o| o[:id] }).to include('manual')- endenddescribe '#index' do@@ -493,15 +473,6 @@ RSpec.describe SpreeMeilisearch::SearchProvider doenddescribe '#reindex' do- it 'configures index settings' do- expect(mock_index).to receive(:update_filterable_attributes)- expect(mock_index).to receive(:update_sortable_attributes)- expect(mock_index).to receive(:update_searchable_attributes)- allow(mock_index).to receive(:add_documents)-- provider.reindex(store.products)- end-it 'indexes all products in batches' doexpect(mock_index).to receive(:add_documents).at_least(:once)provider.reindex(store.products)diff --git a/spree/providers/meilisearch/spec/presenters/spree_meilisearch/product_presenter_spec.rb b/spree/providers/meilisearch/spec/presenters/spree_meilisearch/product_presenter_spec.rbindex c867c4ae87..786027e527 100644--- a/spree/providers/meilisearch/spec/presenters/spree_meilisearch/product_presenter_spec.rb+++ b/spree/providers/meilisearch/spec/presenters/spree_meilisearch/product_presenter_spec.rb@@ -271,7 +271,7 @@ RSpec.describe SpreeMeilisearch::ProductPresenter doit 'uses the same cf_* attributes on every market/locale document' docreate(:market, store: store, name: 'US', currency: 'USD', default_locale: 'en')create(:market, store: store, name: 'EU', currency: 'EUR', default_locale: 'de')- create(:price, variant: product.master, amount: 9.99, currency: 'EUR')+ create(:price, variant: product.default_variant, amount: 9.99, currency: 'EUR')docs = described_class.new(product.reload, store.reload).callexpect(docs.size).to be > 1diff --git a/spree/providers/stripe/spec/models/spree/payment_sessions/stripe_spec.rb b/spree/providers/stripe/spec/models/spree/payment_sessions/stripe_spec.rbindex df3c2f5175..4fe51a7c66 100644--- a/spree/providers/stripe/spec/models/spree/payment_sessions/stripe_spec.rb+++ b/spree/providers/stripe/spec/models/spree/payment_sessions/stripe_spec.rb@@ -18,16 +18,6 @@ RSpec.describe Spree::PaymentSessions::Stripe, type: :model docustomer_external_id: 'cus_test_123')end- describe 'STI' do- it 'uses the correct type' do- expect(payment_session.type).to eq('Spree::PaymentSessions::Stripe')- end-- it 'is a PaymentSession' do- expect(payment_session).to be_a(Spree::PaymentSession)- end- end-describe '#owner' doit 'returns the order when the session belongs to an order' doexpect(payment_session.owner).to eq(order)@@ -45,29 +35,6 @@ RSpec.describe Spree::PaymentSessions::Stripe, type: :model doendend- describe '#stripe_id' do- it 'aliases external_id' do- expect(payment_session.stripe_id).to eq('pi_test_abc123')- end- end-- describe '#client_secret' do- it 'reads from external_data' do- expect(payment_session.client_secret).to eq('pi_secret_xyz')- end-- it 'returns nil when external_data is nil' do- payment_session.external_data = nil- expect(payment_session.client_secret).to be_nil- end- end-- describe '#ephemeral_key_secret' do- it 'reads from external_data' do- expect(payment_session.ephemeral_key_secret).to eq('ek_test_key')- end- end-describe '#stripe_payment_intent' dolet(:stripe_pi) { Stripe::StripeObject.construct_from(id: 'pi_test_abc123', status: 'succeeded') }@@ -194,22 +161,4 @@ RSpec.describe Spree::PaymentSessions::Stripe, type: :model doexpect(order.payments.count).to eq(1)endend-- describe 'state machine' do- it 'starts as pending' do- expect(payment_session.status).to eq('pending')- end-- it 'can transition through the full lifecycle' do- expect(payment_session.process).to be true- expect(payment_session.complete).to be true- expect(payment_session.status).to eq('completed')- end- end-- describe '#api_options' do- it 'delegates to payment_method' do- expect(payment_session.api_options).to eq(gateway.api_options)- end- endenddiff --git a/spree/providers/stripe/spec/models/spree/payment_setup_sessions/stripe_spec.rb b/spree/providers/stripe/spec/models/spree/payment_setup_sessions/stripe_spec.rbindex 820d415c9f..d2b44434c2 100644--- a/spree/providers/stripe/spec/models/spree/payment_setup_sessions/stripe_spec.rb+++ b/spree/providers/stripe/spec/models/spree/payment_setup_sessions/stripe_spec.rb@@ -13,28 +13,6 @@ RSpec.describe Spree::PaymentSetupSessions::Stripe, type: :model doexternal_data: { 'customer_id' => 'cus_test_123' })end- describe 'STI' do- it 'uses the correct type' do- expect(setup_session.type).to eq('Spree::PaymentSetupSessions::Stripe')- end-- it 'is a PaymentSetupSession' do- expect(setup_session).to be_a(Spree::PaymentSetupSession)- end- end-- describe '#stripe_id' do- it 'aliases external_id' do- expect(setup_session.stripe_id).to eq('seti_test_abc123')- end- end-- describe '#client_secret' do- it 'aliases external_client_secret' do- expect(setup_session.client_secret).to eq('seti_test_abc123_secret_xyz')- end- end-describe '#stripe_setup_intent' dolet(:stripe_setup_intent) { Stripe::StripeObject.construct_from(id: 'seti_test_abc123', status: 'succeeded') }@@ -62,10 +40,4 @@ RSpec.describe Spree::PaymentSetupSessions::Stripe, type: :model doexpect(setup_session.successful?).to be falseendend-- describe '#api_options' do- it 'delegates to payment_method' do- expect(setup_session.api_options).to eq(gateway.api_options)- end- endenddiff --git a/spree/providers/stripe/spec/models/spree_stripe/gateway/payment_sessions_spec.rb b/spree/providers/stripe/spec/models/spree_stripe/gateway/payment_sessions_spec.rbindex 2ba69a4f22..cbeb82047c 100644--- a/spree/providers/stripe/spec/models/spree_stripe/gateway/payment_sessions_spec.rb+++ b/spree/providers/stripe/spec/models/spree_stripe/gateway/payment_sessions_spec.rb@@ -28,18 +28,6 @@ RSpec.describe SpreeStripe::Gateway::PaymentSessions doallow(gateway).to receive(:create_ephemeral_key).and_return(ephemeral_key_response)end- describe '#session_required?' do- it 'returns true' do- expect(gateway.session_required?).to be true- end- end-- describe '#payment_session_class' do- it 'returns Spree::PaymentSessions::Stripe' do- expect(gateway.payment_session_class).to eq(Spree::PaymentSessions::Stripe)- end- end-describe '#create_payment_session' dosubject { gateway.create_payment_session(order: order) }@@ -294,7 +282,7 @@ RSpec.describe SpreeStripe::Gateway::PaymentSessions docontext 'when the payment intent is accepted and succeeded' dolet(:stripe_pi) { Stripe::StripeObject.construct_from(id: 'pi_complete_123', status: 'succeeded', latest_charge: 'ch_test_123', payment_method: { type: 'card' }) }- let(:payment) { create(:payment, order: order, payment_method: gateway, amount: order.total, state: 'checkout') }+ let(:payment) { create(:payment, order: order, payment_method: gateway, amount: order.total, status: 'checkout') }before doallow(gateway).to receive(:retrieve_payment_intent).and_return(stripe_pi)@@ -484,7 +472,7 @@ RSpec.describe SpreeStripe::Gateway::PaymentSessions donext_action: { type: 'setup_future_usage' })end- let(:payment) { create(:payment, order: order, payment_method: gateway, amount: order.total, state: 'checkout') }+ let(:payment) { create(:payment, order: order, payment_method: gateway, amount: order.total, status: 'checkout') }before doallow(gateway).to receive(:retrieve_payment_intent).and_return(stripe_pi)@@ -529,7 +517,7 @@ RSpec.describe SpreeStripe::Gateway::PaymentSessions dopayment_method: { type: 'card' })end- let(:payment) { create(:payment, order: order, payment_method: gateway, amount: order.total, state: 'checkout') }+ let(:payment) { create(:payment, order: order, payment_method: gateway, amount: order.total, status: 'checkout') }before doallow(gateway).to receive(:retrieve_payment_intent).and_return(stripe_pi)@@ -660,29 +648,6 @@ RSpec.describe SpreeStripe::Gateway::PaymentSessions doendend- context 'with payment_intent.amount_capturable_updated event' do- let(:stripe_event) do- Stripe::StripeObject.construct_from(- type: 'payment_intent.amount_capturable_updated',- data: { object: { id: 'pi_authorized_123' } }- )- end- let!(:payment_session) do- create(:stripe_payment_session, owner: order, payment_method: gateway, external_id: 'pi_authorized_123')- end-- before do- allow(gateway).to receive(:verify_webhook_signature).and_return(stripe_event)- end-- it 'returns authorized action' do- result = gateway.parse_webhook_event(raw_body, headers)-- expect(result[:action]).to eq(:authorized)- expect(result[:payment_session]).to eq(payment_session)- end- end-context 'with unsupported event type' dolet(:stripe_event) doStripe::StripeObject.construct_from(@@ -716,18 +681,5 @@ RSpec.describe SpreeStripe::Gateway::PaymentSessions doexpect(gateway.parse_webhook_event(raw_body, headers)).to be_nilendend-- context 'with invalid signature' do- before do- allow(gateway).to receive(:verify_webhook_signature)- .and_raise(Spree::PaymentMethod::WebhookSignatureError)- end-- it 'raises WebhookSignatureError' do- expect {- gateway.parse_webhook_event(raw_body, headers)- }.to raise_error(Spree::PaymentMethod::WebhookSignatureError)- end- endendenddiff --git a/spree/providers/stripe/spec/models/spree_stripe/gateway_spec.rb b/spree/providers/stripe/spec/models/spree_stripe/gateway_spec.rbindex 0ae208d6db..6c335b0b2f 100644--- a/spree/providers/stripe/spec/models/spree_stripe/gateway_spec.rb+++ b/spree/providers/stripe/spec/models/spree_stripe/gateway_spec.rb@@ -399,11 +399,10 @@ RSpec.describe SpreeStripe::Gateway dolet!(:order) { create(:order, store: store, total: 10, customer: create(:customer)) }let!(:gateway_customer) { create(:gateway_customer, customer: order.customer, payment_method: gateway) }- let!(:payment) { create(:payment, state: 'completed', order: order, payment_method: gateway, amount: 10.0, response_code: payment_intent_id) }+ let!(:payment) { create(:payment, status: 'completed', order: order, payment_method: gateway, amount: 10.0, response_code: payment_intent_id) }let!(:refund) { create(:refund, payment: payment, amount: 2.0) }let(:payment_intent_id) { 'pi_3QXmL12ESifGlJez0v0B8tUn' }- let(:refund_id) { 're_3QXmL12ESifGlJez0GcOBHng' }it 'creates a refund with credit_allowed_amount' doVCR.use_cassette('create_refund') do@@ -413,12 +412,6 @@ RSpec.describe SpreeStripe::Gateway doexpect(subject.success?).to be(true)expect(subject.authorization).to eq(payment_intent_id)-- expect(subject.params['id']).to eq(refund_id)- expect(subject.params['status']).to eq('succeeded')- expect(subject.params['payment_intent']).to eq(payment_intent_id)- expect(subject.params['object']).to eq('refund')- expect(subject.params['amount']).to eq(800)endend@@ -964,29 +957,6 @@ RSpec.describe SpreeStripe::Gateway doendend- describe 'being a provider' do- let(:provider_methods) { %i[authorize purchase capture void credit] }-- it 'implements provider methods without delegating back to itself' do- provider_methods.each do |method|- expect(gateway).to respond_to method- expect { gateway.send(method) }.to raise_error(ArgumentError)- end- end- end-- describe '#setup_session_supported?' do- it 'returns true' do- expect(gateway.setup_session_supported?).to be(true)- end- end-- describe '#payment_setup_session_class' do- it 'returns the Stripe STI subclass' do- expect(gateway.payment_setup_session_class).to eq(Spree::PaymentSetupSessions::Stripe)- end- end-describe '#create_payment_setup_session' dosubject { gateway.create_payment_setup_session(customer: customer) }@@ -1243,13 +1213,5 @@ RSpec.describe SpreeStripe::Gateway doexpect(keys).to contain_exactly(:publishable_key, :secret_key)end-- it 'still holds what Stripe hands back' do- gateway.preferred_webhook_signing_secret = 'whsec_payments'- gateway.preferred_connect_webhook_signing_secret = 'whsec_connect'-- expect(gateway.preferred_webhook_signing_secret).to eq('whsec_payments')- expect(gateway.preferred_connect_webhook_signing_secret).to eq('whsec_connect')- endendenddiff --git a/spree/providers/stripe/spec/models/spree_stripe/payout_provider_spec.rb b/spree/providers/stripe/spec/models/spree_stripe/payout_provider_spec.rbindex 45fcdf5e87..d1dbb07f92 100644--- a/spree/providers/stripe/spec/models/spree_stripe/payout_provider_spec.rb+++ b/spree/providers/stripe/spec/models/spree_stripe/payout_provider_spec.rb@@ -134,36 +134,6 @@ RSpec.describe SpreeStripe::PayoutProvider doexpect { described_class.new.transfer!(seller_transfer) }.to raise_error(Stripe::InvalidRequestError)end-- context 'when the customer paid by card' do- # Funds the transfer from that charge, so it settles with the charge- # rather than out of the marketplace's own balance.- # Stripe funds a transfer from a charge. `response_code` holds the- # payment intent that produced it, which Stripe cannot use here — the- # charge is recorded on the payment when its session completes.- it 'names the charge as the funding source' do- create(:payment, order: order, payment_method: gateway, status: 'completed',- response_code: 'pi_123', amount: 100,- metadata: { 'stripe_charge_id' => 'ch_123' })-- expect(Stripe::Transfer).to receive(:create).- with(hash_including(source_transaction: 'ch_123'), anything).- and_return(Stripe::StripeObject.construct_from(id: 'tr_1'))-- described_class.new.transfer!(seller_transfer)- end- end-- context 'when there is no charge to draw on' do- it 'omits the funding source rather than sending a null one' do- expect(Stripe::Transfer).to receive(:create) do |payload, _options|- expect(payload).not_to have_key(:source_transaction)- Stripe::StripeObject.construct_from(id: 'tr_1')- end-- described_class.new.transfer!(seller_transfer)- end- endend# An account settles in its own currency and Stripe converts on the way in, so@@ -508,12 +478,6 @@ RSpec.describe SpreeStripe::PayoutProvider doendend- describe '.requires_payout_account?' do- it 'is true — nothing can be sent to a seller without a connected account' do- expect(described_class.requires_payout_account?).to be(true)- end- end-describe '.available_for_store?' doit 'is false without an active Stripe payment method' dogateway.update!(active: false)