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.

Apply code reviews

Matthew Kennedy083cb01d4aeb
diff --git a/core/app/models/spree/wished_variant.rb b/core/app/models/spree/wished_variant.rb
index 103fae87f8..3ffa15da3a 100644
--- a/core/app/models/spree/wished_variant.rb
+++ b/core/app/models/spree/wished_variant.rb
@@ -3,30 +3,24 @@ module Spree
extend DisplayMoney
money_methods :total, :price
- belongs_to :variant
- belongs_to :wishlist
+ belongs_to :variant, class_name: 'Spree::Variant'
+ belongs_to :wishlist, class_name: 'Spree::Wishlist'
- has_one :product, through: :variant
+ has_one :product, class_name: 'Spree::Product', through: :variant
validates :variant, :wishlist, presence: true
def price(currency)
- variant_price = variant.price_in(currency[:currency]).amount
-
- if variant_price.nil?
- variant_price
- else
- variant_price.to_i
- end
+ variant.amount_in(currency[:currency])
end
def total(currency)
- variant_price = variant.price_in(currency[:currency]).amount
+ variant_price = variant.amount_in(currency[:currency])
if variant_price.nil?
variant_price
else
- quantity * variant_price.to_i
+ quantity * variant_price
end
end
end
diff --git a/core/app/models/spree/wishlist.rb b/core/app/models/spree/wishlist.rb
index 30c718aef8..2746c8a420 100644
--- a/core/app/models/spree/wishlist.rb
+++ b/core/app/models/spree/wishlist.rb
@@ -5,16 +5,15 @@ module Spree
has_secure_token
belongs_to :user, class_name: Spree.user_class.to_s
- belongs_to :store, touch: true
+ belongs_to :store, class_name: 'Spree::Store', touch: true
- after_commit :ensure_default_exists_and_is_unique
-
- has_many :wished_variants, dependent: :destroy
+ has_many :wished_variants, class_name: 'Spree::WishedVariant', dependent: :destroy
+ after_commit :ensure_default_exists_and_is_unique
validates :name, :store, :user, presence: true
def include?(variant_id)
- wished_variants.map(&:variant_id).include? variant_id.to_i
+ wished_variants.exists?(variant_id: variant_id)
end
def to_param