Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch '1.9.2' of github.com:jeroeningen/acts_as_price

  • Loading branch information...
commit 99bb3d4922f79d822091a6eaf8857de2dd4f0269 2 parents 2a83fec + f8d5b5c
jeroen authored
View
2  Gemfile
@@ -1,13 +1,13 @@
source 'http://rubygems.org'
gem 'rails', '3.0.7'
+gem 'rake', '0.8.7'
#only use in test envirnoment
group :test do
gem 'rspec-rails'
gem 'shoulda-matchers'
gem 'autotest'
- gem 'autotest-growl'
gem 'rcov'
gem 'metrical'
gem 'activerecord-nulldb-adapter'
View
166 Gemfile.lock
@@ -0,0 +1,166 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ Saikuro (1.1.0)
+ ZenTest (4.5.0)
+ abstract (1.0.0)
+ actionmailer (3.0.7)
+ actionpack (= 3.0.7)
+ mail (~> 2.2.15)
+ actionpack (3.0.7)
+ activemodel (= 3.0.7)
+ activesupport (= 3.0.7)
+ builder (~> 2.1.2)
+ erubis (~> 2.6.6)
+ i18n (~> 0.5.0)
+ rack (~> 1.2.1)
+ rack-mount (~> 0.6.14)
+ rack-test (~> 0.5.7)
+ tzinfo (~> 0.3.23)
+ activemodel (3.0.7)
+ activesupport (= 3.0.7)
+ builder (~> 2.1.2)
+ i18n (~> 0.5.0)
+ activerecord (3.0.7)
+ activemodel (= 3.0.7)
+ activesupport (= 3.0.7)
+ arel (~> 2.0.2)
+ tzinfo (~> 0.3.23)
+ activerecord-nulldb-adapter (0.2.1)
+ activerecord (>= 2.0.0, < 3.1)
+ activeresource (3.0.7)
+ activemodel (= 3.0.7)
+ activesupport (= 3.0.7)
+ activesupport (3.0.7)
+ arel (2.0.10)
+ arrayfields (4.7.4)
+ autotest (4.4.6)
+ ZenTest (>= 4.4.1)
+ builder (2.1.2)
+ chronic (0.3.0)
+ churn (0.0.13)
+ chronic (>= 0.2.3)
+ hirb
+ json_pure
+ main
+ ruby_parser (~> 2.0.4)
+ sexp_processor (~> 3.0.3)
+ colored (1.2)
+ diff-lcs (1.1.2)
+ erubis (2.6.6)
+ abstract (>= 1.0.0)
+ fattr (2.2.0)
+ flay (1.4.2)
+ ruby_parser (~> 2.0)
+ sexp_processor (~> 3.0)
+ flog (2.5.1)
+ ruby_parser (~> 2.0)
+ sexp_processor (~> 3.0)
+ git (1.2.5)
+ haml (3.1.1)
+ hirb (0.4.5)
+ i18n (0.5.0)
+ jeweler (1.5.2)
+ bundler (~> 1.0.0)
+ git (>= 1.2.5)
+ rake
+ json_pure (1.5.1)
+ mail (2.2.19)
+ activesupport (>= 2.3.6)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ main (4.4.0)
+ arrayfields (>= 4.7.4)
+ fattr (>= 2.1.0)
+ metric_fu (2.1.1)
+ Saikuro (>= 1.1.0)
+ activesupport (>= 2.0.0)
+ chronic (~> 0.3.0)
+ churn (>= 0.0.7)
+ flay (>= 1.2.1)
+ flog (>= 2.3.0)
+ rails_best_practices (>= 0.6.4)
+ rcov (>= 0.8.3.3)
+ reek (>= 1.2.6)
+ roodi (>= 2.1.0)
+ syntax
+ metrical (0.0.5)
+ activesupport
+ metric_fu (~> 2.1.1)
+ mime-types (1.16)
+ polyglot (0.3.1)
+ rack (1.2.3)
+ rack-mount (0.6.14)
+ rack (>= 1.0.0)
+ rack-test (0.5.7)
+ rack (>= 1.0)
+ rails (3.0.7)
+ actionmailer (= 3.0.7)
+ actionpack (= 3.0.7)
+ activerecord (= 3.0.7)
+ activeresource (= 3.0.7)
+ activesupport (= 3.0.7)
+ bundler (~> 1.0)
+ railties (= 3.0.7)
+ rails_best_practices (0.9.0)
+ activesupport
+ colored
+ erubis
+ haml
+ i18n
+ ruby-progressbar
+ ruby_parser
+ railties (3.0.7)
+ actionpack (= 3.0.7)
+ activesupport (= 3.0.7)
+ rake (>= 0.8.7)
+ thor (~> 0.14.4)
+ rake (0.8.7)
+ rcov (0.9.9)
+ reek (1.2.8)
+ ruby2ruby (~> 1.2)
+ ruby_parser (~> 2.0)
+ sexp_processor (~> 3.0)
+ roodi (2.1.0)
+ ruby_parser
+ rspec (2.6.0)
+ rspec-core (~> 2.6.0)
+ rspec-expectations (~> 2.6.0)
+ rspec-mocks (~> 2.6.0)
+ rspec-core (2.6.3)
+ rspec-expectations (2.6.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.6.0)
+ rspec-rails (2.6.1)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.6.0)
+ ruby-progressbar (0.0.10)
+ ruby2ruby (1.2.5)
+ ruby_parser (~> 2.0)
+ sexp_processor (~> 3.0)
+ ruby_parser (2.0.6)
+ sexp_processor (~> 3.0)
+ sexp_processor (3.0.5)
+ shoulda-matchers (1.0.0.beta2)
+ syntax (1.0.0)
+ thor (0.14.6)
+ treetop (1.4.9)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.27)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ activerecord-nulldb-adapter
+ autotest
+ jeweler (~> 1.5.2)
+ metrical
+ rails (= 3.0.7)
+ rake (= 0.8.7)
+ rcov
+ rspec-rails
+ shoulda-matchers
View
2  VERSION
@@ -1 +1 @@
-0.2.2
+0.2.3
View
10 lib/acts_as_price.rb
@@ -29,13 +29,13 @@ def acts_as_price column_name, options = {}
#getters
define_method(column_name) do
- if super.blank? or super == 0.0
+ if super().blank? or super() == 0.0
""
else
if comma
- return_val = sprintf("%.2f", super.to_f / 100).gsub(".", ",")
+ return_val = sprintf("%.2f", super().to_f / 100).gsub(".", ",")
else
- return_val = sprintf("%.2f", super.to_f / 100)
+ return_val = sprintf("%.2f", super().to_f / 100)
end
return_val = currency ? "#{currency}. #{return_val}" : return_val
return_val
@@ -45,9 +45,9 @@ def acts_as_price column_name, options = {}
define_method("price_in_cents") do
if currency
- ((send column_name).gsub("#{currency}. ", "").gsub(",", ".").to_f * 100).to_s.to_i
+ ((send column_name).gsub("#{currency}. ", "").gsub(",", ".").to_f * 100).round
else
- ((send column_name).gsub(",", ".").to_f * 100).to_s.to_i
+ ((send column_name).gsub(",", ".").to_f * 100).round
end
end
alias_method "#{column_name}_in_cents", "price_in_cents"
View
4 lib/acts_as_price_helper.rb
@@ -20,6 +20,7 @@ def test_acts_as_price_methods column_name, seperator, options = {}
#normal test for setter
test_setter_in_cents "144", seperator
+
if @acts_as_price_model.currency
currency = @acts_as_price_model.currency
test_setter_in_doubles "#{currency}. 1.41", seperator
@@ -30,6 +31,7 @@ def test_acts_as_price_methods column_name, seperator, options = {}
test_setter_in_doubles "#{currency}. 1.5", seperator
test_setter_in_doubles "#{currency}. 1.505", seperator
test_setter_in_doubles "#{currency}. 1.504", seperator
+
#test if 1,5 is returned as 1.50
test_setter_in_doubles "#{currency}. 1,5", seperator
test_setter_in_doubles "#{currency}. 1,505", seperator
@@ -100,7 +102,7 @@ def test_setter_in_doubles double, seperator
@acts_as_price_model.send(getter).should == ""
else
if currency
- @acts_as_price_model.send(getter).should == currency + ". " + sprintf("%.2f", (double.gsub(",", ".").to_f + 0.001).to_s).gsub(".", seperator)
+ @acts_as_price_model.send(getter).should == currency + ". " + sprintf("%.2f", double.gsub(",", ".").to_f + 0.0001).gsub(".", seperator)
else
@acts_as_price_model.send(getter).should == sprintf("%.2f", double.gsub(",", ".").to_s).gsub(".", seperator)
end
Please sign in to comment.
Something went wrong with that request. Please try again.