dolla_dolla_bill 0.0.2 → 0.0.3
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/lib/dolla_dolla_bill.rb +5 -4
- data/lib/dolla_dolla_bill/version.rb +1 -1
- data/spec/dolla_dolla_bill_spec.rb +8 -0
- metadata +2 -2
data/lib/dolla_dolla_bill.rb
CHANGED
@@ -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
|
-
|
35
|
-
|
36
|
-
|
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
|
@@ -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.
|
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-
|
13
|
+
date: 2012-10-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: money
|