spec/dummy/app/models/product.rb in money-rails-1.3.0 vs spec/dummy/app/models/product.rb in money-rails-1.4.0
- old
+ new
@@ -17,21 +17,26 @@
# Override default currency (EUR) with a specific one (GBP) for this field only
monetize :bonus_cents, :with_currency => :gbp
# Use currency column to determine currency for this field only
monetize :sale_price_amount, :as => :sale_price,
- :with_model_currency => :sale_price_currency_code
+ :with_model_currency => :sale_price_currency_code
monetize :price_in_a_range_cents, :allow_nil => true,
- :subunit_numericality => {
- :greater_than => 0,
- :less_than_or_equal_to => 10000,
- },
- :numericality => {
- :greater_than => 0,
- :less_than_or_equal_to => 100,
- :message => "Must be greater than zero and less than $100"
- }
+ :subunit_numericality => {
+ :greater_than => 0,
+ :less_than_or_equal_to => 10000 },
+ :numericality => {
+ :greater_than => 0,
+ :less_than_or_equal_to => 100,
+ :message => "Must be greater than zero and less than $100"
+ }
+
+ # Skip validations separately from each other
+ monetize :skip_validation_price_cents, subunit_numericality: false, numericality: false, allow_nil: true
+
+ # Override default currency (EUR) with a specific one (CAD) for this field only, from a lambda
+ monetize :lambda_price_cents, with_currency: ->(product) { Rails.configuration.lambda_test }, allow_nil: true
attr_accessor :accessor_price_cents
monetize :accessor_price_cents, disable_validation: true
monetize :validates_method_amount_cents, allow_nil: true