File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
active_record/monetizable Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -800,6 +800,20 @@ class SubProduct < Product
800800 transaction . amount = "$123"
801801 expect ( transaction . valid? ) . to be_truthy
802802 end
803+
804+ it "is valid when the monetize field is set" do
805+ transaction . amount = 5_000
806+ transaction . currency = :eur
807+
808+ expect ( transaction . valid? ) . to be_truthy
809+ end
810+
811+ it "is valid when the monetize field is not set" do
812+ transaction . update ( amount : 5_000 , currency : :eur )
813+ transaction . reload # reload to simulate the retrieved object
814+
815+ expect ( transaction . valid? ) . to be_truthy
816+ end
803817 end
804818 end
805819 end
Original file line number Diff line number Diff line change 11class Transaction < ActiveRecord ::Base
2- monetize :amount_cents , with_model_currency : :currency
2+ monetize :amount_cents , with_model_currency : :currency ,
3+ subunit_numericality : {
4+ only_integer : true ,
5+ greater_than : 0 ,
6+ less_than_or_equal_to : 2_000_000 ,
7+ } ,
8+ numericality : {
9+ greater_than : 0 ,
10+ less_than_or_equal_to : 20_000
11+ }
312
413 monetize :tax_cents , with_model_currency : :currency
514
You can’t perform that action at this time.
0 commit comments