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
refactor tests, make scope :for_template_promotion_id skip args sanitizing
Mateusz Porębski440fabc7bd13
diff --git a/core/app/models/spree/promotion.rb b/core/app/models/spree/promotion.rbindex f93b834bc1..c83ae3114b 100644--- a/core/app/models/spree/promotion.rb+++ b/core/app/models/spree/promotion.rb@@ -56,6 +56,9 @@ module Spreeself.whitelisted_ransackable_attributes = ['path', 'promotion_category_id', 'promotion_batch_id', 'code']self.whitelisted_ransackable_scopes = ['for_template_promotion_id']+ def self.ransackable_scopes_skip_sanitize_args+ [:for_template_promotion_id]+ enddef self.with_coupon_code(coupon_code)where("lower(#{table_name}.code) = ?", coupon_code.strip.downcase).diff --git a/core/spec/services/spree/promotion_batches/generate_code_spec.rb b/core/spec/services/spree/promotion_batches/generate_code_spec.rbindex 1409bca587..30c68642a6 100644--- a/core/spec/services/spree/promotion_batches/generate_code_spec.rb+++ b/core/spec/services/spree/promotion_batches/generate_code_spec.rb@@ -21,7 +21,7 @@ module Spreelet(:prefix) { 'MYCAMPAIGN_' }it 'returns prefix and randomly generated code' do- expect(subject).to start_with('MYCAMPAIGN_')+ expect(subject).to match('^MYCAMPAIGN_[A-Z0-9]{4}$')endend@@ -29,7 +29,7 @@ module Spreelet(:suffix) { '_RETAIL' }it 'returns randomly generated code with suffix' do- expect(subject).to end_with('_RETAIL')+ expect(subject).to match('^[A-Z0-9]{4}_RETAIL$')endend@@ -38,8 +38,7 @@ module Spreelet(:suffix) { '_ONLINE' }it 'returns randomly generated code with prefix and suffix' do- expect(subject).to start_with('TESTCAMPAIGN_')- expect(subject).to end_with('_ONLINE')+ expect(subject).to match('^TESTCAMPAIGN_[A-Z0-9]{4}_ONLINE$')endendend