osm 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,7 +48,7 @@ describe "Badges" do
48
48
  }
49
49
  }
50
50
  }
51
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/challenges.php?action=outstandingBadges&section=cubs&sectionid=1&termid=2", :body => data.to_json)
51
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/challenges.php?action=outstandingBadges&section=cubs&sectionid=1&termid=2", :body => data.to_json, :content_type => 'application/json')
52
52
 
53
53
  db = Osm::Badges.get_due_badges(@api, Osm::Section.new(:id => 1, :type => :cubs), 2)
54
54
  db.empty?.should == false
@@ -60,7 +60,7 @@ describe "Badges" do
60
60
  end
61
61
 
62
62
  it "handles an empty array representing no due badges" do
63
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/challenges.php?action=outstandingBadges&section=cubs&sectionid=1&termid=2", :body => '[]')
63
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/challenges.php?action=outstandingBadges&section=cubs&sectionid=1&termid=2", :body => '[]', :content_type => 'application/json')
64
64
  db = Osm::Badges.get_due_badges(@api, Osm::Section.new(:id => 1, :type => :cubs), 2)
65
65
  db.should_not == nil
66
66
  end
@@ -74,7 +74,7 @@ describe "Badges" do
74
74
  'badge_2' => '2'
75
75
  }
76
76
  }
77
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/challenges.php?action=getInitialBadges&type=core&sectionid=1&section=beavers&termid=2", :body => badges_body.to_json)
77
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/challenges.php?action=getInitialBadges&type=core&sectionid=1&section=beavers&termid=2", :body => badges_body.to_json, :content_type => 'application/json')
78
78
  Osm::Term.stub(:get_current_term_for_section) { Osm::Term.new(:id => 2) }
79
79
 
80
80
  section = Osm::Section.new(:id => 1, :type => :beavers)
@@ -41,7 +41,7 @@ describe "Budget" do
41
41
  }
42
42
  ]
43
43
  }
44
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/finances.php?action=getCategories&sectionid=3", :body => data.to_json)
44
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/finances.php?action=getCategories&sectionid=3", :body => data.to_json, :content_type => 'application/json')
45
45
 
46
46
  budgets = Osm::Budget.get_for_section(@api, 3)
47
47
  budgets.should == [Osm::Budget.new(:id => 2, :section_id => 3, :name => 'Name')]
@@ -173,8 +173,8 @@ describe "Event" do
173
173
  'allowbooking' => '1',
174
174
  }
175
175
 
176
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvents&sectionid=1&showArchived=true", :body => @events_body.to_json)
177
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvent&sectionid=1&eventid=2", :body => @event_body.to_json)
176
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvents&sectionid=1&showArchived=true", :body => @events_body.to_json, :content_type => 'application/json')
177
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvent&sectionid=1&eventid=2", :body => @event_body.to_json, :content_type => 'application/json')
178
178
 
179
179
  Osm::Model.stub(:get_user_permissions) { {:events => [:read, :write]} }
180
180
  end
@@ -210,7 +210,7 @@ describe "Event" do
210
210
  end
211
211
 
212
212
  it 'Handles cost of "-1" for TBC' do
213
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvent&sectionid=1&eventid=2", :body => @event_body.merge({'cost' => '-1'}).to_json)
213
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvent&sectionid=1&eventid=2", :body => @event_body.merge({'cost' => '-1'}).to_json, :content_type => 'application/json')
214
214
 
215
215
  events = Osm::Event.get_for_section(@api, 1)
216
216
  event = events[0]
@@ -257,9 +257,9 @@ describe "Event" do
257
257
  }]
258
258
  }
259
259
 
260
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvents&sectionid=1&showArchived=true", :body => body.to_json)
261
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvent&sectionid=1&eventid=1", :body => {'config' => '[]', 'archived' => '0', 'eventid' => '1'}.to_json)
262
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvent&sectionid=1&eventid=2", :body => {'config' => '[]', 'archived' => '1', 'eventid' => '2'}.to_json)
260
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvents&sectionid=1&showArchived=true", :body => body.to_json, :content_type => 'application/json')
261
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvent&sectionid=1&eventid=1", :body => {'config' => '[]', 'archived' => '0', 'eventid' => '1'}.to_json, :content_type => 'application/json')
262
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvent&sectionid=1&eventid=2", :body => {'config' => '[]', 'archived' => '1', 'eventid' => '2'}.to_json, :content_type => 'application/json')
263
263
 
264
264
  events = Osm::Event.get_for_section(@api, 1)
265
265
  OsmTest::Cache.clear
@@ -300,7 +300,7 @@ describe "Event" do
300
300
  'f_1' => 'a',
301
301
  },
302
302
  ]
303
- }.to_json)
303
+ }.to_json, :content_type => 'application/json')
304
304
  Osm::Term.stub(:get_current_term_for_section) { Osm::Term.new(:id => 3) }
305
305
 
306
306
  event = Osm::Event.new(:attendance_limit => 2, :id => 1, :section_id => 2)
@@ -339,7 +339,7 @@ describe "Event" do
339
339
  'f_1' => 'a',
340
340
  }
341
341
  ]
342
- }.to_json)
342
+ }.to_json, :content_type => 'application/json')
343
343
  Osm::Term.stub(:get_current_term_for_section) { Osm::Term.new(:id => 3) }
344
344
 
345
345
  event = Osm::Event.new(:attendance_limit => 2, :id => 1, :section_id => 2)
@@ -370,7 +370,7 @@ describe "Event" do
370
370
  'f_1' => 'a',
371
371
  }
372
372
  ]
373
- }.to_json)
373
+ }.to_json, :content_type => 'application/json')
374
374
  Osm::Term.stub(:get_current_term_for_section) { Osm::Term.new(:id => 3) }
375
375
 
376
376
  event = Osm::Event.new(:attendance_limit => 2, :id => 1, :section_id => 2)
@@ -690,7 +690,7 @@ describe "Event" do
690
690
  ]
691
691
  }
692
692
 
693
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEventAttendance&eventid=2&sectionid=1&termid=3", :body => attendance_body.to_json)
693
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEventAttendance&eventid=2&sectionid=1&termid=3", :body => attendance_body.to_json, :content_type => 'application/json')
694
694
 
695
695
  event = Osm::Event.new(:id => 2, :section_id => 1)
696
696
  attendance = event.get_attendance(@api, 3)
@@ -717,7 +717,7 @@ describe "Event" do
717
717
  'eventid' => '2',
718
718
  }
719
719
 
720
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEventAttendance&eventid=2&sectionid=1&termid=3", :body => attendance_body.to_json)
720
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEventAttendance&eventid=2&sectionid=1&termid=3", :body => attendance_body.to_json, :content_type => 'application/json')
721
721
 
722
722
  event = Osm::Event.new(:id => 2, :section_id => 1)
723
723
  attendance = event.get_attendance(@api, 3)
@@ -931,7 +931,7 @@ describe "Event" do
931
931
 
932
932
  it "handles a non existant array when no events" do
933
933
  data = '{"identifier":"eventid","label":"name"}'
934
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvents&sectionid=1&showArchived=true", :body => data)
934
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvents&sectionid=1&showArchived=true", :body => data, :content_type => 'application/json')
935
935
  events = Osm::Event.get_for_section(@api, 1).should == []
936
936
  end
937
937
 
@@ -962,8 +962,8 @@ describe "Event" do
962
962
  'limitincludesleaders' => '1',
963
963
  }
964
964
 
965
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvents&sectionid=1&showArchived=true", :body => events_body)
966
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvent&sectionid=1&eventid=2", :body => event_body.to_json)
965
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvents&sectionid=1&showArchived=true", :body => events_body, :content_type => 'application/json')
966
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvent&sectionid=1&eventid=2", :body => event_body.to_json, :content_type => 'application/json')
967
967
 
968
968
  Osm::Model.stub(:get_user_permissions) { {:events => [:read, :write]} }
969
969
 
@@ -132,7 +132,7 @@ describe "Flexi Record" do
132
132
  ]}
133
133
  ]
134
134
  }
135
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/extras.php?action=getExtra&sectionid=1&extraid=2", :body => data.to_json)
135
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/extras.php?action=getExtra&sectionid=1&extraid=2", :body => data.to_json, :content_type => 'application/json')
136
136
 
137
137
  fields = @flexi_record.get_columns(@api)
138
138
  fields.is_a?(Array).should be_true
@@ -388,7 +388,7 @@ describe "Flexi Record" do
388
388
  "patrol" => "Green"
389
389
  }]
390
390
  }
391
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/extras.php?action=getExtraRecords&sectionid=1&extraid=2&termid=3&section=cubs", :body => data.to_json)
391
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/extras.php?action=getExtraRecords&sectionid=1&extraid=2&termid=3&section=cubs", :body => data.to_json, :content_type => 'application/json')
392
392
  Osm::Section.stub(:get) { Osm::Section.new(:id => 1, :type => :cubs) }
393
393
 
394
394
  records = @flexi_record.get_data(@api, 3)
@@ -516,7 +516,7 @@ describe "Flexi Record" do
516
516
  "patrol" => "Green"
517
517
  }]
518
518
  }
519
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/extras.php?action=getExtraRecords&sectionid=1&extraid=2&termid=3&section=cubs", :body => data.to_json)
519
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/extras.php?action=getExtraRecords&sectionid=1&extraid=2&termid=3&section=cubs", :body => data.to_json, :content_type => 'application/json')
520
520
  Osm::Section.stub(:get) { Osm::Section.new(:id => 1, :type => :cubs) }
521
521
 
522
522
  records = @flexi_record.get_data(@api, 3)
@@ -80,7 +80,7 @@ describe "Gift Aid" do
80
80
  {"name" => "2000-01-02", "field" => "2000-01-02", "width" => "110px", "editable" => true, "formatter" => "boldFormatter"}
81
81
  ]}
82
82
  ]
83
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/giftaid.php?action=getStructure&sectionid=1&termid=2", :body => data.to_json)
83
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/giftaid.php?action=getStructure&sectionid=1&termid=2", :body => data.to_json, :content_type => 'application/json')
84
84
 
85
85
  donations = Osm::GiftAid.get_donations(@api, 1, 2)
86
86
  donations.should == [Osm::GiftAid::Donation.new(:donation_date => Date.new(2000, 1, 2))]
@@ -96,7 +96,7 @@ describe "Gift Aid" do
96
96
  ]
97
97
  }
98
98
 
99
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/giftaid.php?action=getGrid&sectionid=1&termid=2", :body => data.to_json)
99
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/giftaid.php?action=getGrid&sectionid=1&termid=2", :body => data.to_json, :content_type => 'application/json')
100
100
 
101
101
  data = Osm::GiftAid.get_data(@api, 1, 2)
102
102
  data.is_a?(Array).should be_true
@@ -21,7 +21,7 @@ describe "Grouping" do
21
21
  'active' => 1,
22
22
  'points' => '3',
23
23
  }]}
24
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=getPatrols&sectionid=2", :body => body.to_json)
24
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=getPatrols&sectionid=2", :body => body.to_json, :content_type => 'application/json')
25
25
 
26
26
  patrols = Osm::Grouping.get_for_section(@api, 2)
27
27
  patrols.size.should == 1
@@ -35,7 +35,7 @@ describe "Grouping" do
35
35
  end
36
36
 
37
37
  it "Handles no data" do
38
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=getPatrols&sectionid=2", :body => '')
38
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=getPatrols&sectionid=2", :body => '', :content_type => 'application/json')
39
39
  patrols = Osm::Grouping.get_for_section(@api, 2)
40
40
  patrols.size.should == 0
41
41
  end
@@ -487,7 +487,7 @@ describe "Invoice" do
487
487
  data = {"identifier" => "id","items" => [
488
488
  {"id" => "1","invoiceid" => "2","recordid" => "3","sectionid" => "4","entrydate" => "2012-01-02","amount" => "1.23","type" => "Expense","payto_userid" => "John Smith","comments" => "Comment","categoryid" => "Default","firstname" => "John Smith"}
489
489
  ]}
490
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/finances.php?action=getInvoiceRecords&invoiceid=2&sectionid=4&dateFormat=generic", :body => data.to_json)
490
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/finances.php?action=getInvoiceRecords&invoiceid=2&sectionid=4&dateFormat=generic", :body => data.to_json, :content_type => 'application/json')
491
491
 
492
492
  invoice = Osm::Invoice.new(:id => 2, :section_id => 4)
493
493
  items = invoice.get_items(@api)
@@ -125,7 +125,7 @@ describe "Meeting" do
125
125
  "sectionid" => "3",
126
126
  }]},
127
127
  }
128
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/programme.php?action=getProgramme&sectionid=3&termid=4", :body => body.to_json)
128
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/programme.php?action=getProgramme&sectionid=3&termid=4", :body => body.to_json, :content_type => 'application/json')
129
129
 
130
130
  programme = Osm::Meeting.get_for_section(@api, 3, 4)
131
131
  programme.size.should == 1
@@ -158,11 +158,11 @@ describe "Meeting" do
158
158
 
159
159
  it "Fetch badge requirements for a meeting" do
160
160
  badges_body = [{'a'=>'a'},{'a'=>'A'}]
161
- FakeWeb.register_uri(:post, 'https://www.onlinescoutmanager.co.uk/users.php?action=getActivityRequirements&date=2000-01-02&sectionid=3&section=cubs', :body => badges_body.to_json)
161
+ FakeWeb.register_uri(:post, 'https://www.onlinescoutmanager.co.uk/users.php?action=getActivityRequirements&date=2000-01-02&sectionid=3&section=cubs', :body => badges_body.to_json, :content_type => 'application/json')
162
162
  roles_body = [
163
163
  {"sectionConfig"=>"{\"subscription_level\":1,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"cubs\",\"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"=>"3", "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}},
164
164
  ]
165
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => roles_body.to_json)
165
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => roles_body.to_json, :content_type => 'application/json')
166
166
 
167
167
  meeting = Osm::Meeting.new(:date => Date.new(2000, 1, 2), :section_id => 3)
168
168
  meeting.get_badge_requirements(@api).should == badges_body
@@ -133,7 +133,7 @@ describe "Member" do
133
133
  body = [
134
134
  {"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}},
135
135
  ]
136
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json)
136
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json, :content_type => 'application/json')
137
137
 
138
138
  body = {
139
139
  'identifier' => 'scoutid',
@@ -182,8 +182,11 @@ describe "Member" do
182
182
  'patrolleaderO' => 0,
183
183
  }]
184
184
  }
185
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=getUserDetails&sectionid=1&termid=2", :body => body.to_json, :content_type => 'application/json')
186
+
187
+ body = {'items' => [{'scoutid'=>'1', 'pic'=>true}]}
188
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ext/members/contact/?action=getListOfMembers&sort=patrolid&sectionid=1&termid=2&section=beavers", :body => body.to_json, :content_type => 'application/json')
185
189
 
186
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=getUserDetails&sectionid=1&termid=2", :body => body.to_json)
187
190
  members = Osm::Member.get_for_section(@api, 1, 2)
188
191
  members.size.should == 1
189
192
  members[0].id.should == 1
@@ -193,14 +196,17 @@ describe "Member" do
193
196
  body = [
194
197
  {"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}},
195
198
  ]
196
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json)
199
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json, :content_type => 'application/json')
197
200
 
198
201
  body = {
199
202
  'identifier' => 'scoutid',
200
203
  'items' => []
201
204
  }
205
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=getUserDetails&sectionid=1&termid=-1", :body => body.to_json, :content_type => 'application/json')
206
+
207
+ body = {'items' => [{'scoutid'=>'1', 'pic'=>true}]}
208
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ext/members/contact/?action=getListOfMembers&sort=patrolid&sectionid=1&termid=-1&section=waiting", :body => body.to_json, :content_type => 'application/json')
202
209
 
203
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=getUserDetails&sectionid=1&termid=-1", :body => body.to_json)
204
210
  members = Osm::Member.get_for_section(@api, 1, 2)
205
211
  members.size.should == 0
206
212
  end
@@ -481,6 +487,41 @@ describe "Member" do
481
487
  member.update(@api).should be_false
482
488
  end
483
489
 
490
+ it "Get Photo link" do
491
+ member = Osm::Member.new(
492
+ :id => 1,
493
+ :section_id => 2,
494
+ :first_name => 'First',
495
+ :last_name => 'Last',
496
+ :date_of_birth => '2000-01-02',
497
+ :started => '2006-01-02',
498
+ :joined => '2006-01-03',
499
+ :grouping_id => '3',
500
+ :grouping_leader => 0,
501
+ :has_photo => true,
502
+ )
503
+ HTTParty.stub(:post) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :content_type=>'image/jpeg', :body=>'abcdef'}) }
504
+
505
+ member.get_photo(@api).should == "abcdef"
506
+ end
507
+
508
+ it "Get Photo link when no photo uploaded" do
509
+ member = Osm::Member.new(
510
+ :id => 1,
511
+ :section_id => 2,
512
+ :first_name => 'First',
513
+ :last_name => 'Last',
514
+ :date_of_birth => '2000-01-02',
515
+ :started => '2006-01-02',
516
+ :joined => '2006-01-03',
517
+ :grouping_id => '3',
518
+ :grouping_leader => 0,
519
+ :has_photo => false,
520
+ )
521
+
522
+ expect{ member.get_photo(@api) }.to raise_error(Osm::Error, "the member doesn't have a photo in OSM")
523
+ end
524
+
484
525
  describe "Get My.SCOUT link" do
485
526
 
486
527
  before :each do
@@ -87,7 +87,7 @@ describe "Register" do
87
87
  {"rows" => [{"name"=>"First name","field"=>"firstname","width"=>"100px"},{"name"=>"Last name","field"=>"lastname","width"=>"100px"},{"name"=>"Total","field"=>"total","width"=>"60px"}],"noscroll"=>true},
88
88
  {"rows" => []}
89
89
  ]
90
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=registerStructure&sectionid=1&termid=2", :body => data.to_json)
90
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=registerStructure&sectionid=1&termid=2", :body => data.to_json, :content_type => 'application/json')
91
91
 
92
92
  register_structure = Osm::Register.get_structure(@api, 1, 2)
93
93
  register_structure.is_a?(Array).should be_true
@@ -109,7 +109,7 @@ describe "Register" do
109
109
  }
110
110
  ]
111
111
  }
112
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=register&sectionid=1&termid=2", :body => data.to_json)
112
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=register&sectionid=1&termid=2", :body => data.to_json, :content_type => 'application/json')
113
113
  Osm::Register.stub(:get_structure) { [
114
114
  Osm::Register::Field.new(:id => '2000-01-01', :name => 'Name', :tooltip => 'Tooltip'),
115
115
  Osm::Register::Field.new(:id => '2000-01-02', :name => 'Name', :tooltip => 'Tooltip'),
@@ -182,7 +182,7 @@ describe "Register" do
182
182
  }
183
183
  ]
184
184
  }
185
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=register&sectionid=1&termid=2", :body => data.to_json)
185
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=register&sectionid=1&termid=2", :body => data.to_json, :content_type => 'application/json')
186
186
  Osm::Register.stub(:get_structure) { [] }
187
187
 
188
188
  register = Osm::Register.get_attendance(@api, 1, 2)
@@ -194,13 +194,13 @@ describe "Register" do
194
194
  end
195
195
 
196
196
  it "Handles no data getting structure" do
197
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=registerStructure&sectionid=1&termid=2", :body => '')
197
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=registerStructure&sectionid=1&termid=2", :body => '', :content_type => 'application/json')
198
198
  register_structure = Osm::Register.get_structure(@api, 1, 2)
199
199
  register_structure.is_a?(Array).should be_true
200
200
  register_structure.size.should == 0
201
201
 
202
202
 
203
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=register&sectionid=1&termid=2", :body => '')
203
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=register&sectionid=1&termid=2", :body => '', :content_type => 'application/json')
204
204
  register = Osm::Register.get_attendance(@api, 1, 2)
205
205
  register.is_a?(Array).should be_true
206
206
  register.size.should == 0
@@ -121,7 +121,7 @@ describe "Section" do
121
121
  {"sectionConfig"=>"{\"subscription_level\":1,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"beavers\",\"columnNames\":{\"column_names\":\"names\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[{\"name\":\"Flexi Record 1\",\"extraid\":\"111\"}],\"wizard\":\"false\",\"fields\":{\"fields\":true},\"intouch\":{\"intouch_fields\":true},\"mobFields\":{\"mobile_fields\":true},\"gocardless\":\"true\",\"portal\":{\"paymentRemindFrequency\":\"7\",\"paymentRemindCount\":\"6\",\"eventRemindFrequency\":\"5\",\"eventRemindCount\":\"4\",\"badgesPartial\":1,\"programmeTimes\":1,\"programmeShow\":\"10\",\"programmeSummary\":1,\"details\":1,\"contactNotificationEmail\":\"notify-changes-to@example.com\",\"emailAddress\":\"send_from@example.com\",\"emailAddressCopy\":null,\"payments\":1,\"badges\":1,\"emails\":{\"email1\":\"true\",\"email2\":\"false\"},\"events\":1,\"programme\":1},\"portalExpires\":{\"events\":\"2013-01-06\",\"eventsA\":1,\"badges\":\"2013-01-07\",\"badgesA\":1,\"programme\":\"2013-01-08\",\"programmeA\":1,\"details\":\"2013-01-09\",\"detailsA\":1},\"hasSentTestSMS\":true,\"sms_remaining\":8,\"sms_sent\":9}", "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}},
122
122
  {"sectionConfig"=>"{\"subscription_level\":3,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"cubs\",\"columnNames\":{\"phone1\":\"Home Phone\",\"phone2\":\"Parent 1 Phone\",\"address\":\"Member's Address\",\"phone3\":\"Parent 2 Phone\",\"address2\":\"Address 2\",\"phone4\":\"Alternate Contact Phone\",\"subs\":\"Gender\",\"email1\":\"Parent 1 Email\",\"medical\":\"Medical / Dietary\",\"email2\":\"Parent 2 Email\",\"ethnicity\":\"Gift Aid\",\"email3\":\"Member's Email\",\"religion\":\"Religion\",\"email4\":\"Email 4\",\"school\":\"School\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[],\"wizard\":\"false\",\"fields\":{\"email1\":true,\"email2\":true,\"email3\":true,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":true,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":true,\"saved\":true},\"intouch\":{\"address\":true,\"address2\":false,\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"medical\":false},\"mobFields\":{\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":false,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":false},\"hasSentTestSMS\":true,\"sms_remaining\":8,\"sms_sent\":9}", "groupname"=>"1st Somewhere", "groupid"=>"1", "groupNormalised"=>"1", "sectionid"=>"2", "sectionname"=>"Section 2", "section"=>"cubs", "isDefault"=>"0", "permissions"=>{"badge"=>100, "member"=>100, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}}
123
123
  ]
124
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json)
124
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json, :content_type => 'application/json')
125
125
  end
126
126
 
127
127
  describe "Gets all sections" do
@@ -303,7 +303,7 @@ describe "Online Scout Manager API Strangeness" do
303
303
 
304
304
  it "handles a section with no type" do
305
305
  body = '[{"sectionConfig":"{\"subscription_level\":3,\"subscription_expires\":\"2013-01-05\",\"columnNames\":{\"phone1\":\"Home Phone\",\"phone2\":\"Parent 1 Phone\",\"address\":\"Member\'s Address\",\"phone3\":\"Parent 2 Phone\",\"address2\":\"Address 2\",\"phone4\":\"Alternate Contact Phone\",\"subs\":\"Gender\",\"email1\":\"Parent 1 Email\",\"medical\":\"Medical / Dietary\",\"email2\":\"Parent 2 Email\",\"ethnicity\":\"Gift Aid\",\"email3\":\"Member\'s Email\",\"religion\":\"Religion\",\"email4\":\"Email 4\",\"school\":\"School\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[{\"name\":\"Subs\",\"extraid\":\"529\"}],\"wizard\":\"false\",\"fields\":{\"email1\":true,\"email2\":true,\"email3\":true,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":true,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":true,\"saved\":true},\"intouch\":{\"address\":true,\"address2\":false,\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"medical\":false},\"mobFields\":{\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":false,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":false}}","groupname":"1st Somewhere","groupid":"1","groupNormalised":"1","sectionid":"1","sectionname":"Section 1","section":"cubs","isDefault":"1","permissions":{"badge":100,"member":100,"user":100,"register":100,"contact":100,"programme":100,"originator":1,"events":100,"finance":100,"flexi":100}}]'
306
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body)
306
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body, :content_type => 'application/json')
307
307
 
308
308
  sections = Osm::Section.get_all(@api)
309
309
  sections.size.should == 1
@@ -314,7 +314,7 @@ describe "Online Scout Manager API Strangeness" do
314
314
 
315
315
  it "handles strange extra records when getting roles" do
316
316
  body = '[{"sectionConfig":"{\"subscription_level\":3,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"cubs\",\"columnNames\":{\"phone1\":\"Home Phone\",\"phone2\":\"Parent 1 Phone\",\"address\":\"Member\'s Address\",\"phone3\":\"Parent 2 Phone\",\"address2\":\"Address 2\",\"phone4\":\"Alternate Contact Phone\",\"subs\":\"Gender\",\"email1\":\"Parent 1 Email\",\"medical\":\"Medical / Dietary\",\"email2\":\"Parent 2 Email\",\"ethnicity\":\"Gift Aid\",\"email3\":\"Member\'s Email\",\"religion\":\"Religion\",\"email4\":\"Email 4\",\"school\":\"School\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[[\"1\",{\"name\":\"Subs\",\"extraid\":\"529\"}],[\"2\",{\"name\":\"Subs 2\",\"extraid\":\"530\"}]],\"wizard\":\"false\",\"fields\":{\"email1\":true,\"email2\":true,\"email3\":true,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":true,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":true,\"saved\":true},\"intouch\":{\"address\":true,\"address2\":false,\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"medical\":false},\"mobFields\":{\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":false,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":false}}","groupname":"1st Somewhere","groupid":"1","groupNormalised":"1","sectionid":"1","sectionname":"Section 1","section":"cubs","isDefault":"1","permissions":{"badge":100,"member":100,"user":100,"register":100,"contact":100,"programme":100,"originator":1,"events":100,"finance":100,"flexi":100}}]'
317
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body)
317
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body, :content_type => 'application/json')
318
318
 
319
319
  sections = Osm::Section.get_all(@api)
320
320
  sections.size.should == 1
@@ -323,7 +323,7 @@ describe "Online Scout Manager API Strangeness" do
323
323
 
324
324
  it "handles a section config where fields is an empty array" do
325
325
  body = '[{"sectionConfig":"{\"subscription_level\":3,\"subscription_expires\":\"2013-01-05\",\"columnNames\":{\"phone1\":\"Home Phone\",\"phone2\":\"Parent 1 Phone\",\"address\":\"Member\'s Address\",\"phone3\":\"Parent 2 Phone\",\"address2\":\"Address 2\",\"phone4\":\"Alternate Contact Phone\",\"subs\":\"Gender\",\"email1\":\"Parent 1 Email\",\"medical\":\"Medical / Dietary\",\"email2\":\"Parent 2 Email\",\"ethnicity\":\"Gift Aid\",\"email3\":\"Member\'s Email\",\"religion\":\"Religion\",\"email4\":\"Email 4\",\"school\":\"School\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[{\"name\":\"Subs\",\"extraid\":\"529\"}],\"wizard\":\"false\",\"fields\":[],\"intouch\":{\"address\":true,\"address2\":false,\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"medical\":false},\"mobFields\":{\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":false,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":false}}","groupname":"1st Somewhere","groupid":"1","groupNormalised":"1","sectionid":"1","sectionname":"Section 1","section":"cubs","isDefault":"1","permissions":{"badge":100,"member":100,"user":100,"register":100,"contact":100,"programme":100,"originator":1,"events":100,"finance":100,"flexi":100}}]'
326
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body)
326
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body, :content_type => 'application/json')
327
327
 
328
328
  sections = Osm::Section.get_all(@api)
329
329
  sections.size.should == 1
@@ -336,7 +336,7 @@ describe "Online Scout Manager API Strangeness" do
336
336
  body = [
337
337
  {"sectionConfig"=>"{\"subscription_level\":1,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"beavers\",\"columnNames\":{\"phone1\":\"Home Phone\",\"phone2\":\"Parent 1 Phone\",\"address\":\"Member's Address\",\"phone3\":\"Parent 2 Phone\",\"address2\":\"Address 2\",\"phone4\":\"Alternate Contact Phone\",\"subs\":\"Gender\",\"email1\":\"Parent 1 Email\",\"medical\":\"Medical / Dietary\",\"email2\":\"Parent 2 Email\",\"ethnicity\":\"Gift Aid\",\"email3\":\"Member's Email\",\"religion\":\"Religion\",\"email4\":\"Email 4\",\"school\":\"School\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":{\"1\":{\"name\":\"Flexi Record 1\",\"extraid\":\"1\"},\"2\":{\"name\":\"Flexi Record 2\",\"extraid\":\"2\"}},\"wizard\":\"false\",\"fields\":{\"email1\":true,\"email2\":true,\"email3\":true,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":true,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":true,\"saved\":true},\"intouch\":{\"address\":true,\"address2\":false,\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"medical\":false},\"mobFields\":{\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":false,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":false}}", "groupname"=>"3rd Somewhere", "groupid"=>"3", "groupNormalised"=>"1", "sectionid"=>"1", "sectionname"=>"Section 1", "section"=>"beavers", "isDefault"=>"1", "permissions"=>{"badge"=>100, "member"=>100, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}},
338
338
  ]
339
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json)
339
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json, :content_type => 'application/json')
340
340
 
341
341
  sections = Osm::Section.get_all(@api)
342
342
  sections.size.should == 1
@@ -350,8 +350,8 @@ describe "Online Scout Manager API Strangeness" do
350
350
 
351
351
  it "handles an empty array representing no notepads" do
352
352
  body = [{"sectionConfig"=>"{\"subscription_level\":1,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"beavers\",\"columnNames\":{\"column_names\":\"names\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[{\"name\":\"Flexi Record 1\",\"extraid\":\"111\"}],\"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}}]
353
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json)
354
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getNotepads", :body => '[]')
353
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json, :content_type => 'application/json')
354
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getNotepads", :body => '[]', :content_type => 'application/json')
355
355
 
356
356
  section = Osm::Section.get(@api, 1)
357
357
  section.should_not be_nil
@@ -363,7 +363,7 @@ describe "Online Scout Manager API Strangeness" do
363
363
  {"sectionConfig"=>"{\"subscription_level\":1,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"beavers\",\"columnNames\":{\"phone1\":\"Home Phone\",\"phone2\":\"Parent 1 Phone\",\"address\":\"Member's Address\",\"phone3\":\"Parent 2 Phone\",\"address2\":\"Address 2\",\"phone4\":\"Alternate Contact Phone\",\"subs\":\"Gender\",\"email1\":\"Parent 1 Email\",\"medical\":\"Medical / Dietary\",\"email2\":\"Parent 2 Email\",\"ethnicity\":\"Gift Aid\",\"email3\":\"Member's Email\",\"religion\":\"Religion\",\"email4\":\"Email 4\",\"school\":\"School\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[],\"wizard\":\"false\",\"fields\":{\"email1\":true,\"email2\":true,\"email3\":true,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":true,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":true,\"saved\":true},\"intouch\":{\"address\":true,\"address2\":false,\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"medical\":false},\"mobFields\":{\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":false,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":false}}", "groupname"=>"3rd Somewhere", "groupid"=>"3", "groupNormalised"=>"1", "sectionid"=>"1", "sectionname"=>"Section 1", "section"=>"beavers", "isDefault"=>"1", "permissions"=>{"badge"=>100, "member"=>100, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}},
364
364
  {"sectionConfig"=>"{\"code\":1,\"districts\":[\"Loddon\",\"Kennet\"]}","groupname"=>"Berkshire","groupid"=>"2","groupNormalised"=>"1","sectionid"=>"3","sectionname"=>"County Admin","section"=>"discount","isDefault"=>"0","permissions"=>{"districts"=>["Loddon"]}}
365
365
  ]
366
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json)
366
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json, :content_type => 'application/json')
367
367
 
368
368
  sections = Osm::Section.get_all(@api)
369
369
  sections.size.should == 1
@@ -377,7 +377,7 @@ describe "Online Scout Manager API Strangeness" do
377
377
  {"sectionConfig"=>"{\"subscription_level\":1,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"beavers\",\"columnNames\":{\"column_names\":\"names\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[{\"name\":\"Flexi Record 1\",\"extraid\":\"111\"}],\"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}},
378
378
  {"sectionConfig"=>{"subscription_level"=>3,"subscription_expires"=>"2013-01-05","sectionType"=>"cubs","columnNames"=>{"phone1"=>"Home Phone","phone2"=>"Parent 1 Phone","address"=>"Member's Address","phone3"=>"Parent 2 Phone","address2"=>"Address 2","phone4"=>"Alternate Contact Phone","subs"=>"Gender","email1"=>"Parent 1 Email","medical"=>"Medical / Dietary","email2"=>"Parent 2 Email","ethnicity"=>"Gift Aid","email3"=>"Member's Email","religion"=>"Religion","email4"=>"Email 4","school"=>"School"},"numscouts"=>10,"hasUsedBadgeRecords"=>true,"hasProgramme"=>true,"extraRecords"=>[],"wizard"=>"false","fields"=>{"email1"=>true,"email2"=>true,"email3"=>true,"email4"=>false,"address"=>true,"address2"=>false,"phone1"=>true,"phone2"=>true,"phone3"=>true,"phone4"=>true,"school"=>false,"religion"=>true,"ethnicity"=>true,"medical"=>true,"patrol"=>true,"subs"=>true,"saved"=>true},"intouch"=>{"address"=>true,"address2"=>false,"email1"=>false,"email2"=>false,"email3"=>false,"email4"=>false,"phone1"=>true,"phone2"=>true,"phone3"=>true,"phone4"=>true,"medical"=>false},"mobFields"=>{"email1"=>false,"email2"=>false,"email3"=>false,"email4"=>false,"address"=>true,"address2"=>false,"phone1"=>true,"phone2"=>true,"phone3"=>true,"phone4"=>true,"school"=>false,"religion"=>false,"ethnicity"=>true,"medical"=>true,"patrol"=>true,"subs"=>false}}, "groupname"=>"1st Somewhere", "groupid"=>"1", "groupNormalised"=>"1", "sectionid"=>"2", "sectionname"=>"Section 2", "section"=>"cubs", "isDefault"=>"0", "permissions"=>{"badge"=>100, "member"=>100, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}}
379
379
  ]
380
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json)
380
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json, :content_type => 'application/json')
381
381
 
382
382
  sections = Osm::Section.get_all(@api)
383
383
  sections.size.should == 2
@@ -191,7 +191,7 @@ describe "SMS" do
191
191
  "to" => "To Name 441234567890"
192
192
  }]
193
193
  }
194
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/sms.php?action=deliveryReports&sectionid=1&dateFormat=generic", :body => data.to_json)
194
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/sms.php?action=deliveryReports&sectionid=1&dateFormat=generic", :body => data.to_json, :content_type => 'application/json')
195
195
 
196
196
  reports = Osm::Sms::DeliveryReport.get_for_section(@api, 1)
197
197
  reports.size.should == 1
@@ -126,7 +126,7 @@ describe "Term" do
126
126
  {"sectionConfig"=>"{\"subscription_level\":1,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"beavers\",\"columnNames\":{\"column_names\":\"names\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[{\"name\":\"Flexi Record 1\",\"extraid\":\"111\"}],\"wizard\":\"false\",\"fields\":{\"fields\":true},\"intouch\":{\"intouch_fields\":true},\"mobFields\":{\"mobile_fields\":true}}", "groupname"=>"3rd Somewhere", "groupid"=>"3", "groupNormalised"=>"1", "sectionid"=>"9", "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}},
127
127
  {"sectionConfig"=>"{\"subscription_level\":3,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"cubs\",\"columnNames\":{\"phone1\":\"Home Phone\",\"phone2\":\"Parent 1 Phone\",\"address\":\"Member's Address\",\"phone3\":\"Parent 2 Phone\",\"address2\":\"Address 2\",\"phone4\":\"Alternate Contact Phone\",\"subs\":\"Gender\",\"email1\":\"Parent 1 Email\",\"medical\":\"Medical / Dietary\",\"email2\":\"Parent 2 Email\",\"ethnicity\":\"Gift Aid\",\"email3\":\"Member's Email\",\"religion\":\"Religion\",\"email4\":\"Email 4\",\"school\":\"School\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[],\"wizard\":\"false\",\"fields\":{\"email1\":true,\"email2\":true,\"email3\":true,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":true,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":true,\"saved\":true},\"intouch\":{\"address\":true,\"address2\":false,\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"medical\":false},\"mobFields\":{\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":false,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":false}}", "groupname"=>"1st Somewhere", "groupid"=>"1", "groupNormalised"=>"1", "sectionid"=>"10", "sectionname"=>"Section 2", "section"=>"cubs", "isDefault"=>"0", "permissions"=>{"badge"=>100, "member"=>100, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}}
128
128
  ]
129
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json)
129
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json, :content_type => 'application/json')
130
130
 
131
131
  body = {
132
132
  "9" => [
@@ -137,7 +137,7 @@ describe "Term" do
137
137
  {"termid" => "3", "name" => "Term 3", "sectionid" => "10", "startdate" => (Date.today + 91).strftime('%Y-%m-%d'), "enddate" => (Date.today + 180).strftime('%Y-%m-%d')}
138
138
  ]
139
139
  }
140
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getTerms", :body => body.to_json)
140
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getTerms", :body => body.to_json, :content_type => 'application/json')
141
141
  end
142
142
 
143
143
 
@@ -180,7 +180,7 @@ describe "Term" do
180
180
  body += '{"termid":"2","name":"Term 2","sectionid":"9","startdate":"' + (Date.today - 30).strftime('%Y-%m-%d') + '","enddate":"' + (Date.today + 30).strftime('%Y-%m-%d') + '"},'
181
181
  body += '{"termid":"3","name":"Term 3","sectionid":"9","startdate":"' + (Date.today + 31).strftime('%Y-%m-%d') + '","enddate":"' + (Date.today + 90).strftime('%Y-%m-%d') + '"}'
182
182
  body += ']}'
183
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getTerms", :body => body)
183
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getTerms", :body => body, :content_type => 'application/json')
184
184
 
185
185
  Osm::Term.get_current_term_for_section(@api, 9).id.should == 2
186
186
  end
@@ -189,7 +189,7 @@ describe "Term" do
189
189
  body = '{"9":['
190
190
  body += '{"termid":"1","name":"Term 1","sectionid":"9","startdate":"' + (Date.today + 31).strftime('%Y-%m-%d') + '","enddate":"' + (Date.today + 90).strftime('%Y-%m-%d') + '"}'
191
191
  body += ']}'
192
- FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getTerms", :body => body)
192
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getTerms", :body => body, :content_type => 'application/json')
193
193
 
194
194
  expect{ Osm::Term.get_current_term_for_section(@api, 9) }.to raise_error do |error|
195
195
  error.should be_a(Osm::Error::NoCurrentTerm)