osm 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -191,6 +191,218 @@ describe "Member" do
191
191
  members.size.should == 0
192
192
  end
193
193
 
194
+ it "Create in OSM (succeded)" do
195
+ member = Osm::Member.new(
196
+ :section_id => 2,
197
+ :first_name => 'First',
198
+ :last_name => 'Last',
199
+ :email1 => 'email1@example.com',
200
+ :email2 => 'email2@example.com',
201
+ :email3 => 'email3@example.com',
202
+ :email4 => 'email4@example.com',
203
+ :phone1 => '11111 111111',
204
+ :phone2 => '222222',
205
+ :phone3 => '+33 3333 333333',
206
+ :phone4 => '4444 444 444',
207
+ :address => '1 Some Road',
208
+ :address2 => 'Address 2',
209
+ :date_of_birth => '2000-01-02',
210
+ :started => '2006-01-02',
211
+ :joined => '2006-01-03',
212
+ :parents => 'John and Jane Doe',
213
+ :notes => 'None',
214
+ :medical => 'Nothing',
215
+ :religion => 'Unknown',
216
+ :school => 'Some School',
217
+ :ethnicity => 'Yes',
218
+ :subs => 'Upto end of 2007',
219
+ :custom1 => 'Custom Field 1',
220
+ :custom2 => 'Custom Field 2',
221
+ :custom3 => 'Custom Field 3',
222
+ :custom4 => 'Custom Field 4',
223
+ :custom5 => 'Custom Field 5',
224
+ :custom6 => 'Custom Field 6',
225
+ :custom7 => 'Custom Field 7',
226
+ :custom8 => 'Custom Field 8',
227
+ :custom9 => 'Custom Field 9',
228
+ :grouping_id => '3',
229
+ :grouping_leader => 0,
230
+ )
231
+
232
+ url = 'https://www.onlinescoutmanager.co.uk/users.php?action=newMember'
233
+ post_data = {
234
+ 'apiid' => @CONFIGURATION[:api][:osm][:id],
235
+ 'token' => @CONFIGURATION[:api][:osm][:token],
236
+ 'userid' => 'user_id',
237
+ 'secret' => 'secret',
238
+ 'sectionid' => 2,
239
+ 'firstname' => 'First',
240
+ 'lastname' => 'Last',
241
+ 'email1' => 'email1@example.com',
242
+ 'email2' => 'email2@example.com',
243
+ 'email3' => 'email3@example.com',
244
+ 'email4' => 'email4@example.com',
245
+ 'phone1' => '11111 111111',
246
+ 'phone2' => '222222',
247
+ 'phone3' => '+33 3333 333333',
248
+ 'phone4' => '4444 444 444',
249
+ 'address' => '1 Some Road',
250
+ 'address2' => 'Address 2',
251
+ 'dob' => '2000-01-02',
252
+ 'started' => '2006-01-02',
253
+ 'startedsection' => '2006-01-03',
254
+ 'parents' => 'John and Jane Doe',
255
+ 'notes' => 'None',
256
+ 'medical' => 'Nothing',
257
+ 'religion' => 'Unknown',
258
+ 'school' => 'Some School',
259
+ 'ethnicity' => 'Yes',
260
+ 'subs' => 'Upto end of 2007',
261
+ 'custom1' => 'Custom Field 1',
262
+ 'custom2' => 'Custom Field 2',
263
+ 'custom3' => 'Custom Field 3',
264
+ 'custom4' => 'Custom Field 4',
265
+ 'custom5' => 'Custom Field 5',
266
+ 'custom6' => 'Custom Field 6',
267
+ 'custom7' => 'Custom Field 7',
268
+ 'custom8' => 'Custom Field 8',
269
+ 'custom9' => 'Custom Field 9',
270
+ 'patrolid' => 3,
271
+ 'patrolleader' => 0,
272
+ }
273
+
274
+ Osm::Term.stub(:get_for_section) { [] }
275
+ HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":"ok","scoutid":1}'}) }
276
+ member.create(@api).should be_true
277
+ member.id.should == 1
278
+ end
279
+
280
+ it "Create in OSM (failed)" do
281
+ member = Osm::Member.new(
282
+ :section_id => 2,
283
+ :first_name => 'First',
284
+ :last_name => 'Last',
285
+ :date_of_birth => '2000-01-02',
286
+ :started => '2006-01-02',
287
+ :joined => '2006-01-03',
288
+ :grouping_id => '3',
289
+ :grouping_leader => 0,
290
+ )
291
+
292
+ HTTParty.should_receive(:post) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":"ok","scoutid":-1}'}) }
293
+ member.create(@api).should be_false
294
+ end
295
+
296
+
297
+ it "Update in OSM (succeded)" do
298
+ member = Osm::Member.new(
299
+ :id => 1,
300
+ :section_id => 2,
301
+ :first_name => 'First',
302
+ :last_name => 'Last',
303
+ :email1 => 'email1@example.com',
304
+ :email2 => 'email2@example.com',
305
+ :email3 => 'email3@example.com',
306
+ :email4 => 'email4@example.com',
307
+ :phone1 => '11111 111111',
308
+ :phone2 => '222222',
309
+ :phone3 => '+33 3333 333333',
310
+ :phone4 => '4444 444 444',
311
+ :address => '1 Some Road',
312
+ :address2 => 'Address 2',
313
+ :date_of_birth => '2000-01-02',
314
+ :started => '2006-01-02',
315
+ :joined => '2006-01-03',
316
+ :parents => 'John and Jane Doe',
317
+ :notes => 'None',
318
+ :medical => 'Nothing',
319
+ :religion => 'Unknown',
320
+ :school => 'Some School',
321
+ :ethnicity => 'Yes',
322
+ :subs => 'Upto end of 2007',
323
+ :custom1 => 'Custom Field 1',
324
+ :custom2 => 'Custom Field 2',
325
+ :custom3 => 'Custom Field 3',
326
+ :custom4 => 'Custom Field 4',
327
+ :custom5 => 'Custom Field 5',
328
+ :custom6 => 'Custom Field 6',
329
+ :custom7 => 'Custom Field 7',
330
+ :custom8 => 'Custom Field 8',
331
+ :custom9 => 'Custom Field 9',
332
+ :grouping_id => 3,
333
+ :grouping_leader => 0,
334
+ )
335
+
336
+ url = 'https://www.onlinescoutmanager.co.uk/users.php?action=updateMember&dateFormat=generic'
337
+ body_data = {
338
+ 'firstname' => 'First',
339
+ 'lastname' => 'Last',
340
+ 'email1' => 'email1@example.com',
341
+ 'email2' => 'email2@example.com',
342
+ 'email3' => 'email3@example.com',
343
+ 'email4' => 'email4@example.com',
344
+ 'phone1' => '11111 111111',
345
+ 'phone2' => '222222',
346
+ 'phone3' => '+33 3333 333333',
347
+ 'phone4' => '4444 444 444',
348
+ 'address' => '1 Some Road',
349
+ 'address2' => 'Address 2',
350
+ 'dob' => '2000-01-02',
351
+ 'started' => '2006-01-02',
352
+ 'startedsection' => '2006-01-03',
353
+ 'parents' => 'John and Jane Doe',
354
+ 'notes' => 'None',
355
+ 'medical' => 'Nothing',
356
+ 'religion' => 'Unknown',
357
+ 'school' => 'Some School',
358
+ 'ethnicity' => 'Yes',
359
+ 'subs' => 'Upto end of 2007',
360
+ 'custom1' => 'Custom Field 1',
361
+ 'custom2' => 'Custom Field 2',
362
+ 'custom3' => 'Custom Field 3',
363
+ 'custom4' => 'Custom Field 4',
364
+ 'custom5' => 'Custom Field 5',
365
+ 'custom6' => 'Custom Field 6',
366
+ 'custom7' => 'Custom Field 7',
367
+ 'custom8' => 'Custom Field 8',
368
+ 'custom9' => 'Custom Field 9',
369
+ 'patrolid' => 3,
370
+ 'patrolleader' => 0,
371
+ }
372
+ body = (body_data.inject({}) {|h,(k,v)| h[k]=v.to_s; h}).to_json
373
+
374
+ body_data.each do |column, value|
375
+ HTTParty.should_receive(:post).with(url, {:body => {
376
+ 'apiid' => @CONFIGURATION[:api][:osm][:id],
377
+ 'token' => @CONFIGURATION[:api][:osm][:token],
378
+ 'userid' => 'user_id',
379
+ 'secret' => 'secret',
380
+ 'scoutid' => member.id,
381
+ 'column' => column,
382
+ 'value' => value,
383
+ 'sectionid' => member.section_id,
384
+ }}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>body}) }
385
+ end
386
+ member.update(@api).should be_true
387
+ end
388
+
389
+ it "Update in OSM (failed)" do
390
+ member = Osm::Member.new(
391
+ :id => 1,
392
+ :section_id => 2,
393
+ :first_name => 'First',
394
+ :last_name => 'Last',
395
+ :date_of_birth => '2000-01-02',
396
+ :started => '2006-01-02',
397
+ :joined => '2006-01-03',
398
+ :grouping_id => '3',
399
+ :grouping_leader => 0,
400
+ )
401
+
402
+ HTTParty.stub(:post) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{}'}) }
403
+ member.update(@api).should be_false
404
+ end
405
+
194
406
  end
195
407
 
196
408
  end
@@ -29,7 +29,7 @@ describe "Section" do
29
29
  :myscout_programme => true,
30
30
  :myscout_payments => true,
31
31
  :myscout_emails => {:email1 => true, :email2 => false},
32
- :myscout_email_address_send => 'send_from@example.com',
32
+ :myscout_email_address_from => 'send_from@example.com',
33
33
  :myscout_email_address_copy => '',
34
34
  :myscout_badges_partial => true,
35
35
  :myscout_programme_summary => true,
@@ -65,7 +65,7 @@ describe "Section" do
65
65
  section.myscout_programme.should == true
66
66
  section.myscout_payments.should == true
67
67
  section.myscout_emails.should == {:email1 => true, :email2 => false}
68
- section.myscout_email_address_send.should == 'send_from@example.com'
68
+ section.myscout_email_address_from.should == 'send_from@example.com'
69
69
  section.myscout_email_address_copy.should == ''
70
70
  section.myscout_badges_partial.should == true
71
71
  section.myscout_programme_summary.should == true
@@ -88,6 +88,8 @@ describe "Section" do
88
88
  section.intouch_fields.should == {}
89
89
  section.mobile_fields.should == {}
90
90
  section.flexi_records.should == []
91
+ section.myscout_email_address_from.should == ''
92
+ section.myscout_email_address_copy.should == ''
91
93
  end
92
94
 
93
95
 
@@ -95,7 +97,7 @@ describe "Section" do
95
97
 
96
98
  before :each do
97
99
  body = [
98
- {"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,\"programmeSummary\":1,\"emailAddress\":\"send_from@example.com\",\"emailAddressCopy\":\"\",\"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}}", "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}},
100
+ {"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,\"programmeSummary\":1,\"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}}", "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}},
99
101
  {"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}}
100
102
  ]
101
103
  FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json)
@@ -129,7 +131,7 @@ describe "Section" do
129
131
  section.myscout_programme.should == true
130
132
  section.myscout_payments.should == true
131
133
  section.myscout_emails.should == {:email1 => true, :email2 => false}
132
- section.myscout_email_address_send.should == 'send_from@example.com'
134
+ section.myscout_email_address_from.should == 'send_from@example.com'
133
135
  section.myscout_email_address_copy.should == ''
134
136
  section.myscout_badges_partial.should == true
135
137
  section.myscout_programme_summary.should == true
data/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Osm
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.12"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-09 00:00:00.000000000Z
12
+ date: 2013-01-12 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &79244120 !ruby/object:Gem::Requirement
16
+ requirement: &84282110 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *79244120
24
+ version_requirements: *84282110
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: httparty
27
- requirement: &79243800 !ruby/object:Gem::Requirement
27
+ requirement: &84281680 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.9'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *79243800
35
+ version_requirements: *84281680
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: active_attr
38
- requirement: &79243500 !ruby/object:Gem::Requirement
38
+ requirement: &84281390 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.6'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *79243500
46
+ version_requirements: *84281390
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: activemodel
49
- requirement: &79243020 !ruby/object:Gem::Requirement
49
+ requirement: &84280860 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '3.2'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *79243020
57
+ version_requirements: *84280860
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &79242470 !ruby/object:Gem::Requirement
60
+ requirement: &84280240 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '10.0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *79242470
68
+ version_requirements: *84280240
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &79242200 !ruby/object:Gem::Requirement
71
+ requirement: &84279560 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '2.11'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *79242200
79
+ version_requirements: *84279560
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: fakeweb
82
- requirement: &79241900 !ruby/object:Gem::Requirement
82
+ requirement: &84279180 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '1.3'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *79241900
90
+ version_requirements: *84279180
91
91
  description: Use the Online Scout Manager API (https://www.onlinescoutmanager.co.uk)
92
92
  to retrieve and save data.
93
93
  email:
@@ -137,7 +137,7 @@ files:
137
137
  - spec/osm/term_spec.rb
138
138
  - spec/spec_helper.rb
139
139
  - version.rb
140
- homepage: ''
140
+ homepage: https://github.com/robertgauld/osm
141
141
  licenses: []
142
142
  post_install_message:
143
143
  rdoc_options: []