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
-- Remove NOT NULL constraint from spree_policies.name to support Mobility translations (#13463)
Muhammad Ibtisam Hussain8a5d757d02c4
diff --git a/core/app/models/spree/policy.rb b/core/app/models/spree/policy.rbindex 569f891c7b..8e56c441d7 100644--- a/core/app/models/spree/policy.rb+++ b/core/app/models/spree/policy.rb@@ -36,7 +36,7 @@ module Spree## Scopes#- scope :with_body, -> { joins(:rich_text_body).distinct }+ scope :with_body, -> { joins(:rich_text_body).distinct }scope :without_body, -> { where.missing(:rich_text_body) }scope :with_matching_name, ->(name_to_match) dovalue = name_to_match.to_s.strip.downcasediff --git a/core/db/migrate/20260117140831_remove_not_null_constraint_from_policy_name.rb b/core/db/migrate/20260117140831_remove_not_null_constraint_from_policy_name.rbnew file mode 100644index 0000000000..6003b2f339--- /dev/null+++ b/core/db/migrate/20260117140831_remove_not_null_constraint_from_policy_name.rb@@ -0,0 +1,5 @@+class RemoveNotNullConstraintFromPolicyName < ActiveRecord::Migration[7.2]+ def change+ change_column_null :spree_policies, :name, true+ end+enddiff --git a/core/spec/models/spree/policy_spec.rb b/core/spec/models/spree/policy_spec.rbindex ccd31beb45..fb9301b093 100644--- a/core/spec/models/spree/policy_spec.rb+++ b/core/spec/models/spree/policy_spec.rb@@ -69,6 +69,26 @@ RSpec.describe Spree::Policy, type: :model doexpect(policy.body.to_plain_text).to eq('Política de Privacidad')endend++ context 'when always_use_translations is enabled' do+ before do+ @original_setting = Spree::Config.always_use_translations+ Spree::Config.always_use_translations = true+ end++ after do+ Spree::Config.always_use_translations = @original_setting+ end++ it 'allows creating policies with translations' do+ I18n.with_locale(:es) do+ policy = create(:policy, owner: store, name: 'Política de Privacidad')++ expect(policy).to be_persisted+ expect(policy.name).to eq('Política de Privacidad')+ end+ end+ endenddescribe 'Scopes' do