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 CHANGED
@@ -1,3 +1,7 @@
1
+ ## Version 1.2.3
2
+
3
+ * Fix bug determining if a badge has been earnt (-1 sections required = all required)
4
+
1
5
  ## Version 1.2.2
2
6
 
3
7
  * Add base\_url method to Api class and instances
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
- return (total_gained >= badge.total_needed) && (sections_gained >= badge.sections_needed)
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Osm
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: