Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Add order as ransackable in return_authorization (#11575)

Aleksandar Petrushevf9cf3df5f163
diff --git a/core/app/models/spree/return_authorization.rb b/core/app/models/spree/return_authorization.rb
index 1d42a9283a..9a895c490f 100644
--- a/core/app/models/spree/return_authorization.rb
+++ b/core/app/models/spree/return_authorization.rb
@@ -41,6 +41,7 @@ module Spree
money_methods :pre_tax_total
self.whitelisted_ransackable_attributes = ['memo', 'number', 'state']
+ self.whitelisted_ransackable_associations = ['order']
def pre_tax_total
return_items.sum(:pre_tax_amount)
diff --git a/core/spec/models/spree/return_authorization_spec.rb b/core/spec/models/spree/return_authorization_spec.rb
index 0202e5d5f7..0e85f3233f 100644
--- a/core/spec/models/spree/return_authorization_spec.rb
+++ b/core/spec/models/spree/return_authorization_spec.rb
@@ -88,6 +88,10 @@ describe Spree::ReturnAuthorization, type: :model do
it { expect(Spree::ReturnAuthorization.whitelisted_ransackable_attributes).to eq(%w(memo number state)) }
end
+ describe 'whitelisted_ransackable_associations' do
+ it { expect(Spree::ReturnAuthorization.whitelisted_ransackable_associations).to eq(%w(order)) }
+ end
+
context '#currency' do
before { allow(order).to receive(:currency).and_return('ABC') }