osm 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/lib/osm/badge.rb +5 -1
- data/spec/osm/badge_spec.rb +8 -0
- data/version.rb +1 -1
- metadata +1 -1
data/CHANGELOG.md
CHANGED
data/lib/osm/badge.rb
CHANGED
@@ -357,7 +357,11 @@ module Osm
|
|
357
357
|
end
|
358
358
|
return false if (completed.eql?(1) && awarded.eql?(1))
|
359
359
|
return true if (completed.eql?(1) && awarded.eql?(0))
|
360
|
-
|
360
|
+
if badge.sections_needed == -1 # require all sections
|
361
|
+
return (sections_gained == badge.needed_from_section.keys.size)
|
362
|
+
else
|
363
|
+
return (total_gained >= badge.total_needed) && (sections_gained >= badge.sections_needed)
|
364
|
+
end
|
361
365
|
end
|
362
366
|
|
363
367
|
# Get what stage which has most recently been earnt
|
data/spec/osm/badge_spec.rb
CHANGED
@@ -201,6 +201,14 @@ describe "Badge" do
|
|
201
201
|
badge = Osm::ActivityBadge.new(:total_needed => 1, :sections_needed => 1, :needed_from_section => {'a' => 2, 'b' => 1})
|
202
202
|
data = Osm::Badge::Data.new(:requirements => {'a_01'=>'y', 'a_02'=>'y', 'b_01' => 'y'}, :completed => 0, :awarded => 0, :badge => badge)
|
203
203
|
data.earnt?.should be_true
|
204
|
+
|
205
|
+
badge = Osm::ActivityBadge.new(:total_needed => 0, :sections_needed => -1, :needed_from_section => {'a' => 2, 'b' => 1})
|
206
|
+
data = Osm::Badge::Data.new(:requirements => {'a_01'=>'y', 'a_02'=>'y', 'b_01' => 'y'}, :completed => 0, :awarded => 0, :badge => badge)
|
207
|
+
data.earnt?.should be_true
|
208
|
+
|
209
|
+
badge = Osm::ActivityBadge.new(:total_needed => 0, :sections_needed => -1, :needed_from_section => {'a' => 2, 'b' => 1})
|
210
|
+
data = Osm::Badge::Data.new(:requirements => {'a_01'=>'y', 'a_02'=>'x', 'b_01' => 'y'}, :completed => 0, :awarded => 0, :badge => badge)
|
211
|
+
data.earnt?.should be_false
|
204
212
|
end
|
205
213
|
end
|
206
214
|
|
data/version.rb
CHANGED