osm 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ ## Version 0.6.3
2
+
3
+ * Fix started? and started methods for badges with a combination of custom and normal requirements
4
+
1
5
  ## Version 0.6.2
2
6
 
3
7
  * Fix items not relevant to API appearing in permissions for a Section
@@ -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
- unless badge.type == :staged
351
- return false if completed?
352
- if badge.osm_key == 'adventure'
353
- # Badge requires completing a number of activities
354
- return (requirements['y_01'].to_i > 0)
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
- end
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Osm
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.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: 0.6.2
4
+ version: 0.6.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: