osm 0.6.2 → 0.6.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/CHANGELOG.md +4 -0
- data/lib/osm/badge.rb +7 -12
- data/spec/osm/badge_spec.rb +17 -0
- data/version.rb +1 -1
- metadata +1 -1
data/CHANGELOG.md
CHANGED
data/lib/osm/badge.rb
CHANGED
@@ -347,20 +347,15 @@ module Osm
|
|
347
347
|
# Check if this badge has been started
|
348
348
|
# @return [Boolean] whether the badge has been started by the member (always false if the badge has been completed)
|
349
349
|
def started?
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
else
|
356
|
-
# 'Normal' nonstaged badge
|
357
|
-
requirements.each do |key, value|
|
350
|
+
return (started > completed) if badge.type.eql?(:staged) # It's a staged badge
|
351
|
+
return false if completed?
|
352
|
+
requirements.each do |key, value|
|
353
|
+
case key.split('_')[0]
|
354
|
+
when 'a'
|
358
355
|
return true unless value.blank? || value[0].downcase.eql?('x')
|
359
|
-
|
356
|
+
when 'y'
|
357
|
+
return true if (requirements['y_01'].to_i > 0)
|
360
358
|
end
|
361
|
-
else
|
362
|
-
# Staged badge
|
363
|
-
return (started > completed)
|
364
359
|
end
|
365
360
|
return false
|
366
361
|
end
|
data/spec/osm/badge_spec.rb
CHANGED
@@ -176,6 +176,23 @@ describe "Badge" do
|
|
176
176
|
:completed => 0,
|
177
177
|
).started?.should be_false
|
178
178
|
|
179
|
+
# Scout's community challenge
|
180
|
+
Osm::Badge::Data.new(
|
181
|
+
:badge => Osm::ChallengeBadge.new(:osm_key => 'community'),
|
182
|
+
:requirements => {'y_01' => 5, 'a_01' => '', 'custom_26695' => 'Text'},
|
183
|
+
:completed => 0,
|
184
|
+
).started?.should be_true
|
185
|
+
Osm::Badge::Data.new(
|
186
|
+
:badge => Osm::ChallengeBadge.new(:osm_key => 'community'),
|
187
|
+
:requirements => {'y_01' => '', 'a_01' => '4', 'custom_26695' => 'Text'},
|
188
|
+
:completed => 0,
|
189
|
+
).started?.should be_true
|
190
|
+
Osm::Badge::Data.new(
|
191
|
+
:badge => Osm::ChallengeBadge.new(:osm_key => 'community'),
|
192
|
+
:requirements => {'y_01' => '', 'a_01' => '', 'custom_26695' => ''},
|
193
|
+
:completed => 0,
|
194
|
+
).started?.should be_false
|
195
|
+
|
179
196
|
# Beaver's adventure activity
|
180
197
|
Osm::Badge::Data.new(
|
181
198
|
:badge => Osm::ActivityBadge.new(:osm_key => 'adventure'),
|
data/version.rb
CHANGED