seamusabshere-conversions 1.4.1 → 1.4.2

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/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 4
3
- :patch: 1
3
+ :patch: 2
4
4
  :major: 1
data/conversions.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{conversions}
8
- s.version = "1.4.1"
8
+ s.version = "1.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Manfred Stienstra"]
12
- s.date = %q{2009-08-21}
12
+ s.date = %q{2009-09-15}
13
13
  s.description = %q{ A Ruby on Rails plugin that adds conversion capabilities to numeric objects"
14
14
  }
15
15
  s.email = %q{manfred@fngtps.com}
@@ -42,7 +42,7 @@ module Conversions
42
42
  value ? value.convert(options[:internal], options[:external], options.except(:internal, :external)) : nil
43
43
  end
44
44
  define_method "#{attribute}_in_#{options[:external]}=" do |v|
45
- send("#{attribute}=", v.to_f.convert(options[:external], options[:internal], options.except(:internal, :external)))
45
+ send("#{attribute}=", v.blank? ? nil : v.to_f.convert(options[:external], options[:internal], options.except(:internal, :external)))
46
46
  end
47
47
  end
48
48
  end
@@ -29,6 +29,24 @@ class AccessorTest < Test::Unit::TestCase
29
29
  assert_in_delta 745.645430684801, @flight.distance_in_miles, DELTA
30
30
  end
31
31
 
32
+ def test_set_zero
33
+ assert_equal nil, @flight.distance_in_miles
34
+ @flight.distance_in_miles = 0
35
+ assert_equal 0, @flight.distance_in_miles
36
+ end
37
+
38
+ def test_set_nil
39
+ assert_equal nil, @flight.distance_in_miles
40
+ @flight.distance_in_miles = nil
41
+ assert_equal nil, @flight.distance_in_miles
42
+ end
43
+
44
+ def test_set_blank
45
+ assert_equal nil, @flight.distance_in_miles
46
+ @flight.distance_in_miles = ''
47
+ assert_equal nil, @flight.distance_in_miles
48
+ end
49
+
32
50
  def test_conversion_with_scale
33
51
  @flight.fuel_consumption = 3400
34
52
  assert_equal 898.18, @flight.fuel_consumption_in_gallons, DELTA
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seamusabshere-conversions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manfred Stienstra
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-21 00:00:00 -07:00
12
+ date: 2009-09-15 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15