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 ransackable attrs to StoreCredit

Aleksandar Petrusheva7b37d5c24ac
diff --git a/api/spec/integration/api/v2/platform/store_credits_spec.rb b/api/spec/integration/api/v2/platform/store_credits_spec.rb
index 3be71d15e4..aacb65959b 100644
--- a/api/spec/integration/api/v2/platform/store_credits_spec.rb
+++ b/api/spec/integration/api/v2/platform/store_credits_spec.rb
@@ -6,8 +6,8 @@ describe 'Store Credits API', swagger: true do
resource_name = 'Store Credit'
options = {
include_example: 'user,created_by,category,credit_type',
- filter_examples: [{ name: 'filter[user_id_eq]', example: 5 },
- { name: 'filter[created_by_id_eq]', example: 2 },
+ filter_examples: [{ name: 'filter[user_id_eq]', example: '5' },
+ { name: 'filter[created_by_id_eq]', example: '2' },
{ name: 'filter[amount_gteq]', example: 50.0 },
{ name: 'filter[currency_eq]', example: 'USD' }]
}
diff --git a/core/app/models/spree/store_credit.rb b/core/app/models/spree/store_credit.rb
index 1024fae9cc..d8887d9199 100644
--- a/core/app/models/spree/store_credit.rb
+++ b/core/app/models/spree/store_credit.rb
@@ -42,6 +42,8 @@ module Spree
extend Spree::DisplayMoney
money_methods :amount, :amount_used
+ self.whitelisted_ransackable_attributes = %w[user_id created_by_id amount currency type_id store_id]
+
def amount_remaining
amount - amount_used - amount_authorized
end