mongoid_money_field 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +2 -9
 - data/VERSION +1 -1
 - data/lib/mongoid_money_field.rb +4 -0
 - data/mongoid_money_field.gemspec +2 -1
 - data/spec/money_spec.rb +10 -2
 - data/spec/support/dummy_money_without_default.rb +9 -0
 - data/spec/support/dummy_prices.rb +2 -0
 - metadata +3 -2
 
    
        data/README.rdoc
    CHANGED
    
    | 
         @@ -11,14 +11,6 @@ A simple gem that creates a Money datatype using RubyMoney for Mongoid. 
     | 
|
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            Inspired by https://gist.github.com/840500
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
            == Updating
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
            v2.0 breaks compatibility as it does not give 0 cents default anymore. Use
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
              money_field_with_options :price, default: 0
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            instead
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
14 
     | 
    
         
             
            == Installation
         
     | 
| 
       23 
15 
     | 
    
         | 
| 
       24 
16 
     | 
    
         
             
            Include the gem in your Gemfile
         
     | 
| 
         @@ -33,7 +25,8 @@ Include the gem in your Gemfile 
     | 
|
| 
       33 
25 
     | 
    
         | 
| 
       34 
26 
     | 
    
         
             
                  field :description
         
     | 
| 
       35 
27 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
                  money_field : 
     | 
| 
      
 28 
     | 
    
         
            +
                  money_field :cart_total # defaults to 0
         
     | 
| 
      
 29 
     | 
    
         
            +
                  money_field_without_default :price, :old_price # defaults to nil
         
     | 
| 
       37 
30 
     | 
    
         | 
| 
       38 
31 
     | 
    
         
             
                  # to disallow changing currency (and to not store it in database)
         
     | 
| 
       39 
32 
     | 
    
         
             
                  money_field_with_options :price2, fixed_currency: 'GBP'
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            2.0 
     | 
| 
      
 1 
     | 
    
         
            +
            2.1.0
         
     | 
    
        data/lib/mongoid_money_field.rb
    CHANGED
    
    
    
        data/mongoid_money_field.gemspec
    CHANGED
    
    | 
         @@ -5,7 +5,7 @@ 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.name = "mongoid_money_field"
         
     | 
| 
       8 
     | 
    
         
            -
              s.version = "2.0 
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "2.1.0"
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.authors = ["glebtv"]
         
     | 
| 
         @@ -35,6 +35,7 @@ Gem::Specification.new do |s| 
     | 
|
| 
       35 
35 
     | 
    
         
             
                "spec/support/dummy_money_with_default.rb",
         
     | 
| 
       36 
36 
     | 
    
         
             
                "spec/support/dummy_money_with_default_with_currency.rb",
         
     | 
| 
       37 
37 
     | 
    
         
             
                "spec/support/dummy_money_with_fixed_currency.rb",
         
     | 
| 
      
 38 
     | 
    
         
            +
                "spec/support/dummy_money_without_default.rb",
         
     | 
| 
       38 
39 
     | 
    
         
             
                "spec/support/dummy_prices.rb"
         
     | 
| 
       39 
40 
     | 
    
         
             
              ]
         
     | 
| 
       40 
41 
     | 
    
         
             
              s.homepage = "http://github.com/glebtv/mongoid_money_field"
         
     | 
    
        data/spec/money_spec.rb
    CHANGED
    
    | 
         @@ -73,9 +73,15 @@ describe Mongoid::MoneyField do 
     | 
|
| 
       73 
73 
     | 
    
         | 
| 
       74 
74 
     | 
    
         
             
              describe 'when accessing a document from the datastore with a Money datatype and empty value' do
         
     | 
| 
       75 
75 
     | 
    
         
             
                it 'should be nil' do
         
     | 
| 
      
 76 
     | 
    
         
            +
                  dummy = DummyMoneyWithoutDefault.new
         
     | 
| 
      
 77 
     | 
    
         
            +
                  dummy.save.should eq true
         
     | 
| 
      
 78 
     | 
    
         
            +
                  DummyMoneyWithoutDefault.first.price.should be_nil
         
     | 
| 
      
 79 
     | 
    
         
            +
                end
         
     | 
| 
      
 80 
     | 
    
         
            +
                
         
     | 
| 
      
 81 
     | 
    
         
            +
                  it 'should be 0 when used with default' do
         
     | 
| 
       76 
82 
     | 
    
         
             
                  dummy = DummyMoney.new
         
     | 
| 
       77 
83 
     | 
    
         
             
                  dummy.save.should eq true
         
     | 
| 
       78 
     | 
    
         
            -
                  DummyMoney.first.price.should  
     | 
| 
      
 84 
     | 
    
         
            +
                  DummyMoney.first.price.cents.should eq 0
         
     | 
| 
       79 
85 
     | 
    
         
             
                end
         
     | 
| 
       80 
86 
     | 
    
         | 
| 
       81 
87 
     | 
    
         
             
                it 'should set money to default currency if money is given without it' do
         
     | 
| 
         @@ -92,8 +98,10 @@ describe Mongoid::MoneyField do 
     | 
|
| 
       92 
98 
     | 
    
         
             
                  dummy = DummyPrices.first
         
     | 
| 
       93 
99 
     | 
    
         
             
                  dummy.price.currency.iso_code.should eq Money.default_currency.iso_code
         
     | 
| 
       94 
100 
     | 
    
         
             
                  dummy.price.cents.should eq 100
         
     | 
| 
      
 101 
     | 
    
         
            +
                  
         
     | 
| 
      
 102 
     | 
    
         
            +
                  dummy.price_nodef.should be_nil
         
     | 
| 
       95 
103 
     | 
    
         | 
| 
       96 
     | 
    
         
            -
                  dummy.price1.should  
     | 
| 
      
 104 
     | 
    
         
            +
                  dummy.price1.cents.should eq 0
         
     | 
| 
       97 
105 
     | 
    
         
             
                end
         
     | 
| 
       98 
106 
     | 
    
         | 
| 
       99 
107 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: mongoid_money_field
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2.0 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.1.0
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -165,6 +165,7 @@ files: 
     | 
|
| 
       165 
165 
     | 
    
         
             
            - spec/support/dummy_money_with_default.rb
         
     | 
| 
       166 
166 
     | 
    
         
             
            - spec/support/dummy_money_with_default_with_currency.rb
         
     | 
| 
       167 
167 
     | 
    
         
             
            - spec/support/dummy_money_with_fixed_currency.rb
         
     | 
| 
      
 168 
     | 
    
         
            +
            - spec/support/dummy_money_without_default.rb
         
     | 
| 
       168 
169 
     | 
    
         
             
            - spec/support/dummy_prices.rb
         
     | 
| 
       169 
170 
     | 
    
         
             
            homepage: http://github.com/glebtv/mongoid_money_field
         
     | 
| 
       170 
171 
     | 
    
         
             
            licenses:
         
     | 
| 
         @@ -181,7 +182,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       181 
182 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       182 
183 
     | 
    
         
             
                  segments:
         
     | 
| 
       183 
184 
     | 
    
         
             
                  - 0
         
     | 
| 
       184 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 185 
     | 
    
         
            +
                  hash: -1966677237532462947
         
     | 
| 
       185 
186 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       186 
187 
     | 
    
         
             
              none: false
         
     | 
| 
       187 
188 
     | 
    
         
             
              requirements:
         
     |