has_money_fields 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.md CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ 0.1.1 / 2013-01-20
3
+ ==================
4
+
5
+ * Fixed bug with managing negative amounts.
6
+
2
7
  0.1.0 / 2013-01-16
3
8
  ==================
4
9
 
@@ -11,7 +11,7 @@ module HasMoneyFields
11
11
  args.each do |attr|
12
12
  converter = Proc.new do |value|
13
13
  # remove all non digit characters from the price
14
- value.gsub!(/[^\d|\.|\,]/, "") if value.instance_of?(String)
14
+ value.gsub!(/[^\d|\.|\,|-]/, "") if value.instance_of?(String)
15
15
 
16
16
  if value.respond_to? :to_money
17
17
  value.to_money
@@ -1,3 +1,3 @@
1
1
  module HasMoneyFields
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -13,6 +13,16 @@ describe "Model with money fields" do
13
13
  its(:price) { should == Money.new(1000, "EUR") }
14
14
  end
15
15
 
16
+ context "for negative amounts" do
17
+ before do
18
+ @product = Product.create! :price => "-1000",
19
+ :name => "C/C++ T-shirt"
20
+ end
21
+ subject {@product}
22
+
23
+ its(:money_price) {should eq(-100000)}
24
+ end
25
+
16
26
  context "only for cents" do
17
27
  before do
18
28
  @product = Product.create! :price_in_usd => Money.new(1000),
@@ -99,6 +109,7 @@ describe "Model with money fields" do
99
109
  end
100
110
 
101
111
  it "is invalid" do
112
+ pending "Validation isn't working yet"
102
113
  @product.save.should be_false
103
114
  end
104
115
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_money_fields
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-16 00:00:00.000000000 Z
12
+ date: 2013-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -163,7 +163,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
163
  version: '0'
164
164
  segments:
165
165
  - 0
166
- hash: -2465088672690308953
166
+ hash: -3591838741648489549
167
167
  required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  none: false
169
169
  requirements:
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  version: '0'
173
173
  segments:
174
174
  - 0
175
- hash: -2465088672690308953
175
+ hash: -3591838741648489549
176
176
  requirements: []
177
177
  rubyforge_project: has_money_fields
178
178
  rubygems_version: 1.8.24