osm 1.2.17 → 1.2.18.dev
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.
- checksums.yaml +8 -8
- data/CHANGELOG.md +35 -0
- data/gemfiles/rails3 +1 -1
- data/lib/hash_validator.rb +12 -4
- data/lib/osm/api.rb +5 -6
- data/lib/osm/member.rb +503 -171
- data/lib/osm/section.rb +1 -26
- data/lib/validity_validator.rb +11 -0
- data/osm.gemspec +1 -1
- data/spec/array_of_validator_spec.rb +1 -1
- data/spec/hash_validator_spec.rb +133 -0
- data/spec/osm/activity_spec.rb +7 -7
- data/spec/osm/api_access_spec.rb +1 -1
- data/spec/osm/api_spec.rb +4 -4
- data/spec/osm/badge_spec.rb +62 -62
- data/spec/osm/badges_spec.rb +4 -4
- data/spec/osm/budget_spec.rb +8 -8
- data/spec/osm/event_spec.rb +42 -42
- data/spec/osm/flexi_record_spec.rb +18 -18
- data/spec/osm/giftaid_spec.rb +7 -7
- data/spec/osm/grouping_spec.rb +5 -5
- data/spec/osm/invoice_spec.rb +32 -32
- data/spec/osm/meeting_spec.rb +10 -10
- data/spec/osm/member_spec.rb +316 -167
- data/spec/osm/model_spec.rb +31 -31
- data/spec/osm/register_spec.rb +15 -15
- data/spec/osm/section_spec.rb +28 -71
- data/spec/osm/sms_spec.rb +1 -1
- data/spec/osm/term_spec.rb +31 -31
- data/spec/validity_validator_spec.rb +32 -0
- data/version.rb +1 -1
- metadata +13 -10
    
        data/spec/osm/giftaid_spec.rb
    CHANGED
    
    | @@ -11,7 +11,7 @@ describe "Gift Aid" do | |
| 11 11 | 
             
                )
         | 
| 12 12 |  | 
| 13 13 | 
             
                d.donation_date.should == Date.new(2000, 1, 2)
         | 
| 14 | 
            -
                d.valid?.should  | 
| 14 | 
            +
                d.valid?.should == true
         | 
| 15 15 | 
             
              end
         | 
| 16 16 |  | 
| 17 17 | 
             
              it "Sorts Donation by date" do
         | 
| @@ -51,7 +51,7 @@ describe "Gift Aid" do | |
| 51 51 | 
             
                d.donations.should == {
         | 
| 52 52 | 
             
                  Date.new(2012, 1, 2) => '1.23',
         | 
| 53 53 | 
             
                }
         | 
| 54 | 
            -
                d.valid?.should  | 
| 54 | 
            +
                d.valid?.should == true
         | 
| 55 55 | 
             
              end
         | 
| 56 56 |  | 
| 57 57 | 
             
              it "Sorts Data by section_id, grouping_id, last_name then first_name" do
         | 
| @@ -99,7 +99,7 @@ describe "Gift Aid" do | |
| 99 99 | 
             
                  FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/giftaid.php?action=getGrid§ionid=1&termid=2", :body => data.to_json, :content_type => 'application/json')
         | 
| 100 100 |  | 
| 101 101 | 
             
                  data = Osm::GiftAid.get_data(@api, 1, 2)
         | 
| 102 | 
            -
                  data.is_a?(Array).should  | 
| 102 | 
            +
                  data.is_a?(Array).should == true
         | 
| 103 103 | 
             
                  data.size.should == 1
         | 
| 104 104 | 
             
                  data = data[0]
         | 
| 105 105 | 
             
                  data.donations.should == {
         | 
| @@ -112,7 +112,7 @@ describe "Gift Aid" do | |
| 112 112 | 
             
                  data.member_id.should == 2
         | 
| 113 113 | 
             
                  data.total.should == '2.34'
         | 
| 114 114 | 
             
                  data.section_id.should == 1
         | 
| 115 | 
            -
                  data.valid?.should  | 
| 115 | 
            +
                  data.valid?.should == true
         | 
| 116 116 | 
             
                end
         | 
| 117 117 |  | 
| 118 118 | 
             
                it "Update donation" do
         | 
| @@ -139,7 +139,7 @@ describe "Gift Aid" do | |
| 139 139 | 
             
                    :members => [3, 4],
         | 
| 140 140 | 
             
                    :amount => '1.23',
         | 
| 141 141 | 
             
                    :note => 'Note',
         | 
| 142 | 
            -
                  }).should  | 
| 142 | 
            +
                  }).should == true
         | 
| 143 143 | 
             
                end
         | 
| 144 144 |  | 
| 145 145 | 
             
                describe "Update data" do
         | 
| @@ -188,7 +188,7 @@ describe "Gift Aid" do | |
| 188 188 | 
             
                    @data.tax_payer_name = 'n'
         | 
| 189 189 | 
             
                    @data.tax_payer_address = 'a'
         | 
| 190 190 | 
             
                    @data.tax_payer_postcode = 'pc'
         | 
| 191 | 
            -
                    @data.update(@api).should  | 
| 191 | 
            +
                    @data.update(@api).should == true
         | 
| 192 192 | 
             
                  end
         | 
| 193 193 |  | 
| 194 194 | 
             
                  it "A donation" do
         | 
| @@ -214,7 +214,7 @@ describe "Gift Aid" do | |
| 214 214 | 
             
                    HTTParty.should_receive(:post).with(url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>body_data.to_json}) }
         | 
| 215 215 |  | 
| 216 216 | 
             
                    @data.donations[Date.new(2012, 1, 3)] = '3.45'
         | 
| 217 | 
            -
                    @data.update(@api).should  | 
| 217 | 
            +
                    @data.update(@api).should == true
         | 
| 218 218 | 
             
                  end
         | 
| 219 219 |  | 
| 220 220 | 
             
                end
         | 
    
        data/spec/osm/grouping_spec.rb
    CHANGED
    
    | @@ -29,9 +29,9 @@ describe "Grouping" do | |
| 29 29 | 
             
                  patrol.id.should == 1
         | 
| 30 30 | 
             
                  patrol.section_id.should == 2
         | 
| 31 31 | 
             
                  patrol.name.should == 'Patrol Name'
         | 
| 32 | 
            -
                  patrol.active.should  | 
| 32 | 
            +
                  patrol.active.should == true
         | 
| 33 33 | 
             
                  patrol.points.should == 3
         | 
| 34 | 
            -
                  patrol.valid?.should  | 
| 34 | 
            +
                  patrol.valid?.should == true
         | 
| 35 35 | 
             
                end
         | 
| 36 36 |  | 
| 37 37 | 
             
                it "Handles no data" do
         | 
| @@ -61,7 +61,7 @@ describe "Grouping" do | |
| 61 61 | 
             
                    'active' => grouping.active,
         | 
| 62 62 | 
             
                  }}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>''}) }
         | 
| 63 63 |  | 
| 64 | 
            -
                  grouping.update(@api).should  | 
| 64 | 
            +
                  grouping.update(@api).should == true
         | 
| 65 65 | 
             
                end
         | 
| 66 66 |  | 
| 67 67 | 
             
                it "Update points in OSM (succeded)" do
         | 
| @@ -83,7 +83,7 @@ describe "Grouping" do | |
| 83 83 | 
             
                    'points' => grouping.points,
         | 
| 84 84 | 
             
                  }}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{}'}) }
         | 
| 85 85 |  | 
| 86 | 
            -
                  grouping.update(@api).should  | 
| 86 | 
            +
                  grouping.update(@api).should == true
         | 
| 87 87 | 
             
                end
         | 
| 88 88 |  | 
| 89 89 | 
             
                it "Update in OSM (failed)" do
         | 
| @@ -96,7 +96,7 @@ describe "Grouping" do | |
| 96 96 | 
             
                  grouping.active = true
         | 
| 97 97 |  | 
| 98 98 | 
             
                  HTTParty.stub(:post) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"done":false}'}) }
         | 
| 99 | 
            -
                  grouping.update(@api).should  | 
| 99 | 
            +
                  grouping.update(@api).should == false
         | 
| 100 100 | 
             
                end
         | 
| 101 101 |  | 
| 102 102 | 
             
              end
         | 
    
        data/spec/osm/invoice_spec.rb
    CHANGED
    
    | @@ -20,9 +20,9 @@ describe "Invoice" do | |
| 20 20 | 
             
                i.name.should == 'Name'
         | 
| 21 21 | 
             
                i.extra_details.should == 'Extra Details'
         | 
| 22 22 | 
             
                i.date.should == Date.new(2001, 2, 3)
         | 
| 23 | 
            -
                i.archived.should  | 
| 24 | 
            -
                i.finalised.should  | 
| 25 | 
            -
                i.valid?.should  | 
| 23 | 
            +
                i.archived.should == true
         | 
| 24 | 
            +
                i.finalised.should == true
         | 
| 25 | 
            +
                i.valid?.should == true
         | 
| 26 26 | 
             
              end
         | 
| 27 27 |  | 
| 28 28 | 
             
              it "Sorts Invoice by Section ID, Name then Date" do
         | 
| @@ -58,7 +58,7 @@ describe "Invoice" do | |
| 58 58 | 
             
                  ii.payto.should == 'Name'
         | 
| 59 59 | 
             
                  ii.description.should == 'Comments'
         | 
| 60 60 | 
             
                  ii.budget_name.should == 'Budget'
         | 
| 61 | 
            -
                  ii.valid?.should  | 
| 61 | 
            +
                  ii.valid?.should == true
         | 
| 62 62 | 
             
                end
         | 
| 63 63 |  | 
| 64 64 | 
             
                it "Sorts by Invoice then Date" do
         | 
| @@ -168,9 +168,9 @@ describe "Invoice" do | |
| 168 168 | 
             
                      invoice.name.should == 'Invoice 1'
         | 
| 169 169 | 
             
                      invoice.extra_details.should == 'Some more details'
         | 
| 170 170 | 
             
                      invoice.date.should == Date.new(2010, 1, 1)
         | 
| 171 | 
            -
                      invoice.archived.should  | 
| 172 | 
            -
                      invoice.finalised.should  | 
| 173 | 
            -
                      invoice.valid?.should  | 
| 171 | 
            +
                      invoice.archived.should == false
         | 
| 172 | 
            +
                      invoice.finalised.should == false
         | 
| 173 | 
            +
                      invoice.valid?.should == true
         | 
| 174 174 | 
             
                    end
         | 
| 175 175 |  | 
| 176 176 | 
             
                    it "Honours archived option" do
         | 
| @@ -291,7 +291,7 @@ describe "Invoice" do | |
| 291 291 | 
             
                      'date' => '2002-03-04',
         | 
| 292 292 | 
             
                    }) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body => '{"id":2}'}) }
         | 
| 293 293 |  | 
| 294 | 
            -
                    invoice.create(@api).should  | 
| 294 | 
            +
                    invoice.create(@api).should == true
         | 
| 295 295 | 
             
                    invoice.id.should == 2
         | 
| 296 296 | 
             
                  end
         | 
| 297 297 |  | 
| @@ -314,7 +314,7 @@ describe "Invoice" do | |
| 314 314 | 
             
                      'date' => '2002-03-04',
         | 
| 315 315 | 
             
                    }) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body => '{"message":"Something went wrong"}'}) }
         | 
| 316 316 |  | 
| 317 | 
            -
                    invoice.create(@api).should  | 
| 317 | 
            +
                    invoice.create(@api).should == false
         | 
| 318 318 | 
             
                    invoice.id.should be_nil
         | 
| 319 319 | 
             
                  end
         | 
| 320 320 |  | 
| @@ -339,7 +339,7 @@ describe "Invoice" do | |
| 339 339 | 
             
                      'date' => '2002-03-04',
         | 
| 340 340 | 
             
                    }) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body => '{"ok":true}'}) }
         | 
| 341 341 |  | 
| 342 | 
            -
                    invoice.update(@api).should  | 
| 342 | 
            +
                    invoice.update(@api).should == true
         | 
| 343 343 | 
             
                  end
         | 
| 344 344 |  | 
| 345 345 | 
             
                  it "Update (failure)" do
         | 
| @@ -363,7 +363,7 @@ describe "Invoice" do | |
| 363 363 | 
             
                      'date' => '2002-03-04',
         | 
| 364 364 | 
             
                    }) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body => '{"ok":false}'}) }
         | 
| 365 365 |  | 
| 366 | 
            -
                    invoice.update(@api).should  | 
| 366 | 
            +
                    invoice.update(@api).should == false
         | 
| 367 367 | 
             
                  end
         | 
| 368 368 |  | 
| 369 369 | 
             
                  it "Delete (success)" do
         | 
| @@ -378,7 +378,7 @@ describe "Invoice" do | |
| 378 378 | 
             
                      'invoiceid' => 1,
         | 
| 379 379 | 
             
                    }) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body => '{"ok":true}'}) }
         | 
| 380 380 |  | 
| 381 | 
            -
                    invoice.delete(@api).should  | 
| 381 | 
            +
                    invoice.delete(@api).should == true
         | 
| 382 382 | 
             
                  end
         | 
| 383 383 |  | 
| 384 384 | 
             
                  it "Delete (failure)" do
         | 
| @@ -393,7 +393,7 @@ describe "Invoice" do | |
| 393 393 | 
             
                      'invoiceid' => 1,
         | 
| 394 394 | 
             
                    }) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body => '{"ok":false}'}) }
         | 
| 395 395 |  | 
| 396 | 
            -
                    invoice.delete(@api).should  | 
| 396 | 
            +
                    invoice.delete(@api).should == false
         | 
| 397 397 | 
             
                  end
         | 
| 398 398 |  | 
| 399 399 | 
             
                  it "Finalise invoice (success)" do
         | 
| @@ -407,8 +407,8 @@ describe "Invoice" do | |
| 407 407 | 
             
                      'secret' => 'secret',
         | 
| 408 408 | 
             
                    }) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body => '{"ok":true}'}) }
         | 
| 409 409 |  | 
| 410 | 
            -
                    invoice.finalise(@api).should  | 
| 411 | 
            -
                    invoice.finalised.should  | 
| 410 | 
            +
                    invoice.finalise(@api).should == true
         | 
| 411 | 
            +
                    invoice.finalised.should == true
         | 
| 412 412 | 
             
                  end
         | 
| 413 413 |  | 
| 414 414 | 
             
                  it "Finalise invoice (failure)" do
         | 
| @@ -422,8 +422,8 @@ describe "Invoice" do | |
| 422 422 | 
             
                      'secret' => 'secret',
         | 
| 423 423 | 
             
                    }) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body => '{"ok":false}'}) }
         | 
| 424 424 |  | 
| 425 | 
            -
                    invoice.finalise(@api).should  | 
| 426 | 
            -
                    invoice.finalised.should  | 
| 425 | 
            +
                    invoice.finalise(@api).should == false
         | 
| 426 | 
            +
                    invoice.finalised.should == false
         | 
| 427 427 | 
             
                  end
         | 
| 428 428 |  | 
| 429 429 | 
             
                  it "Finalise invoice (already finalised)" do
         | 
| @@ -431,8 +431,8 @@ describe "Invoice" do | |
| 431 431 |  | 
| 432 432 | 
             
                    HTTParty.should_not_receive(:post)
         | 
| 433 433 |  | 
| 434 | 
            -
                    invoice.finalise(@api).should  | 
| 435 | 
            -
                    invoice.finalised.should  | 
| 434 | 
            +
                    invoice.finalise(@api).should == false
         | 
| 435 | 
            +
                    invoice.finalised.should == true
         | 
| 436 436 | 
             
                  end
         | 
| 437 437 |  | 
| 438 438 | 
             
                  it "Archive invoice (success)" do
         | 
| @@ -448,8 +448,8 @@ describe "Invoice" do | |
| 448 448 | 
             
                      'archived' => 1,
         | 
| 449 449 | 
             
                    }) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body => '{"ok":true}'}) }
         | 
| 450 450 |  | 
| 451 | 
            -
                    invoice.archive(@api).should  | 
| 452 | 
            -
                    invoice.archived.should  | 
| 451 | 
            +
                    invoice.archive(@api).should == true
         | 
| 452 | 
            +
                    invoice.archived.should == true
         | 
| 453 453 | 
             
                  end
         | 
| 454 454 |  | 
| 455 455 | 
             
                  it "Archive invoice (failure)" do
         | 
| @@ -465,8 +465,8 @@ describe "Invoice" do | |
| 465 465 | 
             
                      'archived' => 1,
         | 
| 466 466 | 
             
                    }) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body => '{"ok":false}'}) }
         | 
| 467 467 |  | 
| 468 | 
            -
                    invoice.archive(@api).should  | 
| 469 | 
            -
                    invoice.archived.should  | 
| 468 | 
            +
                    invoice.archive(@api).should == false
         | 
| 469 | 
            +
                    invoice.archived.should == false
         | 
| 470 470 | 
             
                  end
         | 
| 471 471 |  | 
| 472 472 | 
             
                  it "Archive invoice (already archived)" do
         | 
| @@ -474,8 +474,8 @@ describe "Invoice" do | |
| 474 474 |  | 
| 475 475 | 
             
                    HTTParty.should_not_receive(:post)
         | 
| 476 476 |  | 
| 477 | 
            -
                    invoice.archive(@api).should  | 
| 478 | 
            -
                    invoice.archived.should  | 
| 477 | 
            +
                    invoice.archive(@api).should == false
         | 
| 478 | 
            +
                    invoice.archived.should == true
         | 
| 479 479 | 
             
                  end
         | 
| 480 480 |  | 
| 481 481 | 
             
                end
         | 
| @@ -502,7 +502,7 @@ describe "Invoice" do | |
| 502 502 | 
             
                    item.payto.should == 'John Smith'
         | 
| 503 503 | 
             
                    item.budget_name.should == 'Default'
         | 
| 504 504 | 
             
                    item.description.should == 'Comment'
         | 
| 505 | 
            -
                    item.valid?.should  | 
| 505 | 
            +
                    item.valid?.should == true
         | 
| 506 506 | 
             
                  end
         | 
| 507 507 |  | 
| 508 508 | 
             
                  it "Create (success)" do
         | 
| @@ -558,7 +558,7 @@ describe "Invoice" do | |
| 558 558 | 
             
                      }) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body => {osm_name => new_value}.to_json}) }
         | 
| 559 559 | 
             
                    end
         | 
| 560 560 |  | 
| 561 | 
            -
                    item.create(@api).should  | 
| 561 | 
            +
                    item.create(@api).should == true
         | 
| 562 562 | 
             
                    item.id.should == 2
         | 
| 563 563 | 
             
                    item.record_id.should == 4
         | 
| 564 564 | 
             
                  end
         | 
| @@ -588,7 +588,7 @@ describe "Invoice" do | |
| 588 588 | 
             
                    ]
         | 
| 589 589 | 
             
                    invoice.should_receive(:get_items).with(@api, {:no_cache=>true}).and_return(data)
         | 
| 590 590 |  | 
| 591 | 
            -
                    item.create(@api).should  | 
| 591 | 
            +
                    item.create(@api).should == false
         | 
| 592 592 | 
             
                  end
         | 
| 593 593 |  | 
| 594 594 | 
             
                  it "Update (success)" do
         | 
| @@ -628,7 +628,7 @@ describe "Invoice" do | |
| 628 628 | 
             
                      }) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body => {osm_name => new_value}.to_json}) }
         | 
| 629 629 | 
             
                    end
         | 
| 630 630 |  | 
| 631 | 
            -
                    item.update(@api).should  | 
| 631 | 
            +
                    item.update(@api).should == true
         | 
| 632 632 | 
             
                  end
         | 
| 633 633 |  | 
| 634 634 | 
             
                  it "Update (failure)" do
         | 
| @@ -659,7 +659,7 @@ describe "Invoice" do | |
| 659 659 | 
             
                      'value' => 'A new description',
         | 
| 660 660 | 
             
                    }) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body => '{"comments":"A description"}'}) }
         | 
| 661 661 |  | 
| 662 | 
            -
                    item.update(@api).should  | 
| 662 | 
            +
                    item.update(@api).should == false
         | 
| 663 663 | 
             
                  end
         | 
| 664 664 |  | 
| 665 665 | 
             
                  it "Delete (success)" do
         | 
| @@ -674,7 +674,7 @@ describe "Invoice" do | |
| 674 674 | 
             
                      'id' => 1,
         | 
| 675 675 | 
             
                    }) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body => '{"ok":true}'}) }
         | 
| 676 676 |  | 
| 677 | 
            -
                    item.delete(@api).should  | 
| 677 | 
            +
                    item.delete(@api).should == true
         | 
| 678 678 | 
             
                  end
         | 
| 679 679 |  | 
| 680 680 | 
             
                  it "Delete (failure)" do
         | 
| @@ -689,7 +689,7 @@ describe "Invoice" do | |
| 689 689 | 
             
                      'id' => 1,
         | 
| 690 690 | 
             
                    }) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body => '{"ok":false}'}) }
         | 
| 691 691 |  | 
| 692 | 
            -
                    item.delete(@api).should  | 
| 692 | 
            +
                    item.delete(@api).should == false
         | 
| 693 693 | 
             
                  end
         | 
| 694 694 |  | 
| 695 695 | 
             
                end
         | 
    
        data/spec/osm/meeting_spec.rb
    CHANGED
    
    | @@ -34,7 +34,7 @@ describe "Meeting" do | |
| 34 34 | 
             
                e.date.should == Date.new(2000, 1, 2)
         | 
| 35 35 | 
             
                e.activities.should == []
         | 
| 36 36 | 
             
                e.badge_links.should == []
         | 
| 37 | 
            -
                e.valid?.should  | 
| 37 | 
            +
                e.valid?.should == true
         | 
| 38 38 | 
             
              end
         | 
| 39 39 |  | 
| 40 40 | 
             
              it "Sorts by Section ID, Meeting date, Start time and then Meeting ID" do
         | 
| @@ -61,7 +61,7 @@ describe "Meeting" do | |
| 61 61 | 
             
                  ea.activity_id.should == 2
         | 
| 62 62 | 
             
                  ea.title.should == 'Activity Name'
         | 
| 63 63 | 
             
                  ea.notes.should == 'Notes'
         | 
| 64 | 
            -
                  ea.valid?.should  | 
| 64 | 
            +
                  ea.valid?.should == true
         | 
| 65 65 | 
             
                end
         | 
| 66 66 |  | 
| 67 67 | 
             
                it "Sorts by title then activity_id" do
         | 
| @@ -106,7 +106,7 @@ describe "Meeting" do | |
| 106 106 | 
             
                  programme = Osm::Meeting.get_for_section(@api, 3, 4)
         | 
| 107 107 | 
             
                  programme.size.should == 1
         | 
| 108 108 | 
             
                  meeting = programme[0]
         | 
| 109 | 
            -
                  meeting.is_a?(Osm::Meeting).should  | 
| 109 | 
            +
                  meeting.is_a?(Osm::Meeting).should == true
         | 
| 110 110 | 
             
                  meeting.id.should == 5
         | 
| 111 111 | 
             
                  meeting.section_id.should == 3
         | 
| 112 112 | 
             
                  meeting.title.should == 'Weekly Meeting 1'
         | 
| @@ -199,7 +199,7 @@ describe "Meeting" do | |
| 199 199 | 
             
                    :start_time => '11:11',
         | 
| 200 200 | 
             
                    :finish_time => '22:22',
         | 
| 201 201 | 
             
                    :title => 'Title',
         | 
| 202 | 
            -
                  }).is_a?(Osm::Meeting).should  | 
| 202 | 
            +
                  }).is_a?(Osm::Meeting).should == true
         | 
| 203 203 | 
             
                end
         | 
| 204 204 |  | 
| 205 205 | 
             
                it "Create a meeting (failed)" do
         | 
| @@ -232,7 +232,7 @@ describe "Meeting" do | |
| 232 232 | 
             
                  HTTParty.should_receive(:post).with(url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":0}'}) }
         | 
| 233 233 | 
             
                  activity = Osm::Activity.new(:id => 2, :title => 'Title')
         | 
| 234 234 | 
             
                  meeting = Osm::Meeting.new(:section_id => 1, :date => Date.new(2000, 1, 2))
         | 
| 235 | 
            -
                  meeting.add_activity(@api, activity, 'Notes').should  | 
| 235 | 
            +
                  meeting.add_activity(@api, activity, 'Notes').should == true
         | 
| 236 236 | 
             
                  meeting.activities[0].activity_id.should == 2
         | 
| 237 237 | 
             
                end
         | 
| 238 238 |  | 
| @@ -240,7 +240,7 @@ describe "Meeting" do | |
| 240 240 | 
             
                  HTTParty.should_receive(:post) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":1}'}) }
         | 
| 241 241 | 
             
                  activity = Osm::Activity.new(:id => 2, :title => 'Title')
         | 
| 242 242 | 
             
                  meeting = Osm::Meeting.new(:section_id => 1, :date => Date.new(2000, 1, 2))
         | 
| 243 | 
            -
                  meeting.add_activity(@api, activity, 'Notes').should  | 
| 243 | 
            +
                  meeting.add_activity(@api, activity, 'Notes').should == false
         | 
| 244 244 | 
             
                end
         | 
| 245 245 |  | 
| 246 246 |  | 
| @@ -276,7 +276,7 @@ describe "Meeting" do | |
| 276 276 | 
             
                      :requirement_id => 93384,
         | 
| 277 277 | 
             
                    )]
         | 
| 278 278 | 
             
                  )
         | 
| 279 | 
            -
                  meeting.update(@api).should  | 
| 279 | 
            +
                  meeting.update(@api).should == true
         | 
| 280 280 | 
             
                end
         | 
| 281 281 |  | 
| 282 282 | 
             
                it "Update a meeting (failed)" do
         | 
| @@ -294,7 +294,7 @@ describe "Meeting" do | |
| 294 294 | 
             
                  HTTParty.should_receive(:post).with(url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":1}'}) }
         | 
| 295 295 |  | 
| 296 296 | 
             
                  meeting = Osm::Meeting.new(:id=>1, :section_id=>2, :date=>Date.new(2000, 01, 02))
         | 
| 297 | 
            -
                  meeting.update(@api).should  | 
| 297 | 
            +
                  meeting.update(@api).should == false
         | 
| 298 298 | 
             
                end
         | 
| 299 299 |  | 
| 300 300 | 
             
                it "Update a meeting (invalid meeting)" do
         | 
| @@ -315,7 +315,7 @@ describe "Meeting" do | |
| 315 315 | 
             
                  HTTParty.should_receive(:post).with(url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>''}) }
         | 
| 316 316 |  | 
| 317 317 | 
             
                  meeting = Osm::Meeting.new(:id=>1, :section_id=>2)
         | 
| 318 | 
            -
                  meeting.delete(@api).should  | 
| 318 | 
            +
                  meeting.delete(@api).should == true
         | 
| 319 319 | 
             
                end
         | 
| 320 320 |  | 
| 321 321 | 
             
              end # Describe using API
         | 
| @@ -339,7 +339,7 @@ describe "Meeting" do | |
| 339 339 | 
             
                  activity.activity_id.should == 6
         | 
| 340 340 | 
             
                  activity.title.should == 'Activity 6'
         | 
| 341 341 | 
             
                  activity.notes.should == 'Some notes'
         | 
| 342 | 
            -
                  meeting.valid?.should  | 
| 342 | 
            +
                  meeting.valid?.should == true
         | 
| 343 343 | 
             
                end
         | 
| 344 344 | 
             
              end
         | 
| 345 345 |  | 
    
        data/spec/osm/member_spec.rb
    CHANGED
    
    | @@ -7,86 +7,50 @@ describe "Member" do | |
| 7 7 | 
             
                attributes = {
         | 
| 8 8 | 
             
                  :id => 1,
         | 
| 9 9 | 
             
                  :section_id => 2,
         | 
| 10 | 
            -
                  :type => '',
         | 
| 11 10 | 
             
                  :first_name => 'First',
         | 
| 12 11 | 
             
                  :last_name => 'Last',
         | 
| 13 | 
            -
                  :email1 => 'email1@example.com',
         | 
| 14 | 
            -
                  :email2 => 'email2@example.com',
         | 
| 15 | 
            -
                  :email3 => 'email3@example.com',
         | 
| 16 | 
            -
                  :email4 => 'email4@example.com',
         | 
| 17 | 
            -
                  :phone1 => '11111 111111',
         | 
| 18 | 
            -
                  :phone2 => '222222',
         | 
| 19 | 
            -
                  :phone3 => '+33 3333 333333',
         | 
| 20 | 
            -
                  :phone4 => '4444 444 444',
         | 
| 21 | 
            -
                  :address => '1 Some Road',
         | 
| 22 | 
            -
                  :address2 => '',
         | 
| 23 12 | 
             
                  :date_of_birth => '2000-01-02',
         | 
| 24 | 
            -
                  :started => '2006-01-02',
         | 
| 25 | 
            -
                  :joining_in_years => '2',
         | 
| 26 | 
            -
                  :parents => 'John and Jane Doe',
         | 
| 27 | 
            -
                  :notes => 'None',
         | 
| 28 | 
            -
                  :medical => 'Nothing',
         | 
| 29 | 
            -
                  :religion => 'Unknown',
         | 
| 30 | 
            -
                  :school=> 'Some School',
         | 
| 31 | 
            -
                  :ethnicity => 'Yes',
         | 
| 32 | 
            -
                  :subs => 'Upto end of 2007',
         | 
| 33 | 
            -
                  :custom1 => 'Custom Field 1',
         | 
| 34 | 
            -
                  :custom2 => 'Custom Field 2',
         | 
| 35 | 
            -
                  :custom3 => 'Custom Field 3',
         | 
| 36 | 
            -
                  :custom4 => 'Custom Field 4',
         | 
| 37 | 
            -
                  :custom5 => 'Custom Field 5',
         | 
| 38 | 
            -
                  :custom6 => 'Custom Field 6',
         | 
| 39 | 
            -
                  :custom7 => 'Custom Field 7',
         | 
| 40 | 
            -
                  :custom8 => 'Custom Field 8',
         | 
| 41 | 
            -
                  :custom9 => 'Custom Field 9',
         | 
| 42 13 | 
             
                  :grouping_id => '3',
         | 
| 43 14 | 
             
                  :grouping_leader => 0,
         | 
| 44 | 
            -
                  : | 
| 45 | 
            -
                  : | 
| 46 | 
            -
                  : | 
| 15 | 
            +
                  :grouping_label => 'Grouping',
         | 
| 16 | 
            +
                  :grouping_leader_label => '6er',
         | 
| 17 | 
            +
                  :age => '06 / 07',
         | 
| 18 | 
            +
                  :gender => :other,
         | 
| 19 | 
            +
                  :joined_movement => '2006-01-02',
         | 
| 20 | 
            +
                  :started_section => '2006-01-07',
         | 
| 21 | 
            +
                  :finished_section => '2007-12-31',
         | 
| 22 | 
            +
                  :custom => {'12_3' => '123'},
         | 
| 23 | 
            +
                  :custom_labels => {'12_3' => 'Label for 123'},
         | 
| 24 | 
            +
                  :contact => Osm::Member::MemberContact.new(postcode: 'A'),
         | 
| 25 | 
            +
                  :primary_contact => Osm::Member::PrimaryContact.new(postcode: 'B'),
         | 
| 26 | 
            +
                  :secondary_contact => Osm::Member::PrimaryContact.new(postcode: 'C'),
         | 
| 27 | 
            +
                  :emergency_contact => Osm::Member::EmergencyContact.new(postcode: 'D'),
         | 
| 28 | 
            +
                  :doctor => Osm::Member::DoctorContact.new(postcode: 'E'),
         | 
| 47 29 | 
             
                }
         | 
| 48 30 | 
             
                member = Osm::Member.new(attributes)
         | 
| 49 31 |  | 
| 50 32 | 
             
                member.id.should == 1
         | 
| 51 33 | 
             
                member.section_id.should == 2
         | 
| 52 | 
            -
                member.type.should == ''
         | 
| 53 34 | 
             
                member.first_name.should == 'First'
         | 
| 54 35 | 
             
                member.last_name.should == 'Last'
         | 
| 55 | 
            -
                member.email1.should == 'email1@example.com'
         | 
| 56 | 
            -
                member.email2.should == 'email2@example.com'
         | 
| 57 | 
            -
                member.email3.should == 'email3@example.com'
         | 
| 58 | 
            -
                member.email4.should == 'email4@example.com'
         | 
| 59 | 
            -
                member.phone1.should == '11111 111111'
         | 
| 60 | 
            -
                member.phone2.should == '222222'
         | 
| 61 | 
            -
                member.phone3.should == '+33 3333 333333'
         | 
| 62 | 
            -
                member.phone4.should == '4444 444 444'
         | 
| 63 | 
            -
                member.address.should == '1 Some Road'
         | 
| 64 | 
            -
                member.address2.should == ''
         | 
| 65 36 | 
             
                member.date_of_birth.should == Date.new(2000, 1, 2)
         | 
| 66 | 
            -
                member.started.should == Date.new(2006, 1, 2)
         | 
| 67 | 
            -
                member.joining_in_years.should == 2
         | 
| 68 | 
            -
                member.parents.should == 'John and Jane Doe'
         | 
| 69 | 
            -
                member.notes.should == 'None'
         | 
| 70 | 
            -
                member.medical.should == 'Nothing'
         | 
| 71 | 
            -
                member.religion.should == 'Unknown'
         | 
| 72 | 
            -
                member.school.should == 'Some School'
         | 
| 73 | 
            -
                member.ethnicity.should == 'Yes'
         | 
| 74 | 
            -
                member.subs.should == 'Upto end of 2007'
         | 
| 75 | 
            -
                member.custom1.should == 'Custom Field 1'
         | 
| 76 | 
            -
                member.custom2.should == 'Custom Field 2'
         | 
| 77 | 
            -
                member.custom3.should == 'Custom Field 3'
         | 
| 78 | 
            -
                member.custom4.should == 'Custom Field 4'
         | 
| 79 | 
            -
                member.custom5.should == 'Custom Field 5'
         | 
| 80 | 
            -
                member.custom6.should == 'Custom Field 6'
         | 
| 81 | 
            -
                member.custom7.should == 'Custom Field 7'
         | 
| 82 | 
            -
                member.custom8.should == 'Custom Field 8'
         | 
| 83 | 
            -
                member.custom9.should == 'Custom Field 9'
         | 
| 84 37 | 
             
                member.grouping_id.should == 3
         | 
| 85 38 | 
             
                member.grouping_leader.should == 0
         | 
| 86 | 
            -
                member. | 
| 87 | 
            -
                member. | 
| 88 | 
            -
                member. | 
| 89 | 
            -
                member. | 
| 39 | 
            +
                member.grouping_label.should == 'Grouping'
         | 
| 40 | 
            +
                member.grouping_leader_label.should == '6er'
         | 
| 41 | 
            +
                member.age.should == '06 / 07'
         | 
| 42 | 
            +
                member.gender.should == :other
         | 
| 43 | 
            +
                member.joined_movement.should == Date.new(2006, 1, 2)
         | 
| 44 | 
            +
                member.started_section.should == Date.new(2006, 1, 7)
         | 
| 45 | 
            +
                member.finished_section.should == Date.new(2007, 12, 31)
         | 
| 46 | 
            +
                member.custom.should == {'12_3' => '123'}
         | 
| 47 | 
            +
                member.custom_labels.should == {'12_3' => 'Label for 123'}
         | 
| 48 | 
            +
                member.contact.postcode.should == 'A'
         | 
| 49 | 
            +
                member.primary_contact.postcode.should == 'B'
         | 
| 50 | 
            +
                member.secondary_contact.postcode.should == 'C'
         | 
| 51 | 
            +
                member.emergency_contact.postcode.should == 'D'
         | 
| 52 | 
            +
                member.doctor.postcode.should == 'E'
         | 
| 53 | 
            +
                member.valid?.should == true
         | 
| 90 54 | 
             
              end
         | 
| 91 55 |  | 
| 92 56 |  | 
| @@ -102,15 +66,15 @@ describe "Member" do | |
| 102 66 | 
             
              end
         | 
| 103 67 |  | 
| 104 68 | 
             
              it "Tells if member is a leader" do
         | 
| 105 | 
            -
                Osm::Member.new(grouping_id: -2).leader?.should  | 
| 106 | 
            -
                Osm::Member.new(grouping_id: 2).leader?.should  | 
| 107 | 
            -
                Osm::Member.new(grouping_id: 0).leader?.should  | 
| 69 | 
            +
                Osm::Member.new(grouping_id: -2).leader?.should == true  # In the leader grouping
         | 
| 70 | 
            +
                Osm::Member.new(grouping_id: 2).leader?.should == false  # In a youth grouping
         | 
| 71 | 
            +
                Osm::Member.new(grouping_id: 0).leader?.should == false  # Not in a grouping
         | 
| 108 72 | 
             
              end
         | 
| 109 73 |  | 
| 110 74 | 
             
              it "Tells if member is a youth member" do
         | 
| 111 | 
            -
                Osm::Member.new(grouping_id: -2).youth?.should  | 
| 112 | 
            -
                Osm::Member.new(grouping_id: 2).youth?.should  | 
| 113 | 
            -
                Osm::Member.new(grouping_id: 0).youth?.should  | 
| 75 | 
            +
                Osm::Member.new(grouping_id: -2).youth?.should == false  # In the leader grouping
         | 
| 76 | 
            +
                Osm::Member.new(grouping_id: 2).youth?.should == true  # In a youth grouping
         | 
| 77 | 
            +
                Osm::Member.new(grouping_id: 0).youth?.should == false  # Not in a grouping
         | 
| 114 78 | 
             
              end
         | 
| 115 79 |  | 
| 116 80 | 
             
              it "Provides each part of age" do
         | 
| @@ -123,6 +87,45 @@ describe "Member" do | |
| 123 87 | 
             
                member.age_months.should == 7
         | 
| 124 88 | 
             
              end
         | 
| 125 89 |  | 
| 90 | 
            +
              it "Tells if the member is male" do
         | 
| 91 | 
            +
                Osm::Member.new(gender: :male).male?.should == true
         | 
| 92 | 
            +
                Osm::Member.new(gender: :female).male?.should == false
         | 
| 93 | 
            +
                Osm::Member.new(gender: :other).male?.should == false
         | 
| 94 | 
            +
                Osm::Member.new(gender: :unspecified).male?.should == false
         | 
| 95 | 
            +
                Osm::Member.new(gender: nil).male?.should == false
         | 
| 96 | 
            +
              end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
              it "Tells if the member is female" do
         | 
| 99 | 
            +
                Osm::Member.new(gender: :female).female?.should == true
         | 
| 100 | 
            +
                Osm::Member.new(gender: :male).female?.should == false
         | 
| 101 | 
            +
                Osm::Member.new(gender: :other).female?.should == false
         | 
| 102 | 
            +
                Osm::Member.new(gender: :unspecified).female?.should == false
         | 
| 103 | 
            +
                Osm::Member.new(gender: nil).female?.should == false
         | 
| 104 | 
            +
              end
         | 
| 105 | 
            +
             | 
| 106 | 
            +
              describe "Tells if the member is currently in the section" do
         | 
| 107 | 
            +
                it "Today" do
         | 
| 108 | 
            +
                  Osm::Member.new(started_section: Date.yesterday).current?.should == true
         | 
| 109 | 
            +
                  Osm::Member.new(started_section: Date.today).current?.should == true
         | 
| 110 | 
            +
                  Osm::Member.new(started_section: Date.tomorrow).current?.should == false
         | 
| 111 | 
            +
                  Osm::Member.new(started_section: Date.yesterday, finished_section: Date.yesterday).current?.should == false
         | 
| 112 | 
            +
                  Osm::Member.new(started_section: Date.yesterday, finished_section: Date.today).current?.should == true
         | 
| 113 | 
            +
                  Osm::Member.new(started_section: Date.yesterday, finished_section: Date.tomorrow).current?.should == true
         | 
| 114 | 
            +
                end
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                it "Another date" do
         | 
| 117 | 
            +
                  yesterday = Date.new(2014, 10, 15)
         | 
| 118 | 
            +
                  today = Date.new(2014, 10, 16)
         | 
| 119 | 
            +
                  tomorrow = Date.new(2014, 10, 17)
         | 
| 120 | 
            +
                  Osm::Member.new(started_section: yesterday).current?(today).should == true
         | 
| 121 | 
            +
                  Osm::Member.new(started_section: today).current?(today).should == true
         | 
| 122 | 
            +
                  Osm::Member.new(started_section: tomorrow).current?(today).should == false
         | 
| 123 | 
            +
                  Osm::Member.new(started_section: yesterday, finished_section: yesterday).current?(today).should == false
         | 
| 124 | 
            +
                  Osm::Member.new(started_section: yesterday, finished_section: today).current?(today).should == true
         | 
| 125 | 
            +
                  Osm::Member.new(started_section: yesterday, finished_section: tomorrow).current?(today).should == true
         | 
| 126 | 
            +
                end
         | 
| 127 | 
            +
              end
         | 
| 128 | 
            +
             | 
| 126 129 |  | 
| 127 130 | 
             
              it "Sorts by section_id, grouping_id, grouping_leader (descending), last_name then first_name" do
         | 
| 128 131 | 
             
                m1 = Osm::Member.new(:section_id => 1, :grouping_id => 1, :grouping_leader => 1, :last_name => 'a', :first_name => 'a')
         | 
| @@ -140,88 +143,233 @@ describe "Member" do | |
| 140 143 |  | 
| 141 144 | 
             
              describe "Using the API" do
         | 
| 142 145 |  | 
| 143 | 
            -
                it " | 
| 144 | 
            -
                  body = [
         | 
| 145 | 
            -
                    {"sectionConfig"=>"{\"subscription_level\":1,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"beavers\",\"columnNames\":{\"column_names\":\"names\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[],\"wizard\":\"false\",\"fields\":{\"fields\":true},\"intouch\":{\"intouch_fields\":true},\"mobFields\":{\"mobile_fields\":true}}", "groupname"=>"3rd Somewhere", "groupid"=>"3", "groupNormalised"=>"1", "sectionid"=>"1", "sectionname"=>"Section 1", "section"=>"beavers", "isDefault"=>"1", "permissions"=>{"badge"=>10, "member"=>20, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}},
         | 
| 146 | 
            -
                  ]
         | 
| 147 | 
            -
                  FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json, :content_type => 'application/json')
         | 
| 148 | 
            -
             | 
| 146 | 
            +
                it "Get from OSM" do
         | 
| 149 147 | 
             
                  body = {
         | 
| 150 | 
            -
                    ' | 
| 151 | 
            -
                    ' | 
| 152 | 
            -
             | 
| 153 | 
            -
                      ' | 
| 154 | 
            -
             | 
| 155 | 
            -
             | 
| 156 | 
            -
             | 
| 157 | 
            -
             | 
| 158 | 
            -
             | 
| 159 | 
            -
             | 
| 160 | 
            -
             | 
| 161 | 
            -
             | 
| 162 | 
            -
             | 
| 163 | 
            -
             | 
| 164 | 
            -
             | 
| 165 | 
            -
             | 
| 166 | 
            -
             | 
| 167 | 
            -
             | 
| 168 | 
            -
             | 
| 169 | 
            -
             | 
| 170 | 
            -
             | 
| 171 | 
            -
             | 
| 172 | 
            -
             | 
| 173 | 
            -
             | 
| 174 | 
            -
             | 
| 175 | 
            -
             | 
| 176 | 
            -
             | 
| 177 | 
            -
                       | 
| 178 | 
            -
             | 
| 179 | 
            -
             | 
| 180 | 
            -
                      ' | 
| 181 | 
            -
                      ' | 
| 182 | 
            -
                      ' | 
| 183 | 
            -
                      ' | 
| 184 | 
            -
             | 
| 185 | 
            -
             | 
| 186 | 
            -
             | 
| 187 | 
            -
             | 
| 188 | 
            -
             | 
| 189 | 
            -
             | 
| 190 | 
            -
             | 
| 191 | 
            -
             | 
| 192 | 
            -
             | 
| 193 | 
            -
             | 
| 194 | 
            -
             | 
| 148 | 
            +
                    'status' => true,
         | 
| 149 | 
            +
                    'error' => nil,
         | 
| 150 | 
            +
                    'data' => {
         | 
| 151 | 
            +
                      '123' => {
         | 
| 152 | 
            +
                        'acive' => true,
         | 
| 153 | 
            +
                        'age' => '12 / 00',
         | 
| 154 | 
            +
                        'date_of_birth' => '2000-03-08',
         | 
| 155 | 
            +
                        'end_date' => '2010-06-03',
         | 
| 156 | 
            +
                        'first_name' => 'John',
         | 
| 157 | 
            +
                        'joined' => '2008-07-12',
         | 
| 158 | 
            +
                        'last_name' => 'Smith',
         | 
| 159 | 
            +
                        'member_id' => 123,
         | 
| 160 | 
            +
                        'patrol' => 'Leaders',
         | 
| 161 | 
            +
                        'patrol_id' => -2,
         | 
| 162 | 
            +
                        'patrol_role_level' => 1,
         | 
| 163 | 
            +
                        'patrol_role_level_label' => 'Assistant leader',
         | 
| 164 | 
            +
                        'section_id' => 1,
         | 
| 165 | 
            +
                        'started' => '2006-07-17',
         | 
| 166 | 
            +
                        'custom_data' => {
         | 
| 167 | 
            +
                          '1' => {'2' => 'Primary', '3' => 'Contact', '7' => 'Address 1', '8' => 'Address 2', '9' => 'Address 3', '10' => 'Address 4', '11' => 'Postcode', '12' => 'primary@example.com', '13' => 'yes', '14' => '', '15' => '', '18' => '01234 567890', '19' => 'yes', '20' => '0987 654321', '21' => '', '8441' => 'Data for 8441'},
         | 
| 168 | 
            +
                          '2' => {'2' => 'Secondary', '3' => 'Contact', '7' => 'Address 1', '8' => 'Address 2', '9' => 'Address 3', '10' => 'Address 4', '11' => 'Postcode', '12' => 'secondary@example.com', '13' => 'yes', '14' => '', '15' => '', '18' => '01234 567890', '19' => 'yes', '20' => '0987 654321', '21' => '', '8442' => 'Data for 8442'},
         | 
| 169 | 
            +
                          '3' => {'2' => 'Emergency', '3' => 'Contact', '7' => 'Address 1', '8' => 'Address 2', '9' => 'Address 3', '10' => 'Address 4', '11' => 'Postcode', '12' => 'emergency@example.com', '14' => '', '18' => '01234 567890', '20' => '0987 654321', '21' => '', '8443' => 'Data for 8443'},
         | 
| 170 | 
            +
                          '4' => {'2' => 'Doctor', '3' => 'Contact', '7' => 'Address 1', '8' => 'Address 2', '9' => 'Address 3', '10' => 'Address 4', '11' => 'Postcode', '18' => '01234 567890', '20' => '0987 654321', '21' => '', '54' => 'Surgery', '8444' => 'Data for 8444'},
         | 
| 171 | 
            +
                          '5' => {'4848' => 'Data for 4848'},
         | 
| 172 | 
            +
                          '6' => {'7' => 'Address 1', '8' => 'Address 2', '9' => 'Address 3', '10' => 'Address 4', '11' => 'Postcode', '12' => 'member@example.com', '13' => 'yes', '14' => '', '15' => '', '18' => '01234 567890', '19' => 'yes', '20' => '0987 654321', '21' => '', '8446' => 'Data for 8446'},
         | 
| 173 | 
            +
                          '7' => {'34' => 'Unspecified'},
         | 
| 174 | 
            +
                        },
         | 
| 175 | 
            +
                      }
         | 
| 176 | 
            +
                    },
         | 
| 177 | 
            +
                    'meta' => {
         | 
| 178 | 
            +
                      'leader_count' => 20,
         | 
| 179 | 
            +
                      'member_count' => 30,
         | 
| 180 | 
            +
                      'status' => true,
         | 
| 181 | 
            +
                      'structure' => [
         | 
| 182 | 
            +
                        {'group_id' => 1, 'description' => '', 'identifier' => 'contact_primary_1', 'name' => 'Primary Contact 1', 'columns' => [
         | 
| 183 | 
            +
                          {'column_id' => 2, 'group_column_id' => '1_2', 'label' => 'First Name', 'varname' => 'firstname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 184 | 
            +
                          {'column_id' => 3, 'group_column_id' => '1_3', 'label' => 'Last Name', 'varname' => 'lastname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 185 | 
            +
                          {'column_id' => 7, 'group_column_id' => '1_7', 'label' => 'Address 1', 'varname' => 'address1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 186 | 
            +
                          {'column_id' => 8, 'group_column_id' => '1_8', 'label' => 'Address 2', 'varname' => 'address2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 187 | 
            +
                          {'column_id' => 9, 'group_column_id' => '1_9', 'label' => 'Address 3', 'varname' => 'address3', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 188 | 
            +
                          {'column_id' => 10, 'group_column_id' => '1_10', 'label' => 'Address 4', 'varname' => 'address4', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 189 | 
            +
                          {'column_id' => 11, 'group_column_id' => '1_11', 'label' => 'Postcode', 'varname' => 'postcode', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 190 | 
            +
                          {'column_id' => 12, 'group_column_id' => '1_12', 'label' => 'Email 1', 'varname' => 'email1', 'read_only' => 'no', 'required' => 'no', 'type' => 'email', 'width' => 120},
         | 
| 191 | 
            +
                          {'column_id' => 14, 'group_column_id' => '1_14', 'label' => 'Email 2', 'varname' => 'email2', 'read_only' => 'no', 'required' => 'no', 'type' => 'email', 'width' => 120},
         | 
| 192 | 
            +
                          {'column_id' => 18, 'group_column_id' => '1_18', 'label' => 'Phone 1', 'varname' => 'phone1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 193 | 
            +
                          {'column_id' => 20, 'group_column_id' => '1_20', 'label' => 'Phone 2', 'varname' => 'phone2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 194 | 
            +
                          {'column_id' => 8441, 'group_column_id' => '1_8441', 'label' => 'Label for 8441', 'varname' => 'label_for_8441', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 195 | 
            +
                        ]},
         | 
| 196 | 
            +
                        {'group_id' => 2, 'description' => '', 'identifier' => 'contact_primary_2', 'name' => 'Primary Contact 2', 'columns' => [
         | 
| 197 | 
            +
                          {'column_id' => 2, 'group_column_id' => '2_2', 'label' => 'First Name', 'varname' => 'firstname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 198 | 
            +
                          {'column_id' => 3, 'group_column_id' => '2_3', 'label' => 'Last Name', 'varname' => 'lastname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 199 | 
            +
                          {'column_id' => 7, 'group_column_id' => '2_7', 'label' => 'Address 1', 'varname' => 'address1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 200 | 
            +
                          {'column_id' => 8, 'group_column_id' => '2_8', 'label' => 'Address 2', 'varname' => 'address2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 201 | 
            +
                          {'column_id' => 9, 'group_column_id' => '2_9', 'label' => 'Address 3', 'varname' => 'address3', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 202 | 
            +
                          {'column_id' => 10, 'group_column_id' => '2_10', 'label' => 'Address 4', 'varname' => 'address4', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 203 | 
            +
                          {'column_id' => 11, 'group_column_id' => '2_11', 'label' => 'Postcode', 'varname' => 'postcode', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 204 | 
            +
                          {'column_id' => 12, 'group_column_id' => '2_12', 'label' => 'Email 1', 'varname' => 'email1', 'read_only' => 'no', 'required' => 'no', 'type' => 'email', 'width' => 120},
         | 
| 205 | 
            +
                          {'column_id' => 14, 'group_column_id' => '2_14', 'label' => 'Email 2', 'varname' => 'email2', 'read_only' => 'no', 'required' => 'no', 'type' => 'email', 'width' => 120},
         | 
| 206 | 
            +
                          {'column_id' => 18, 'group_column_id' => '2_18', 'label' => 'Phone 1', 'varname' => 'phone1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 207 | 
            +
                          {'column_id' => 20, 'group_column_id' => '2_20', 'label' => 'Phone 2', 'varname' => 'phone2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 208 | 
            +
                          {'column_id' => 8442, 'group_column_id' => '2_8442', 'label' => 'Label for 8442', 'varname' => 'label_for_8442', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 209 | 
            +
                        ]},
         | 
| 210 | 
            +
                        {'group_id' => 3, 'description' => '', 'identifier' => 'emergency', 'name' => 'Emergency Contact', 'columns' => [
         | 
| 211 | 
            +
                          {'column_id' => 2, 'group_column_id' => '3_2', 'label' => 'First Name', 'varname' => 'firstname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 212 | 
            +
                          {'column_id' => 3, 'group_column_id' => '3_3', 'label' => 'Last Name', 'varname' => 'lastname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 213 | 
            +
                          {'column_id' => 7, 'group_column_id' => '3_7', 'label' => 'Address 1', 'varname' => 'address1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 214 | 
            +
                          {'column_id' => 8, 'group_column_id' => '3_8', 'label' => 'Address 2', 'varname' => 'address2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 215 | 
            +
                          {'column_id' => 9, 'group_column_id' => '3_9', 'label' => 'Address 3', 'varname' => 'address3', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 216 | 
            +
                          {'column_id' => 10, 'group_column_id' => '3_10', 'label' => 'Address 4', 'varname' => 'address4', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 217 | 
            +
                          {'column_id' => 11, 'group_column_id' => '3_11', 'label' => 'Postcode', 'varname' => 'postcode', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 218 | 
            +
                          {'column_id' => 12, 'group_column_id' => '3_12', 'label' => 'Email 1', 'varname' => 'email1', 'read_only' => 'no', 'required' => 'no', 'type' => 'email', 'width' => 120},
         | 
| 219 | 
            +
                          {'column_id' => 14, 'group_column_id' => '3_14', 'label' => 'Email 2', 'varname' => 'email2', 'read_only' => 'no', 'required' => 'no', 'type' => 'email', 'width' => 120},
         | 
| 220 | 
            +
                          {'column_id' => 18, 'group_column_id' => '3_18', 'label' => 'Phone 1', 'varname' => 'phone1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 221 | 
            +
                          {'column_id' => 20, 'group_column_id' => '3_20', 'label' => 'Phone 2', 'varname' => 'phone2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 222 | 
            +
                          {'column_id' => 8443, 'group_column_id' => '3_8443', 'label' => 'Label for 8443', 'varname' => 'label_for_8443', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 223 | 
            +
                        ]},
         | 
| 224 | 
            +
                        {'group_id' => 4, 'description' => '', 'identifier' => 'doctor', 'name' => "Doctor's Surgery", 'columns' => [
         | 
| 225 | 
            +
                          {'column_id' => 2, 'group_column_id' => '4_2', 'label' => 'First Name', 'varname' => 'firstname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 226 | 
            +
                          {'column_id' => 3, 'group_column_id' => '4_3', 'label' => 'Last Name', 'varname' => 'lastname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 227 | 
            +
                          {'column_id' => 54, 'group_column_id' => '4_54', 'label' => 'Surgery', 'varname' => 'surgery', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 228 | 
            +
                          {'column_id' => 7, 'group_column_id' => '4_7', 'label' => 'Address 1', 'varname' => 'address1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 229 | 
            +
                          {'column_id' => 8, 'group_column_id' => '4_8', 'label' => 'Address 2', 'varname' => 'address2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 230 | 
            +
                          {'column_id' => 9, 'group_column_id' => '4_9', 'label' => 'Address 3', 'varname' => 'address3', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 231 | 
            +
                          {'column_id' => 10, 'group_column_id' => '4_10', 'label' => 'Address 4', 'varname' => 'address4', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 232 | 
            +
                          {'column_id' => 11, 'group_column_id' => '4_11', 'label' => 'Postcode', 'varname' => 'postcode', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 233 | 
            +
                          {'column_id' => 18, 'group_column_id' => '4_18', 'label' => 'Phone 1', 'varname' => 'phone1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 234 | 
            +
                          {'column_id' => 20, 'group_column_id' => '4_20', 'label' => 'Phone 2', 'varname' => 'phone2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 235 | 
            +
                          {'column_id' => 8444, 'group_column_id' => '4_8444', 'label' => 'Label for 8444', 'varname' => 'label_for_8444', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 236 | 
            +
                        ]},
         | 
| 237 | 
            +
                        {'group_id' => 6, 'description' => '', 'identifier' => 'contact_member', 'name' => 'Member', 'columns' => [
         | 
| 238 | 
            +
                          {'column_id' => 2, 'group_column_id' => '6_2', 'label' => 'First Name', 'varname' => 'firstname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 239 | 
            +
                          {'column_id' => 3, 'group_column_id' => '6_3', 'label' => 'Last Name', 'varname' => 'lastname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 240 | 
            +
                          {'column_id' => 7, 'group_column_id' => '6_7', 'label' => 'Address 1', 'varname' => 'address1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 241 | 
            +
                          {'column_id' => 8, 'group_column_id' => '6_8', 'label' => 'Address 2', 'varname' => 'address2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 242 | 
            +
                          {'column_id' => 9, 'group_column_id' => '6_9', 'label' => 'Address 3', 'varname' => 'address3', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 243 | 
            +
                          {'column_id' => 10, 'group_column_id' => '6_10', 'label' => 'Address 4', 'varname' => 'address4', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 244 | 
            +
                          {'column_id' => 11, 'group_column_id' => '6_11', 'label' => 'Postcode', 'varname' => 'postcode', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 245 | 
            +
                          {'column_id' => 12, 'group_column_id' => '6_12', 'label' => 'Email 1', 'varname' => 'email1', 'read_only' => 'no', 'required' => 'no', 'type' => 'email', 'width' => 120},
         | 
| 246 | 
            +
                          {'column_id' => 14, 'group_column_id' => '6_14', 'label' => 'Email 2', 'varname' => 'email2', 'read_only' => 'no', 'required' => 'no', 'type' => 'email', 'width' => 120},
         | 
| 247 | 
            +
                          {'column_id' => 18, 'group_column_id' => '6_18', 'label' => 'Phone 1', 'varname' => 'phone1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 248 | 
            +
                          {'column_id' => 20, 'group_column_id' => '6_20', 'label' => 'Phone 2', 'varname' => 'phone2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 249 | 
            +
                          {'column_id' => 8446, 'group_column_id' => '6_8446', 'label' => 'Label for 8446', 'varname' => 'label_for_8446', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 250 | 
            +
                        ]},
         | 
| 251 | 
            +
                        {'group_id' => 5, 'description' => 'This allows you to add  extra information for your members.', 'identifier' => 'customisable_data', 'name' => 'Customisable Data', 'columns' => [
         | 
| 252 | 
            +
                          {'column_id' => 4848, 'group_column_id' => '5_4848', 'label' => 'Label for 4848', 'varname' => 'label_for_4848', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 253 | 
            +
                        ]},
         | 
| 254 | 
            +
                        {'group_id' => 7, 'description' => '', 'identifier' => 'floating', 'name' => 'Floating', 'columns' => [
         | 
| 255 | 
            +
                          {'column_id' => 34, 'group_column_id' => '7_34', 'label' => 'Gender', 'varname' => 'gender', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
         | 
| 256 | 
            +
                        ]},
         | 
| 257 | 
            +
                      ],
         | 
| 258 | 
            +
                    },
         | 
| 195 259 | 
             
                  }
         | 
| 196 | 
            -
                  FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ | 
| 197 | 
            -
             | 
| 198 | 
            -
                  body = {'items' => [{'scoutid'=>'1', 'pic'=>true}]}
         | 
| 199 | 
            -
                  FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ext/members/contact/?action=getListOfMembers&sort=patrolid§ionid=1&termid=2§ion=beavers", :body => body.to_json, :content_type => 'application/json') 
         | 
| 260 | 
            +
                  FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ext/members/contact/grid/?action=getMembers", :body => body.to_json, :content_type => 'application/json')
         | 
| 200 261 |  | 
| 201 262 | 
             
                  members = Osm::Member.get_for_section(@api, 1, 2)
         | 
| 202 263 | 
             
                  members.size.should == 1
         | 
| 203 | 
            -
                  members[0] | 
| 264 | 
            +
                  member = members[0]
         | 
| 265 | 
            +
                  member.id.should == 123
         | 
| 266 | 
            +
                  member.section_id.should == 1
         | 
| 267 | 
            +
                  member.first_name.should == 'John'
         | 
| 268 | 
            +
                  member.last_name.should == 'Smith'
         | 
| 269 | 
            +
                  member.date_of_birth.should == Date.new(2000, 3, 8)
         | 
| 270 | 
            +
                  member.grouping_id.should == -2
         | 
| 271 | 
            +
                  member.grouping_leader.should == 1
         | 
| 272 | 
            +
                  member.grouping_label.should == 'Leaders'
         | 
| 273 | 
            +
                  member.grouping_leader_label.should == 'Assistant leader'
         | 
| 274 | 
            +
                  member.age.should == '12 / 00'
         | 
| 275 | 
            +
                  member.gender.should == :unspecified
         | 
| 276 | 
            +
                  member.joined_movement.should == Date.new(2006, 7, 17)
         | 
| 277 | 
            +
                  member.started_section.should == Date.new(2008, 7, 12)
         | 
| 278 | 
            +
                  member.finished_section.should == Date.new(2010, 6, 3)
         | 
| 279 | 
            +
                  member.custom.should == {4848 => 'Data for 4848'}
         | 
| 280 | 
            +
                  member.custom_labels.should == {4848 => 'Label for 4848'}
         | 
| 281 | 
            +
                  member.contact.first_name.should == 'John'
         | 
| 282 | 
            +
                  member.contact.last_name.should == 'Smith'
         | 
| 283 | 
            +
                  member.contact.address_1.should == 'Address 1'
         | 
| 284 | 
            +
                  member.contact.address_2.should == 'Address 2'
         | 
| 285 | 
            +
                  member.contact.address_3.should == 'Address 3'
         | 
| 286 | 
            +
                  member.contact.address_4.should == 'Address 4'
         | 
| 287 | 
            +
                  member.contact.postcode.should == 'Postcode'
         | 
| 288 | 
            +
                  member.contact.phone_1.should == '01234 567890'
         | 
| 289 | 
            +
                  member.contact.receive_phone_1.should == true
         | 
| 290 | 
            +
                  member.contact.phone_2.should == '0987 654321'
         | 
| 291 | 
            +
                  member.contact.receive_phone_2.should == false
         | 
| 292 | 
            +
                  member.contact.email_1.should == 'member@example.com'
         | 
| 293 | 
            +
                  member.contact.receive_email_1.should == true
         | 
| 294 | 
            +
                  member.contact.email_2.should == ''
         | 
| 295 | 
            +
                  member.contact.receive_email_2.should == false
         | 
| 296 | 
            +
                  member.contact.custom.should == {8446=>"Data for 8446"}
         | 
| 297 | 
            +
                  member.contact.custom_labels.should == {8446=>"Label for 8446"}
         | 
| 298 | 
            +
                  member.primary_contact.first_name.should == 'Primary'
         | 
| 299 | 
            +
                  member.primary_contact.last_name.should == 'Contact'
         | 
| 300 | 
            +
                  member.primary_contact.address_1.should == 'Address 1'
         | 
| 301 | 
            +
                  member.primary_contact.address_2.should == 'Address 2'
         | 
| 302 | 
            +
                  member.primary_contact.address_3.should == 'Address 3'
         | 
| 303 | 
            +
                  member.primary_contact.address_4.should == 'Address 4'
         | 
| 304 | 
            +
                  member.primary_contact.postcode.should == 'Postcode'
         | 
| 305 | 
            +
                  member.primary_contact.phone_1.should == '01234 567890'
         | 
| 306 | 
            +
                  member.primary_contact.receive_phone_1.should == true
         | 
| 307 | 
            +
                  member.primary_contact.phone_2.should == '0987 654321'
         | 
| 308 | 
            +
                  member.primary_contact.receive_phone_2.should == false
         | 
| 309 | 
            +
                  member.primary_contact.email_1.should == 'primary@example.com'
         | 
| 310 | 
            +
                  member.primary_contact.receive_email_1.should == true
         | 
| 311 | 
            +
                  member.primary_contact.email_2.should == ''
         | 
| 312 | 
            +
                  member.primary_contact.receive_email_2.should == false
         | 
| 313 | 
            +
                  member.primary_contact.custom.should == {8441=>"Data for 8441"}
         | 
| 314 | 
            +
                  member.primary_contact.custom_labels.should == {8441=>"Label for 8441"}
         | 
| 315 | 
            +
                  member.secondary_contact.first_name.should == 'Secondary'
         | 
| 316 | 
            +
                  member.secondary_contact.last_name.should == 'Contact'
         | 
| 317 | 
            +
                  member.secondary_contact.address_1.should == 'Address 1'
         | 
| 318 | 
            +
                  member.secondary_contact.address_2.should == 'Address 2'
         | 
| 319 | 
            +
                  member.secondary_contact.address_3.should == 'Address 3'
         | 
| 320 | 
            +
                  member.secondary_contact.address_4.should == 'Address 4'
         | 
| 321 | 
            +
                  member.secondary_contact.postcode.should == 'Postcode'
         | 
| 322 | 
            +
                  member.secondary_contact.phone_1.should == '01234 567890'
         | 
| 323 | 
            +
                  member.secondary_contact.receive_phone_1.should == true
         | 
| 324 | 
            +
                  member.secondary_contact.phone_2.should == '0987 654321'
         | 
| 325 | 
            +
                  member.secondary_contact.receive_phone_2.should == false
         | 
| 326 | 
            +
                  member.secondary_contact.email_1.should == 'secondary@example.com'
         | 
| 327 | 
            +
                  member.secondary_contact.receive_email_1.should == true
         | 
| 328 | 
            +
                  member.secondary_contact.email_2.should == ''
         | 
| 329 | 
            +
                  member.secondary_contact.receive_email_2.should == false
         | 
| 330 | 
            +
                  member.secondary_contact.custom.should == {8442=>"Data for 8442"}
         | 
| 331 | 
            +
                  member.secondary_contact.custom_labels.should == {8442=>"Label for 8442"}
         | 
| 332 | 
            +
                  member.emergency_contact.first_name.should == 'Emergency'
         | 
| 333 | 
            +
                  member.emergency_contact.last_name.should == 'Contact'
         | 
| 334 | 
            +
                  member.emergency_contact.address_1.should == 'Address 1'
         | 
| 335 | 
            +
                  member.emergency_contact.address_2.should == 'Address 2'
         | 
| 336 | 
            +
                  member.emergency_contact.address_3.should == 'Address 3'
         | 
| 337 | 
            +
                  member.emergency_contact.address_4.should == 'Address 4'
         | 
| 338 | 
            +
                  member.emergency_contact.postcode.should == 'Postcode'
         | 
| 339 | 
            +
                  member.emergency_contact.phone_1.should == '01234 567890'
         | 
| 340 | 
            +
                  member.emergency_contact.phone_2.should == '0987 654321'
         | 
| 341 | 
            +
                  member.emergency_contact.email_1.should == 'emergency@example.com'
         | 
| 342 | 
            +
                  member.emergency_contact.email_2.should == ''
         | 
| 343 | 
            +
                  member.emergency_contact.custom.should == {8443=>"Data for 8443"}
         | 
| 344 | 
            +
                  member.emergency_contact.custom_labels.should == {8443=>"Label for 8443"}
         | 
| 345 | 
            +
                  member.doctor.first_name.should == 'Doctor'
         | 
| 346 | 
            +
                  member.doctor.last_name.should == 'Contact'
         | 
| 347 | 
            +
                  member.doctor.surgery.should == 'Surgery'
         | 
| 348 | 
            +
                  member.doctor.address_1.should == 'Address 1'
         | 
| 349 | 
            +
                  member.doctor.address_2.should == 'Address 2'
         | 
| 350 | 
            +
                  member.doctor.address_3.should == 'Address 3'
         | 
| 351 | 
            +
                  member.doctor.address_4.should == 'Address 4'
         | 
| 352 | 
            +
                  member.doctor.postcode.should == 'Postcode'
         | 
| 353 | 
            +
                  member.doctor.phone_1.should == '01234 567890'
         | 
| 354 | 
            +
                  member.doctor.phone_2.should == '0987 654321'
         | 
| 355 | 
            +
                  member.doctor.custom.should == {8444=>"Data for 8444"}
         | 
| 356 | 
            +
                  member.doctor.custom_labels.should == {8444=>"Label for 8444"}
         | 
| 357 | 
            +
                  member.valid?.should == true
         | 
| 204 358 | 
             
                end
         | 
| 205 359 |  | 
| 206 | 
            -
                it " | 
| 207 | 
            -
                  body = [
         | 
| 208 | 
            -
                    {"sectionConfig"=>"{\"subscription_level\":1,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"waiting\",\"columnNames\":{\"column_names\":\"names\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[],\"wizard\":\"false\",\"fields\":{\"fields\":true},\"intouch\":{\"intouch_fields\":true},\"mobFields\":{\"mobile_fields\":true}}", "groupname"=>"3rd Somewhere", "groupid"=>"3", "groupNormalised"=>"1", "sectionid"=>"1", "sectionname"=>"Section 1", "section"=>"waiting", "isDefault"=>"1", "permissions"=>{"badge"=>10, "member"=>20, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}},
         | 
| 209 | 
            -
                  ]
         | 
| 210 | 
            -
                  FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json, :content_type => 'application/json')
         | 
| 211 | 
            -
             | 
| 360 | 
            +
                it "Get from OSM (handles an empty data array)" do
         | 
| 212 361 | 
             
                  body = {
         | 
| 213 | 
            -
                    ' | 
| 214 | 
            -
                    ' | 
| 362 | 
            +
                    'status' => true,
         | 
| 363 | 
            +
                    'error' => nil,
         | 
| 364 | 
            +
                    'data' => [],
         | 
| 365 | 
            +
                    'meta' => {},
         | 
| 215 366 | 
             
                  }
         | 
| 216 | 
            -
                  FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ | 
| 217 | 
            -
             | 
| 218 | 
            -
                  body = {'items' => [{'scoutid'=>'1', 'pic'=>true}]}
         | 
| 219 | 
            -
                  FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ext/members/contact/?action=getListOfMembers&sort=patrolid§ionid=1&termid=-1§ion=waiting", :body => body.to_json, :content_type => 'application/json')
         | 
| 367 | 
            +
                  FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ext/members/contact/grid/?action=getMembers", :body => body.to_json, :content_type => 'application/json')
         | 
| 220 368 |  | 
| 221 | 
            -
                   | 
| 222 | 
            -
                  members.size.should == 0
         | 
| 369 | 
            +
                  Osm::Member.get_for_section(@api, 1, 2).should == []
         | 
| 223 370 | 
             
                end
         | 
| 224 371 |  | 
| 372 | 
            +
             | 
| 225 373 | 
             
                it "Create in OSM (succeded)" do
         | 
| 226 374 | 
             
                  member = Osm::Member.new(
         | 
| 227 375 | 
             
                    :section_id => 2,
         | 
| @@ -304,7 +452,7 @@ describe "Member" do | |
| 304 452 |  | 
| 305 453 | 
             
                  Osm::Term.stub(:get_for_section) { [] }
         | 
| 306 454 | 
             
                  HTTParty.should_receive(:post).with(url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":"ok","scoutid":1}'}) }
         | 
| 307 | 
            -
                  member.create(@api).should  | 
| 455 | 
            +
                  member.create(@api).should == true
         | 
| 308 456 | 
             
                  member.id.should == 1
         | 
| 309 457 | 
             
                end
         | 
| 310 458 |  | 
| @@ -321,7 +469,7 @@ describe "Member" do | |
| 321 469 | 
             
                  )
         | 
| 322 470 |  | 
| 323 471 | 
             
                  HTTParty.should_receive(:post) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":"ok","scoutid":-1}'}) }
         | 
| 324 | 
            -
                  member.create(@api).should  | 
| 472 | 
            +
                  member.create(@api).should == false
         | 
| 325 473 | 
             
                end
         | 
| 326 474 |  | 
| 327 475 |  | 
| @@ -427,7 +575,7 @@ describe "Member" do | |
| 427 575 | 
             
                  }}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>body}) }
         | 
| 428 576 | 
             
                  Osm::Term.stub(:get_for_section) { [] }
         | 
| 429 577 |  | 
| 430 | 
            -
                  member.update(@api).should  | 
| 578 | 
            +
                  member.update(@api).should == true
         | 
| 431 579 | 
             
                end
         | 
| 432 580 |  | 
| 433 581 | 
             
                it "Update in OSM (only updated fields)" do
         | 
| @@ -478,7 +626,7 @@ describe "Member" do | |
| 478 626 | 
             
                  }}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>body}) }
         | 
| 479 627 | 
             
                  Osm::Term.stub(:get_for_section) { [] }
         | 
| 480 628 |  | 
| 481 | 
            -
                  member.update(@api).should  | 
| 629 | 
            +
                  member.update(@api).should == true
         | 
| 482 630 | 
             
                end
         | 
| 483 631 |  | 
| 484 632 | 
             
                it "Update in OSM (failed)" do
         | 
| @@ -495,7 +643,7 @@ describe "Member" do | |
| 495 643 | 
             
                  member.first_name = 'First'
         | 
| 496 644 |  | 
| 497 645 | 
             
                  HTTParty.stub(:post) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{}'}) }
         | 
| 498 | 
            -
                  member.update(@api).should  | 
| 646 | 
            +
                  member.update(@api).should == false
         | 
| 499 647 | 
             
                end
         | 
| 500 648 |  | 
| 501 649 | 
             
                it "Get Photo link" do
         | 
| @@ -505,33 +653,25 @@ describe "Member" do | |
| 505 653 | 
             
                    :first_name => 'First',
         | 
| 506 654 | 
             
                    :last_name => 'Last',
         | 
| 507 655 | 
             
                    :date_of_birth => '2000-01-02',
         | 
| 508 | 
            -
                    : | 
| 509 | 
            -
                    : | 
| 656 | 
            +
                    :started_section => '2006-01-02',
         | 
| 657 | 
            +
                    :joined_movement => '2006-01-03',
         | 
| 510 658 | 
             
                    :grouping_id => '3',
         | 
| 511 659 | 
             
                    :grouping_leader => 0,
         | 
| 512 | 
            -
                    : | 
| 660 | 
            +
                    :grouping_label => 'Grouping',
         | 
| 661 | 
            +
                    :grouping_leader_label => '',
         | 
| 662 | 
            +
                    :custom => {},
         | 
| 663 | 
            +
                    :custom_labels => {},
         | 
| 664 | 
            +
                    :contact => Osm::Member::MemberContact.new(),
         | 
| 665 | 
            +
                    :primary_contact => Osm::Member::PrimaryContact.new(),
         | 
| 666 | 
            +
                    :secondary_contact => Osm::Member::PrimaryContact.new(),
         | 
| 667 | 
            +
                    :emergency_contact => Osm::Member::EmergencyContact.new(),
         | 
| 668 | 
            +
                    :doctor => Osm::Member::DoctorContact.new(),
         | 
| 513 669 | 
             
                  )
         | 
| 514 670 | 
             
                  HTTParty.stub(:post) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :content_type=>'image/jpeg', :body=>'abcdef'}) }
         | 
| 515 671 |  | 
| 516 672 | 
             
                  member.get_photo(@api).should == "abcdef"
         | 
| 517 673 | 
             
                end
         | 
| 518 674 |  | 
| 519 | 
            -
                it "Get Photo link when no photo uploaded" do
         | 
| 520 | 
            -
                  member = Osm::Member.new(
         | 
| 521 | 
            -
                    :id => 1,
         | 
| 522 | 
            -
                    :section_id => 2,
         | 
| 523 | 
            -
                    :first_name => 'First',
         | 
| 524 | 
            -
                    :last_name => 'Last',
         | 
| 525 | 
            -
                    :date_of_birth => '2000-01-02',
         | 
| 526 | 
            -
                    :started => '2006-01-02',
         | 
| 527 | 
            -
                    :joined => '2006-01-03',
         | 
| 528 | 
            -
                    :grouping_id => '3',
         | 
| 529 | 
            -
                    :grouping_leader => 0,
         | 
| 530 | 
            -
                    :has_photo => false,
         | 
| 531 | 
            -
                  )
         | 
| 532 | 
            -
             | 
| 533 | 
            -
                  expect{ member.get_photo(@api) }.to raise_error(Osm::Error, "the member doesn't have a photo in OSM")
         | 
| 534 | 
            -
                end
         | 
| 535 675 |  | 
| 536 676 | 
             
                describe "Get My.SCOUT link" do
         | 
| 537 677 |  | 
| @@ -542,10 +682,19 @@ describe "Member" do | |
| 542 682 | 
             
                      :first_name => 'First',
         | 
| 543 683 | 
             
                      :last_name => 'Last',
         | 
| 544 684 | 
             
                      :date_of_birth => '2000-01-02',
         | 
| 545 | 
            -
                      : | 
| 546 | 
            -
                      : | 
| 685 | 
            +
                      :started_section => '2006-01-02',
         | 
| 686 | 
            +
                      :joined_movement => '2006-01-03',
         | 
| 547 687 | 
             
                      :grouping_id => '3',
         | 
| 548 688 | 
             
                      :grouping_leader => 0,
         | 
| 689 | 
            +
                      :grouping_label => 'Grouping',
         | 
| 690 | 
            +
                      :grouping_leader_label => '',
         | 
| 691 | 
            +
                      :custom => {},
         | 
| 692 | 
            +
                      :custom_labels => {},
         | 
| 693 | 
            +
                      :contact => Osm::Member::MemberContact.new(),
         | 
| 694 | 
            +
                      :primary_contact => Osm::Member::PrimaryContact.new(),
         | 
| 695 | 
            +
                      :secondary_contact => Osm::Member::PrimaryContact.new(),
         | 
| 696 | 
            +
                      :emergency_contact => Osm::Member::EmergencyContact.new(),
         | 
| 697 | 
            +
                      :doctor => Osm::Member::DoctorContact.new(),
         | 
| 549 698 | 
             
                    )
         | 
| 550 699 | 
             
                  end
         | 
| 551 700 |  |