mongoid_money_field 4.0.8 → 5.0.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.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -1
- data/.ruby-version +1 -1
- data/.travis.yml +6 -5
- data/Gemfile +2 -0
- data/README.rdoc +5 -3
- data/gemfiles/money51-mongoid31.gemfile +6 -0
- data/gemfiles/money51-mongoid4.gemfile +6 -0
- data/gemfiles/money6-mongoid31.gemfile +6 -0
- data/gemfiles/money6-mongoid4.gemfile +6 -0
- data/lib/mongoid_money_field.rb +10 -162
- data/lib/mongoid_money_field/field.rb +1 -1
- data/lib/mongoid_money_field/type.rb +82 -0
- data/lib/mongoid_money_field/version.rb +1 -1
- data/mongoid_money_field.gemspec +8 -10
- data/spec/money_spec.rb +106 -107
- data/spec/ruby_money_spec.rb +15 -15
- data/spec/support/dummy_money.rb +1 -1
- data/spec/support/dummy_money_required.rb +9 -9
- data/spec/support/dummy_money_with_default.rb +9 -9
- data/spec/support/money3.rb +1 -1
- metadata +50 -72
- data/lib/mongoid_money_field/rails_admin.rb +0 -46
- data/spec/model_spec.rb +0 -8
- data/spec/money3_compat_spec.rb +0 -123
- data/spec/money3_spec.rb +0 -342
data/spec/ruby_money_spec.rb
CHANGED
@@ -15,48 +15,48 @@ describe Money do
|
|
15
15
|
|
16
16
|
context "mongoize" do
|
17
17
|
it "mongoizes correctly a Money object to a hash of cents and currency" do
|
18
|
-
|
19
|
-
|
18
|
+
priceable.price.cents.should == 100
|
19
|
+
priceable.price.currency.should == Money::Currency.find('EUR')
|
20
20
|
end
|
21
21
|
|
22
22
|
it "mongoizes correctly a Numeric object to a hash of cents and currency" do
|
23
|
-
|
24
|
-
|
23
|
+
priceable_from_num.price.cents.should == 100
|
24
|
+
priceable_from_num.price.currency.should == Money.default_currency
|
25
25
|
end
|
26
26
|
|
27
27
|
it "mongoizes correctly a String object to a hash of cents and currency" do
|
28
|
-
|
29
|
-
|
28
|
+
priceable_from_string.price.cents.should == 100
|
29
|
+
priceable_from_string.price.currency.should == Money::Currency.find('EUR')
|
30
30
|
end
|
31
31
|
|
32
32
|
it "mongoizes correctly a hash of cents and currency" do
|
33
|
-
|
34
|
-
|
33
|
+
priceable_from_hash.price.cents.should == 100
|
34
|
+
priceable_from_hash.price.currency.should == Money::Currency.find('EUR')
|
35
35
|
end
|
36
36
|
|
37
37
|
it "mongoizes correctly a HashWithIndifferentAccess of cents and currency" do
|
38
|
-
|
39
|
-
|
38
|
+
priceable_from_hash_with_indifferent_access.price.cents.should == 100
|
39
|
+
priceable_from_hash_with_indifferent_access.price.currency.should == Money::Currency.find('EUR')
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
context "demongoize" do
|
44
44
|
subject { Priceable.first.price }
|
45
|
-
it {
|
46
|
-
it {
|
45
|
+
it { should be_an_instance_of(Money) }
|
46
|
+
it { should == Money.new(100, 'EUR') }
|
47
47
|
it "returns nil if a nil value was stored" do
|
48
48
|
nil_priceable = Priceable.create(:price => nil)
|
49
|
-
|
49
|
+
nil_priceable.price.should be_nil
|
50
50
|
end
|
51
51
|
it 'returns nil if an unknown value was stored' do
|
52
52
|
zero_priceable = Priceable.create(:price => [])
|
53
|
-
|
53
|
+
zero_priceable.price.should be_nil
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
context "evolve" do
|
58
58
|
it "transforms correctly a Money object to a Mongo friendly value" do
|
59
|
-
|
59
|
+
Priceable.where(:price => Money.new(100, 'EUR')).first.should == priceable
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
data/spec/support/dummy_money.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
class DummyMoneyRequired
|
4
|
-
include Mongoid::Document
|
5
|
-
include Mongoid::MoneyField
|
6
|
-
|
7
|
-
field :description
|
8
|
-
|
9
|
-
money_field :price, required: true, default_currency: nil
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
class DummyMoneyRequired
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::MoneyField
|
6
|
+
|
7
|
+
field :description
|
8
|
+
|
9
|
+
money_field :price, required: true, default_currency: nil
|
10
10
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
class DummyMoneyWithDefault
|
4
|
-
include Mongoid::Document
|
5
|
-
include Mongoid::MoneyField
|
6
|
-
|
7
|
-
field :description
|
8
|
-
|
9
|
-
money_field :price, default: 1.00
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
class DummyMoneyWithDefault
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::MoneyField
|
6
|
+
|
7
|
+
field :description
|
8
|
+
|
9
|
+
money_field :price, default: 1.00
|
10
10
|
end
|
data/spec/support/money3.rb
CHANGED
metadata
CHANGED
@@ -1,161 +1,141 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_money_field
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gleb Tv
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2013-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '4.1'
|
19
|
+
version: 3.0.0
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '3.0'
|
30
|
-
- - "<"
|
24
|
+
- - '>='
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: monetize
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - ">="
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '0'
|
40
|
-
type: :runtime
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '0'
|
26
|
+
version: 3.0.0
|
47
27
|
- !ruby/object:Gem::Dependency
|
48
28
|
name: money
|
49
29
|
requirement: !ruby/object:Gem::Requirement
|
50
30
|
requirements:
|
51
|
-
- -
|
31
|
+
- - '>='
|
52
32
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
33
|
+
version: 5.0.0
|
54
34
|
type: :runtime
|
55
35
|
prerelease: false
|
56
36
|
version_requirements: !ruby/object:Gem::Requirement
|
57
37
|
requirements:
|
58
|
-
- -
|
38
|
+
- - '>='
|
59
39
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
40
|
+
version: 5.0.0
|
61
41
|
- !ruby/object:Gem::Dependency
|
62
42
|
name: rake
|
63
43
|
requirement: !ruby/object:Gem::Requirement
|
64
44
|
requirements:
|
65
|
-
- -
|
45
|
+
- - '>='
|
66
46
|
- !ruby/object:Gem::Version
|
67
47
|
version: '0'
|
68
48
|
type: :development
|
69
49
|
prerelease: false
|
70
50
|
version_requirements: !ruby/object:Gem::Requirement
|
71
51
|
requirements:
|
72
|
-
- -
|
52
|
+
- - '>='
|
73
53
|
- !ruby/object:Gem::Version
|
74
54
|
version: '0'
|
75
55
|
- !ruby/object:Gem::Dependency
|
76
56
|
name: bundler
|
77
57
|
requirement: !ruby/object:Gem::Requirement
|
78
58
|
requirements:
|
79
|
-
- -
|
59
|
+
- - ~>
|
80
60
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
61
|
+
version: 1.3.4
|
82
62
|
type: :development
|
83
63
|
prerelease: false
|
84
64
|
version_requirements: !ruby/object:Gem::Requirement
|
85
65
|
requirements:
|
86
|
-
- -
|
66
|
+
- - ~>
|
87
67
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
68
|
+
version: 1.3.4
|
89
69
|
- !ruby/object:Gem::Dependency
|
90
70
|
name: rspec
|
91
71
|
requirement: !ruby/object:Gem::Requirement
|
92
72
|
requirements:
|
93
|
-
- -
|
73
|
+
- - ~>
|
94
74
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
75
|
+
version: 2.13.0
|
96
76
|
type: :development
|
97
77
|
prerelease: false
|
98
78
|
version_requirements: !ruby/object:Gem::Requirement
|
99
79
|
requirements:
|
100
|
-
- -
|
80
|
+
- - ~>
|
101
81
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
82
|
+
version: 2.13.0
|
103
83
|
- !ruby/object:Gem::Dependency
|
104
84
|
name: rdoc
|
105
85
|
requirement: !ruby/object:Gem::Requirement
|
106
86
|
requirements:
|
107
|
-
- -
|
87
|
+
- - ~>
|
108
88
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
89
|
+
version: 4.0.1
|
110
90
|
type: :development
|
111
91
|
prerelease: false
|
112
92
|
version_requirements: !ruby/object:Gem::Requirement
|
113
93
|
requirements:
|
114
|
-
- -
|
94
|
+
- - ~>
|
115
95
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
96
|
+
version: 4.0.1
|
117
97
|
- !ruby/object:Gem::Dependency
|
118
98
|
name: simplecov
|
119
99
|
requirement: !ruby/object:Gem::Requirement
|
120
100
|
requirements:
|
121
|
-
- -
|
101
|
+
- - ~>
|
122
102
|
- !ruby/object:Gem::Version
|
123
|
-
version:
|
103
|
+
version: 0.7.1
|
124
104
|
type: :development
|
125
105
|
prerelease: false
|
126
106
|
version_requirements: !ruby/object:Gem::Requirement
|
127
107
|
requirements:
|
128
|
-
- -
|
108
|
+
- - ~>
|
129
109
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
110
|
+
version: 0.7.1
|
131
111
|
- !ruby/object:Gem::Dependency
|
132
112
|
name: database_cleaner
|
133
113
|
requirement: !ruby/object:Gem::Requirement
|
134
114
|
requirements:
|
135
|
-
- -
|
115
|
+
- - ~>
|
136
116
|
- !ruby/object:Gem::Version
|
137
|
-
version:
|
117
|
+
version: 0.9.1
|
138
118
|
type: :development
|
139
119
|
prerelease: false
|
140
120
|
version_requirements: !ruby/object:Gem::Requirement
|
141
121
|
requirements:
|
142
|
-
- -
|
122
|
+
- - ~>
|
143
123
|
- !ruby/object:Gem::Version
|
144
|
-
version:
|
124
|
+
version: 0.9.1
|
145
125
|
- !ruby/object:Gem::Dependency
|
146
126
|
name: mongoid-rspec
|
147
127
|
requirement: !ruby/object:Gem::Requirement
|
148
128
|
requirements:
|
149
|
-
- -
|
129
|
+
- - ~>
|
150
130
|
- !ruby/object:Gem::Version
|
151
|
-
version:
|
131
|
+
version: 1.7.0
|
152
132
|
type: :development
|
153
133
|
prerelease: false
|
154
134
|
version_requirements: !ruby/object:Gem::Requirement
|
155
135
|
requirements:
|
156
|
-
- -
|
136
|
+
- - ~>
|
157
137
|
- !ruby/object:Gem::Version
|
158
|
-
version:
|
138
|
+
version: 1.7.0
|
159
139
|
description: Use RubyMoney with mongoid
|
160
140
|
email:
|
161
141
|
- glebtv@gmail.com
|
@@ -163,26 +143,27 @@ executables: []
|
|
163
143
|
extensions: []
|
164
144
|
extra_rdoc_files: []
|
165
145
|
files:
|
166
|
-
-
|
167
|
-
-
|
168
|
-
-
|
169
|
-
-
|
170
|
-
-
|
171
|
-
-
|
146
|
+
- .document
|
147
|
+
- .gitignore
|
148
|
+
- .rspec
|
149
|
+
- .ruby-gemset
|
150
|
+
- .ruby-version
|
151
|
+
- .travis.yml
|
172
152
|
- Gemfile
|
173
153
|
- Gemfile.lock
|
174
154
|
- LICENSE.txt
|
175
155
|
- README.rdoc
|
176
156
|
- Rakefile
|
157
|
+
- gemfiles/money51-mongoid31.gemfile
|
158
|
+
- gemfiles/money51-mongoid4.gemfile
|
159
|
+
- gemfiles/money6-mongoid31.gemfile
|
160
|
+
- gemfiles/money6-mongoid4.gemfile
|
177
161
|
- lib/mongoid_money_field.rb
|
178
162
|
- lib/mongoid_money_field/field.rb
|
179
|
-
- lib/mongoid_money_field/rails_admin.rb
|
180
163
|
- lib/mongoid_money_field/simple_form/money_input.rb
|
164
|
+
- lib/mongoid_money_field/type.rb
|
181
165
|
- lib/mongoid_money_field/version.rb
|
182
166
|
- mongoid_money_field.gemspec
|
183
|
-
- spec/model_spec.rb
|
184
|
-
- spec/money3_compat_spec.rb
|
185
|
-
- spec/money3_spec.rb
|
186
167
|
- spec/money_spec.rb
|
187
168
|
- spec/ruby_money_spec.rb
|
188
169
|
- spec/spec_helper.rb
|
@@ -211,24 +192,21 @@ require_paths:
|
|
211
192
|
- lib
|
212
193
|
required_ruby_version: !ruby/object:Gem::Requirement
|
213
194
|
requirements:
|
214
|
-
- -
|
195
|
+
- - '>='
|
215
196
|
- !ruby/object:Gem::Version
|
216
197
|
version: '0'
|
217
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
199
|
requirements:
|
219
|
-
- -
|
200
|
+
- - '>='
|
220
201
|
- !ruby/object:Gem::Version
|
221
202
|
version: '0'
|
222
203
|
requirements: []
|
223
204
|
rubyforge_project:
|
224
|
-
rubygems_version: 2.
|
205
|
+
rubygems_version: 2.1.10
|
225
206
|
signing_key:
|
226
207
|
specification_version: 4
|
227
208
|
summary: Use RubyMoney with mongoid
|
228
209
|
test_files:
|
229
|
-
- spec/model_spec.rb
|
230
|
-
- spec/money3_compat_spec.rb
|
231
|
-
- spec/money3_spec.rb
|
232
210
|
- spec/money_spec.rb
|
233
211
|
- spec/ruby_money_spec.rb
|
234
212
|
- spec/spec_helper.rb
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'rails_admin/adapters/mongoid'
|
2
|
-
require 'rails_admin/config/fields/types/string'
|
3
|
-
module RailsAdmin
|
4
|
-
module Adapters
|
5
|
-
module Mongoid
|
6
|
-
alias_method :type_lookup_without_money, :type_lookup
|
7
|
-
def type_lookup(name, field)
|
8
|
-
if field.type.to_s == 'Money' || field.type.class.name == 'MoneyType'
|
9
|
-
{ :type => :money_field }
|
10
|
-
else
|
11
|
-
type_lookup_without_money(name, field)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
module Config
|
18
|
-
module Fields
|
19
|
-
module Types
|
20
|
-
class MoneyField < RailsAdmin::Config::Fields::Types::String
|
21
|
-
# Register field type for the type loader
|
22
|
-
RailsAdmin::Config::Fields::Types::register(self)
|
23
|
-
|
24
|
-
register_instance_option :pretty_value do
|
25
|
-
ret = if value.class.name == 'Hash'
|
26
|
-
value.stringify_keys!
|
27
|
-
if value['cents']
|
28
|
-
"%.2f" % ::Money.new(value['cents'], value['currency_iso']).to_f
|
29
|
-
else
|
30
|
-
value
|
31
|
-
end
|
32
|
-
elsif value.respond_to?(:cents)
|
33
|
-
"%.2f" % value.to_f
|
34
|
-
else
|
35
|
-
value
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
register_instance_option :formatted_value do
|
40
|
-
pretty_value
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
data/spec/model_spec.rb
DELETED
data/spec/money3_compat_spec.rb
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Money3Compat do
|
6
|
-
it { is_expected.to allow_mass_assignment_of(:description) }
|
7
|
-
it { is_expected.to allow_mass_assignment_of(:price) }
|
8
|
-
|
9
|
-
it 'correctly reads old fields data' do
|
10
|
-
Money3.create!(price_currency: 'GBP', price_cents: '12000')
|
11
|
-
expect(Money3Compat.first.price.cents).to eq 12000
|
12
|
-
expect(Money3Compat.first.price.currency.iso_code).to eq 'GBP'
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'correctly works after save' do
|
16
|
-
Money3.create!(price_currency: 'GBP', price_cents: '12000')
|
17
|
-
expect(Money3Compat.first.save).to be_truthy
|
18
|
-
|
19
|
-
expect(Money3Compat.first.price.cents).to eq 12000
|
20
|
-
expect(Money3Compat.first.price.currency.iso_code).to eq 'GBP'
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'correctly migrates data' do
|
24
|
-
Money3.create!(price_currency: 'GBP', price_cents: '12000')
|
25
|
-
|
26
|
-
expect(Money3.first.read_attribute(:price_currency)).not_to be_nil
|
27
|
-
expect(Money3.first.read_attribute(:price_cents)).not_to be_nil
|
28
|
-
|
29
|
-
expect(Money3.first.read_attribute(:price_currency)).to eq 'GBP'
|
30
|
-
expect(Money3.first.read_attribute(:price_cents)).to eq 12000
|
31
|
-
|
32
|
-
Money3Compat.migrate_from_money_field_3!(:price)
|
33
|
-
|
34
|
-
expect(Money3Compat.first.price.cents).to eq 12000
|
35
|
-
expect(Money3Compat.first.price.currency.iso_code).to eq 'GBP'
|
36
|
-
|
37
|
-
expect(Money3.first.read_attribute(:price_currency)).to be_nil
|
38
|
-
expect(Money3.first.read_attribute(:price_cents)).to be_nil
|
39
|
-
|
40
|
-
expect(Money3Compat.first.read_attribute(:price_currency)).to be_nil
|
41
|
-
expect(Money3Compat.first.read_attribute(:price_cents)).to be_nil
|
42
|
-
|
43
|
-
f = Money3Compat.first
|
44
|
-
f.price = '32.00 GBP'
|
45
|
-
expect(f.save).to be_truthy
|
46
|
-
|
47
|
-
expect(Money3Compat.first.price.cents).to eq 3200
|
48
|
-
expect(Money3Compat.first.price.currency.iso_code).to eq 'GBP'
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'with fixed currency' do
|
52
|
-
it 'correctly reads old' do
|
53
|
-
Money3.create!(price_with_fix_cents: '12000')
|
54
|
-
expect(Money3Compat.first.price_with_fix.cents).to eq 12000
|
55
|
-
expect(Money3Compat.first.price_with_fix.currency.iso_code).to eq 'GBP'
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'correctly works after save' do
|
59
|
-
Money3.create!(price_with_fix_cents: '12000')
|
60
|
-
expect(Money3Compat.first.save).to be_truthy
|
61
|
-
expect(Money3Compat.first.price_with_fix.cents).to eq 12000
|
62
|
-
expect(Money3Compat.first.price_with_fix.currency.iso_code).to eq 'GBP'
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'correctly migrates data' do
|
66
|
-
Money3.create!(price_with_fix_cents: '12000')
|
67
|
-
Money3Compat.migrate_from_money_field_3!(:price_with_fix)
|
68
|
-
|
69
|
-
expect(Money3Compat.first.read_attribute(:price_with_fix_currency)).to be_nil
|
70
|
-
expect(Money3Compat.first.read_attribute(:price_with_fix_cents)).to be_nil
|
71
|
-
|
72
|
-
expect(Money3Compat.first.price_with_fix.cents).to eq 12000
|
73
|
-
expect(Money3Compat.first.price_with_fix.currency.iso_code).to eq 'GBP'
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe 'with no default' do
|
78
|
-
it 'correctly reads old' do
|
79
|
-
Money3.create!(price_no_default_currency: 'GBP', price_no_default_cents: '12000')
|
80
|
-
expect(Money3Compat.first.price_no_default.cents).to eq 12000
|
81
|
-
expect(Money3Compat.first.price_no_default.currency.iso_code).to eq 'GBP'
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'correctly works after save' do
|
85
|
-
Money3.create!(price_no_default_currency: 'GBP', price_no_default_cents: '12000')
|
86
|
-
expect(Money3Compat.first.save).to be_truthy
|
87
|
-
expect(Money3Compat.first.price_no_default.cents).to eq 12000
|
88
|
-
expect(Money3Compat.first.price_no_default.currency.iso_code).to eq 'GBP'
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'correctly migrates data' do
|
92
|
-
Money3.create!(price_no_default_currency: 'GBP', price_no_default_cents: '12000')
|
93
|
-
Money3Compat.migrate_from_money_field_3!(:price_no_default)
|
94
|
-
|
95
|
-
expect(Money3Compat.first.read_attribute(:price_no_default_currency)).to be_nil
|
96
|
-
expect(Money3Compat.first.read_attribute(:price_no_default_cents)).to be_nil
|
97
|
-
|
98
|
-
expect(Money3Compat.first.price_no_default.cents).to eq 12000
|
99
|
-
expect(Money3Compat.first.price_no_default.currency.iso_code).to eq 'GBP'
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'correctly migrates data with no currency' do
|
103
|
-
Money3.create!(price_no_default_cents: '12000')
|
104
|
-
Money3Compat.migrate_from_money_field_3!(:price_no_default)
|
105
|
-
|
106
|
-
expect(Money3Compat.first.read_attribute(:price_no_default_currency)).to be_nil
|
107
|
-
expect(Money3Compat.first.read_attribute(:price_no_default_cents)).to be_nil
|
108
|
-
|
109
|
-
expect(Money3Compat.first.price_no_default.cents).to eq 12000
|
110
|
-
expect(Money3Compat.first.price_no_default.currency.iso_code).to eq 'RUB'
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'correctly migrates data with no cents' do
|
114
|
-
Money3.create!()
|
115
|
-
Money3Compat.migrate_from_money_field_3!(:price_no_default)
|
116
|
-
|
117
|
-
expect(Money3Compat.first.read_attribute(:price_no_default_currency)).to be_nil
|
118
|
-
expect(Money3Compat.first.read_attribute(:price_no_default_cents)).to be_nil
|
119
|
-
|
120
|
-
expect(Money3Compat.first.price_no_default).to be_nil
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|