money-rails 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -0
- data/lib/money-rails/active_model/validator.rb +1 -1
- data/lib/money-rails/version.rb +1 -1
- data/spec/active_record/monetizable_spec.rb +21 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 039411253785e557d6b22b2ce90af40767ab9826
|
4
|
+
data.tar.gz: c2cbf81f1876b426f9706d93e28ed76d0fd1511e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d941f2078bbff98816829f488d9c0603b0c8715b7d4fa810e2f4d45c60765f5e4e0a64a7e2d723cbf62624b110bf8d2248067a2d4e09de75e7abb248ce90c82e
|
7
|
+
data.tar.gz: 732c397e937951ba6b557a4d9bd4b4e83b5860dfd24093c576cba5afdc5e1b30a0906f70f12140f77da4205ee72e04d2efb2b270f4859ff3fb07233b5615cf23
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ module MoneyRails
|
|
6
6
|
@record = record
|
7
7
|
@attr = attr
|
8
8
|
|
9
|
-
subunit_attr = @record.class.monetized_attributes[@attr.
|
9
|
+
subunit_attr = @record.class.monetized_attributes[@attr.to_s]
|
10
10
|
|
11
11
|
# WARNING: Currently this is only defined in ActiveRecord extension!
|
12
12
|
before_type_cast = :"#{@attr}_money_before_type_cast"
|
data/lib/money-rails/version.rb
CHANGED
@@ -2,10 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
class Sub < Product; end
|
4
4
|
|
5
|
-
class SubProduct < Product
|
6
|
-
monetize :special_price_cents
|
7
|
-
end
|
8
|
-
|
9
5
|
if defined? ActiveRecord
|
10
6
|
describe MoneyRails::ActiveRecord::Monetizable do
|
11
7
|
describe "monetize" do
|
@@ -22,12 +18,28 @@ if defined? ActiveRecord
|
|
22
18
|
Service.create(:charge_cents => 2000, :discount_cents => 120)
|
23
19
|
end
|
24
20
|
|
25
|
-
|
26
|
-
expect(Sub.monetized_attributes).to eq(Product.monetized_attributes)
|
27
|
-
end
|
21
|
+
context 'monetized_attributes' do
|
28
22
|
|
29
|
-
|
30
|
-
|
23
|
+
class InheritedMonetizeProduct < Product
|
24
|
+
monetize :special_price_cents
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should be inherited by subclasses" do
|
28
|
+
assert_monetized_attributes(Sub.monetized_attributes, Product.monetized_attributes)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should be inherited by subclasses with new monetized attribute" do
|
32
|
+
assert_monetized_attributes(InheritedMonetizeProduct.monetized_attributes, Product.monetized_attributes.merge(special_price: "special_price_cents"))
|
33
|
+
end
|
34
|
+
|
35
|
+
def assert_monetized_attributes(monetized_attributes, expected_attributes)
|
36
|
+
expect(monetized_attributes).to include expected_attributes
|
37
|
+
expect(expected_attributes).to include monetized_attributes
|
38
|
+
expect(monetized_attributes.size).to eql expected_attributes.size
|
39
|
+
monetized_attributes.keys.each do |key|
|
40
|
+
expect(key.is_a? String).to be_truthy
|
41
|
+
end
|
42
|
+
end
|
31
43
|
end
|
32
44
|
|
33
45
|
it "attaches a Money object to model field" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: money-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Loupasakis
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-04-
|
13
|
+
date: 2015-04-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: money
|