dolla_dolla_bill 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,10 +30,11 @@ module DollaDollaBill
30
30
  end
31
31
 
32
32
  self.class.send(:define_method, "lowest_#{name}") do
33
- select("#{cents_field_reader}, #{currency_field_reader}").
34
- order("#{cents_field_reader} ASC").
35
- first.
36
- price
33
+ lowest = select("#{cents_field_reader}, #{currency_field_reader}").
34
+ order("#{cents_field_reader} ASC").
35
+ first
36
+
37
+ lowest.nil? ? nil : lowest.price
37
38
  end
38
39
  end
39
40
  end
@@ -1,3 +1,3 @@
1
1
  module DollaDollaBill
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -84,6 +84,14 @@ describe DollaDollaBill do
84
84
  end
85
85
 
86
86
  describe '.lowest_money' do
87
+ context 'when there are no items' do
88
+ before { ExoticDancer.count.should be_zero }
89
+
90
+ it 'is nil' do
91
+ ExoticDancer.lowest_price.should be_nil
92
+ end
93
+ end
94
+
87
95
  context 'when there are two items with different amounts' do
88
96
  let!(:higher_money) { ExoticDancer.create( price_in_cents: 5433,
89
97
  price_currency: 'GBP') }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dolla_dolla_bill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-10 00:00:00.000000000 Z
13
+ date: 2012-10-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: money