Sha256: ccc2110014bdefe106eb435b544c086cada66e4d2416d0cbd8415b634ce05d7c

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe "DueBadge" do

  it "Create from API data" do
    data = {
      'pending' => {
        'badge_name' => [
          {
            'scoutid' => '1',
            'firstname' => 'John',
            'lastname' => 'Doe',
            'completed' => '',
            'extra' => '',
          }
        ],
        'cubs_core_participation' => [{
            'sid' => '2',
            'firstname' => 'Jane',
            'lastname' => 'Doe',
            'completed' => '3',
            'extra' => 'Lvl 3'
          }, {
            'sid' => '1',
            'firstname' => 'John',
            'lastname' => 'Doe',
            'completed' => '2',
            'extra' => 'Lvl 2'
          }
        ]
      },

      'description' => {
        'badge_name' => {
          'name' => 'Badge Name',
          'section' => 'cubs',
          'type' => 'activity',
          'badge' => 'badge_name'
        },
        'cubs_core_participation' => {
          'name' => 'Participation',
          'section' => 'cubs',
          'type' => 'core',
          'badge' => 'participation'
        }
      }
    }
    db = Osm::DueBadges.from_api(data)

    db.empty?.should == false
    db.descriptions.should == {:badge_name=>{:name=>"Badge Name", :section=>:cubs, :type=>:activity, :badge=>"badge_name"}, :cubs_core_participation=>{:name=>"Participation", :section=>:cubs, :type=>:core, :badge=>"participation"}}
    db.by_member.should == {"John Doe"=>[{:badge=>:badge_name, :extra_information=>""}, {:badge=>:cubs_core_participation, :extra_information=>"Lvl 2"}], "Jane Doe"=>[{:badge=>:cubs_core_participation, :extra_information=>"Lvl 3"}]}
    db.totals.should == {:badge_name=>{""=>1}, :cubs_core_participation=>{"Lvl 3"=>1, "Lvl 2"=>1}}
    db.valid?.should be_true
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
osm-0.0.21 spec/osm/due_badges_spec.rb
osm-0.0.20 spec/osm/due_badges_spec.rb
osm-0.0.19 spec/osm/due_badges_spec.rb
osm-0.0.18 spec/osm/due_badges_spec.rb