osm 1.2.18.dev.8 → 1.2.18.dev.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +2 -2
- data/lib/osm/member.rb +37 -35
- data/spec/osm/member_spec.rb +410 -380
- data/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWZhOTg0ZjAwNzk1YjE3ZmY0YTJlNjI0ZWRjZmFiMWFkMTc5YTk1OQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGQ3M2MyNTk0MWRlNjNkMmYwNWU2OTc4MjBhYjAxMmQ4OGUxZjE1Nw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDkwMjA5NTYyYTRiMTEzMGNiMzNhNzFiM2E2MTEwZmQwNDc1NjE3NDcyYjM2
|
10
|
+
ZTcxNGQwOTE5YjFhMTU5ZmMyMWQxODNmMTExN2MyNDNjMWIwY2ExMjYxNDdh
|
11
|
+
OTM3ZmQ3NWEyOWJlMmUxMGMyM2QzMmE4MmE1M2FhNjc1NDIzYzM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzhjNDRkZWVlNjdlZjljYWU2ODkyNDZjODliODllYzcyZmI4Y2RiYTBhNTQx
|
14
|
+
MGRiZWM5YzMyMWI4NzJmYTJhYzc1YzgzNTMxZWMwZmIxM2MzNTcwNGNiNGFk
|
15
|
+
MDc2OWMzMDFiNTIxNmUwYjE3YTQzMGM4ODQ2YTc4MWUwZmI1ZDc=
|
data/CHANGELOG.md
CHANGED
@@ -16,8 +16,8 @@
|
|
16
16
|
* Addition of attibutes:
|
17
17
|
* gender (Symbol - :male, :female, :other or :unspecified)
|
18
18
|
* finished_section (Date, nil)
|
19
|
-
*
|
20
|
-
*
|
19
|
+
* additional_information (DirtyHashy) - The customisable data part from OSM
|
20
|
+
* additional_information_labels (DirtyHashy) - The labels which belong to the data in custom
|
21
21
|
* primary_contact, secondary_contact, emergency_contact and doctor - the relevant parts from OSM
|
22
22
|
* grouping_label
|
23
23
|
* grouping_leader_label
|
data/lib/osm/member.rb
CHANGED
@@ -61,10 +61,10 @@ module Osm
|
|
61
61
|
# @return [Date] when the member finished the section they were retrieved for
|
62
62
|
# @!attribute [rw] joined_movement
|
63
63
|
# @return [Date] when the member joined the movement
|
64
|
-
# @!attribute [rw]
|
65
|
-
# @return [DirtyHashy] the
|
66
|
-
# @!attribute [rw]
|
67
|
-
# @return [DirtyHashy] the labels for the
|
64
|
+
# @!attribute [rw] additional_information
|
65
|
+
# @return [DirtyHashy] the Additional Information (key is OSM's variable name, value is the data)
|
66
|
+
# @!attribute [rw] additional_information_labels
|
67
|
+
# @return [DirtyHashy] the labels for the additional information (key is OSM's variable name, value is the label)
|
68
68
|
# @!attribute [rw] contact
|
69
69
|
# @return [Osm::Member::MemberContact, nil] the member's contact details (nil if hidden in OSM)
|
70
70
|
# @!attribute [rw] primary_contact
|
@@ -90,8 +90,8 @@ module Osm
|
|
90
90
|
attribute :finished_section, :type => Date
|
91
91
|
attribute :joined_movement, :type => Date
|
92
92
|
attribute :gender, :type => Object
|
93
|
-
attribute :
|
94
|
-
attribute :
|
93
|
+
attribute :additional_information, :type => Object, :default => DirtyHashy.new
|
94
|
+
attribute :additional_information_labels, :type => Object, :default => DirtyHashy.new
|
95
95
|
attribute :contact, :type => Object
|
96
96
|
attribute :primary_contact, :type => Object
|
97
97
|
attribute :secondary_contact, :type => Object
|
@@ -101,7 +101,8 @@ module Osm
|
|
101
101
|
if ActiveModel::VERSION::MAJOR < 4
|
102
102
|
attr_accessible :id, :section_id, :first_name, :last_name, :grouping_id, :grouping_leader,
|
103
103
|
:date_of_birth, :started_section, :finished_section, :joined_movement, :age,
|
104
|
-
:grouping_label, :grouping_leader_label, :gender,
|
104
|
+
:grouping_label, :grouping_leader_label, :gender,
|
105
|
+
:additional_information, :additional_information_labels,
|
105
106
|
:contact, :primary_contact, :secondary_contact, :emergency_contact, :doctor
|
106
107
|
end
|
107
108
|
|
@@ -113,8 +114,8 @@ module Osm
|
|
113
114
|
validates_presence_of :last_name
|
114
115
|
validates_presence_of :grouping_label, :allow_blank => true
|
115
116
|
validates_presence_of :grouping_leader_label, :allow_blank => true
|
116
|
-
validates_presence_of :
|
117
|
-
validates_presence_of :
|
117
|
+
validates_presence_of :additional_information, :allow_blank => true
|
118
|
+
validates_presence_of :additional_information_labels, :allow_blank => true
|
118
119
|
validates_presence_of :date_of_birth
|
119
120
|
validates_presence_of :started_section
|
120
121
|
validates_presence_of :finished_section, :allow_nil=>true
|
@@ -212,8 +213,8 @@ module Osm
|
|
212
213
|
receive_phone_2: member_contact[CID_RECIEVE_PHONE_2],
|
213
214
|
receive_email_1: member_contact[CID_RECIEVE_EMAIL_1],
|
214
215
|
receive_email_2: member_contact[CID_RECIEVE_EMAIL_2],
|
215
|
-
|
216
|
-
|
216
|
+
additional_information: member_custom,
|
217
|
+
additional_information_labels: custom_labels[GID_MEMBER_CONTACT],
|
217
218
|
),
|
218
219
|
:primary_contact => primary_contact.nil? ? nil : PrimaryContact.new(
|
219
220
|
first_name: primary_contact[CID_FIRST_NAME],
|
@@ -231,8 +232,8 @@ module Osm
|
|
231
232
|
receive_phone_2: primary_contact[CID_RECIEVE_PHONE_2],
|
232
233
|
receive_email_1: primary_contact[CID_RECIEVE_EMAIL_1],
|
233
234
|
receive_email_2: primary_contact[CID_RECIEVE_EMAIL_2],
|
234
|
-
|
235
|
-
|
235
|
+
additional_information: primary_custom,
|
236
|
+
additional_information_labels: custom_labels[GID_PRIMARY_CONTACT],
|
236
237
|
),
|
237
238
|
:secondary_contact => secondary_contact.nil? ? nil : SecondaryContact.new(
|
238
239
|
first_name: secondary_contact[CID_FIRST_NAME],
|
@@ -250,8 +251,8 @@ module Osm
|
|
250
251
|
receive_phone_2: secondary_contact[CID_RECIEVE_PHONE_2],
|
251
252
|
receive_email_1: secondary_contact[CID_RECIEVE_EMAIL_1],
|
252
253
|
receive_email_2: secondary_contact[CID_RECIEVE_EMAIL_2],
|
253
|
-
|
254
|
-
|
254
|
+
additional_information: secondary_custom,
|
255
|
+
additional_information_labels: custom_labels[GID_SECONDARY_CONTACT],
|
255
256
|
),
|
256
257
|
:emergency_contact => emergency_contact.nil? ? nil : EmergencyContact.new(
|
257
258
|
first_name: emergency_contact[CID_FIRST_NAME],
|
@@ -265,8 +266,8 @@ module Osm
|
|
265
266
|
phone_2: emergency_contact[CID_PHONE_2],
|
266
267
|
email_1: emergency_contact[CID_EMAIL_1],
|
267
268
|
email_2: emergency_contact[CID_EMAIL_2],
|
268
|
-
|
269
|
-
|
269
|
+
additional_information: emergency_custom,
|
270
|
+
additional_information_labels: custom_labels[GID_EMERGENCY_CONTACT],
|
270
271
|
),
|
271
272
|
:doctor => doctor_contact.nil? ? nil : DoctorContact.new(
|
272
273
|
first_name: doctor_contact[CID_FIRST_NAME],
|
@@ -279,11 +280,11 @@ module Osm
|
|
279
280
|
postcode: doctor_contact[CID_POSTCODE],
|
280
281
|
phone_1: doctor_contact[CID_PHONE_1],
|
281
282
|
phone_2: doctor_contact[CID_PHONE_2],
|
282
|
-
|
283
|
-
|
283
|
+
additional_information:doctor_custom,
|
284
|
+
additional_information_labels: custom_labels[GID_DOCTOR_CONTACT],
|
284
285
|
),
|
285
|
-
|
286
|
-
|
286
|
+
additional_information: custom_data,
|
287
|
+
additional_information_labels: custom_labels[GID_CUSTOM],
|
287
288
|
)
|
288
289
|
end
|
289
290
|
|
@@ -376,8 +377,8 @@ module Osm
|
|
376
377
|
end
|
377
378
|
|
378
379
|
# Do custom attributes
|
379
|
-
|
380
|
-
new_value =
|
380
|
+
additional_information.keys.select{ |a| force || additional_information.changes.keys.include?(a) }.each do |attr|
|
381
|
+
new_value = additional_information[attr]
|
381
382
|
data = api.perform_query("ext/customdata/?action=updateColumn§ion_id=#{section_id}", {
|
382
383
|
'associated_id' => self.id,
|
383
384
|
'associated_type' => 'member',
|
@@ -399,7 +400,7 @@ module Osm
|
|
399
400
|
# Finish off
|
400
401
|
if updated
|
401
402
|
reset_changed_attributes
|
402
|
-
|
403
|
+
additional_information.clean_up!
|
403
404
|
# The cached columns for the members will be out of date - remove them
|
404
405
|
Osm::Term.get_for_section(api, section_id).each do |term|
|
405
406
|
Osm::Model.cache_delete(api, ['members', section_id, term.id])
|
@@ -630,10 +631,10 @@ module Osm
|
|
630
631
|
# @return [String] the primary phone number
|
631
632
|
# @!attribute [rw] phone_2
|
632
633
|
# @return [String] the secondary phone number
|
633
|
-
# @!attribute [rw]
|
634
|
-
# @return [DirtyHashy] the
|
635
|
-
# @!attribute [rw]
|
636
|
-
# @return [DirtyHashy] the labels for the
|
634
|
+
# @!attribute [rw] additional_information
|
635
|
+
# @return [DirtyHashy] the additional information (key is OSM's variable name, value is the data)
|
636
|
+
# @!attribute [rw] additional_information_labels
|
637
|
+
# @return [DirtyHashy] the labels for the additional information (key is OSM's variable name, value is the label)
|
637
638
|
|
638
639
|
attribute :first_name, :type => String
|
639
640
|
attribute :last_name, :type => String
|
@@ -644,12 +645,13 @@ module Osm
|
|
644
645
|
attribute :postcode, :type => String
|
645
646
|
attribute :phone_1, :type => String
|
646
647
|
attribute :phone_2, :type => String
|
647
|
-
attribute :
|
648
|
-
attribute :
|
648
|
+
attribute :additional_information, :type => Object, :default => DirtyHashy.new
|
649
|
+
attribute :additional_information_labels, :type => Object, :default => DirtyHashy.new
|
649
650
|
|
650
651
|
if ActiveModel::VERSION::MAJOR < 4
|
651
652
|
attr_accessible :first_name, :last_name, :address_1, :address_2, :address_3, :address_4,
|
652
|
-
:postcode, :phone_1, :phone_2,
|
653
|
+
:postcode, :phone_1, :phone_2,
|
654
|
+
:additional_information, :additional_information_labels
|
653
655
|
end
|
654
656
|
|
655
657
|
# @!method initialize
|
@@ -699,13 +701,13 @@ module Osm
|
|
699
701
|
} # our name => OSM name
|
700
702
|
|
701
703
|
data = {}
|
702
|
-
attributes.keys.select{ |a| !['
|
704
|
+
attributes.keys.select{ |a| !['additional_information', 'additional_information_labels'].include?(a) }.select{ |a| force || changed_attributes.include?(a) }.each do |attr|
|
703
705
|
value = send(attr)
|
704
706
|
value = 'yes' if value.eql?(true)
|
705
707
|
data[attribute_map[attr]] = value
|
706
708
|
end
|
707
|
-
|
708
|
-
data["data[#{attr}]"] =
|
709
|
+
additional_information.keys.select{ |a| force || additional_information.changes.keys.include?(a) }.each do |attr|
|
710
|
+
data["data[#{attr}]"] = additional_information[attr]
|
709
711
|
end
|
710
712
|
|
711
713
|
updated = false
|
@@ -722,7 +724,7 @@ module Osm
|
|
722
724
|
# Finish off
|
723
725
|
if updated
|
724
726
|
reset_changed_attributes
|
725
|
-
|
727
|
+
additional_information.clean_up!
|
726
728
|
end
|
727
729
|
return updated
|
728
730
|
end
|
data/spec/osm/member_spec.rb
CHANGED
@@ -19,8 +19,8 @@ describe "Member" do
|
|
19
19
|
:joined_movement => '2006-01-02',
|
20
20
|
:started_section => '2006-01-07',
|
21
21
|
:finished_section => '2007-12-31',
|
22
|
-
:
|
23
|
-
:
|
22
|
+
:additional_information => {'12_3' => '123'},
|
23
|
+
:additional_information_labels => {'12_3' => 'Label for 123'},
|
24
24
|
:contact => Osm::Member::MemberContact.new(postcode: 'A'),
|
25
25
|
:primary_contact => Osm::Member::PrimaryContact.new(postcode: 'B'),
|
26
26
|
:secondary_contact => Osm::Member::PrimaryContact.new(postcode: 'C'),
|
@@ -43,8 +43,8 @@ describe "Member" do
|
|
43
43
|
member.joined_movement.should == Date.new(2006, 1, 2)
|
44
44
|
member.started_section.should == Date.new(2006, 1, 7)
|
45
45
|
member.finished_section.should == Date.new(2007, 12, 31)
|
46
|
-
member.
|
47
|
-
member.
|
46
|
+
member.additional_information.should == {'12_3' => '123'}
|
47
|
+
member.additional_information_labels.should == {'12_3' => 'Label for 123'}
|
48
48
|
member.contact.postcode.should == 'A'
|
49
49
|
member.primary_contact.postcode.should == 'B'
|
50
50
|
member.secondary_contact.postcode.should == 'C'
|
@@ -144,383 +144,386 @@ describe "Member" do
|
|
144
144
|
|
145
145
|
describe "Using the API" do
|
146
146
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
'data' => {
|
152
|
-
'123' => {
|
153
|
-
'active' => true,
|
154
|
-
'age' => '12 / 00',
|
155
|
-
'date_of_birth' => '2000-03-08',
|
156
|
-
'end_date' => '2010-06-03',
|
157
|
-
'first_name' => 'John',
|
158
|
-
'joined' => '2008-07-12',
|
159
|
-
'last_name' => 'Smith',
|
160
|
-
'member_id' => 123,
|
161
|
-
'patrol' => 'Leaders',
|
162
|
-
'patrol_id' => -2,
|
163
|
-
'patrol_role_level' => 1,
|
164
|
-
'patrol_role_level_label' => 'Assistant leader',
|
165
|
-
'section_id' => 1,
|
166
|
-
'started' => '2006-07-17',
|
167
|
-
'custom_data' => {
|
168
|
-
'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'},
|
169
|
-
'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'},
|
170
|
-
'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'},
|
171
|
-
'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'},
|
172
|
-
'5' => {'4848' => 'Data for 4848'},
|
173
|
-
'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'},
|
174
|
-
'7' => {'34' => 'Unspecified'},
|
175
|
-
},
|
176
|
-
}
|
177
|
-
},
|
178
|
-
'meta' => {
|
179
|
-
'leader_count' => 20,
|
180
|
-
'member_count' => 30,
|
147
|
+
describe "Get from OSM" do
|
148
|
+
|
149
|
+
it "Normal data returned from OSM" do
|
150
|
+
body = {
|
181
151
|
'status' => true,
|
182
|
-
'
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
{'
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
{'
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
{'
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
152
|
+
'error' => nil,
|
153
|
+
'data' => {
|
154
|
+
'123' => {
|
155
|
+
'active' => true,
|
156
|
+
'age' => '12 / 00',
|
157
|
+
'date_of_birth' => '2000-03-08',
|
158
|
+
'end_date' => '2010-06-03',
|
159
|
+
'first_name' => 'John',
|
160
|
+
'joined' => '2008-07-12',
|
161
|
+
'last_name' => 'Smith',
|
162
|
+
'member_id' => 123,
|
163
|
+
'patrol' => 'Leaders',
|
164
|
+
'patrol_id' => -2,
|
165
|
+
'patrol_role_level' => 1,
|
166
|
+
'patrol_role_level_label' => 'Assistant leader',
|
167
|
+
'section_id' => 1,
|
168
|
+
'started' => '2006-07-17',
|
169
|
+
'custom_data' => {
|
170
|
+
'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'},
|
171
|
+
'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'},
|
172
|
+
'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'},
|
173
|
+
'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'},
|
174
|
+
'5' => {'4848' => 'Data for 4848'},
|
175
|
+
'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'},
|
176
|
+
'7' => {'34' => 'Unspecified'},
|
177
|
+
},
|
178
|
+
}
|
179
|
+
},
|
180
|
+
'meta' => {
|
181
|
+
'leader_count' => 20,
|
182
|
+
'member_count' => 30,
|
183
|
+
'status' => true,
|
184
|
+
'structure' => [
|
185
|
+
{'group_id' => 1, 'description' => '', 'identifier' => 'contact_primary_1', 'name' => 'Primary Contact 1', 'columns' => [
|
186
|
+
{'column_id' => 2, 'group_column_id' => '1_2', 'label' => 'First Name', 'varname' => 'firstname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
187
|
+
{'column_id' => 3, 'group_column_id' => '1_3', 'label' => 'Last Name', 'varname' => 'lastname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
188
|
+
{'column_id' => 7, 'group_column_id' => '1_7', 'label' => 'Address 1', 'varname' => 'address1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
189
|
+
{'column_id' => 8, 'group_column_id' => '1_8', 'label' => 'Address 2', 'varname' => 'address2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
190
|
+
{'column_id' => 9, 'group_column_id' => '1_9', 'label' => 'Address 3', 'varname' => 'address3', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
191
|
+
{'column_id' => 10, 'group_column_id' => '1_10', 'label' => 'Address 4', 'varname' => 'address4', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
192
|
+
{'column_id' => 11, 'group_column_id' => '1_11', 'label' => 'Postcode', 'varname' => 'postcode', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
193
|
+
{'column_id' => 12, 'group_column_id' => '1_12', 'label' => 'Email 1', 'varname' => 'email1', 'read_only' => 'no', 'required' => 'no', 'type' => 'email', 'width' => 120},
|
194
|
+
{'column_id' => 14, 'group_column_id' => '1_14', 'label' => 'Email 2', 'varname' => 'email2', 'read_only' => 'no', 'required' => 'no', 'type' => 'email', 'width' => 120},
|
195
|
+
{'column_id' => 18, 'group_column_id' => '1_18', 'label' => 'Phone 1', 'varname' => 'phone1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
196
|
+
{'column_id' => 20, 'group_column_id' => '1_20', 'label' => 'Phone 2', 'varname' => 'phone2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
197
|
+
{'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},
|
198
|
+
]},
|
199
|
+
{'group_id' => 2, 'description' => '', 'identifier' => 'contact_primary_2', 'name' => 'Primary Contact 2', 'columns' => [
|
200
|
+
{'column_id' => 2, 'group_column_id' => '2_2', 'label' => 'First Name', 'varname' => 'firstname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
201
|
+
{'column_id' => 3, 'group_column_id' => '2_3', 'label' => 'Last Name', 'varname' => 'lastname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
202
|
+
{'column_id' => 7, 'group_column_id' => '2_7', 'label' => 'Address 1', 'varname' => 'address1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
203
|
+
{'column_id' => 8, 'group_column_id' => '2_8', 'label' => 'Address 2', 'varname' => 'address2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
204
|
+
{'column_id' => 9, 'group_column_id' => '2_9', 'label' => 'Address 3', 'varname' => 'address3', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
205
|
+
{'column_id' => 10, 'group_column_id' => '2_10', 'label' => 'Address 4', 'varname' => 'address4', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
206
|
+
{'column_id' => 11, 'group_column_id' => '2_11', 'label' => 'Postcode', 'varname' => 'postcode', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
207
|
+
{'column_id' => 12, 'group_column_id' => '2_12', 'label' => 'Email 1', 'varname' => 'email1', 'read_only' => 'no', 'required' => 'no', 'type' => 'email', 'width' => 120},
|
208
|
+
{'column_id' => 14, 'group_column_id' => '2_14', 'label' => 'Email 2', 'varname' => 'email2', 'read_only' => 'no', 'required' => 'no', 'type' => 'email', 'width' => 120},
|
209
|
+
{'column_id' => 18, 'group_column_id' => '2_18', 'label' => 'Phone 1', 'varname' => 'phone1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
210
|
+
{'column_id' => 20, 'group_column_id' => '2_20', 'label' => 'Phone 2', 'varname' => 'phone2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
211
|
+
{'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},
|
212
|
+
]},
|
213
|
+
{'group_id' => 3, 'description' => '', 'identifier' => 'emergency', 'name' => 'Emergency Contact', 'columns' => [
|
214
|
+
{'column_id' => 2, 'group_column_id' => '3_2', 'label' => 'First Name', 'varname' => 'firstname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
215
|
+
{'column_id' => 3, 'group_column_id' => '3_3', 'label' => 'Last Name', 'varname' => 'lastname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
216
|
+
{'column_id' => 7, 'group_column_id' => '3_7', 'label' => 'Address 1', 'varname' => 'address1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
217
|
+
{'column_id' => 8, 'group_column_id' => '3_8', 'label' => 'Address 2', 'varname' => 'address2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
218
|
+
{'column_id' => 9, 'group_column_id' => '3_9', 'label' => 'Address 3', 'varname' => 'address3', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
219
|
+
{'column_id' => 10, 'group_column_id' => '3_10', 'label' => 'Address 4', 'varname' => 'address4', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
220
|
+
{'column_id' => 11, 'group_column_id' => '3_11', 'label' => 'Postcode', 'varname' => 'postcode', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
221
|
+
{'column_id' => 12, 'group_column_id' => '3_12', 'label' => 'Email 1', 'varname' => 'email1', 'read_only' => 'no', 'required' => 'no', 'type' => 'email', 'width' => 120},
|
222
|
+
{'column_id' => 14, 'group_column_id' => '3_14', 'label' => 'Email 2', 'varname' => 'email2', 'read_only' => 'no', 'required' => 'no', 'type' => 'email', 'width' => 120},
|
223
|
+
{'column_id' => 18, 'group_column_id' => '3_18', 'label' => 'Phone 1', 'varname' => 'phone1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
224
|
+
{'column_id' => 20, 'group_column_id' => '3_20', 'label' => 'Phone 2', 'varname' => 'phone2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
225
|
+
{'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},
|
226
|
+
]},
|
227
|
+
{'group_id' => 4, 'description' => '', 'identifier' => 'doctor', 'name' => "Doctor's Surgery", 'columns' => [
|
228
|
+
{'column_id' => 2, 'group_column_id' => '4_2', 'label' => 'First Name', 'varname' => 'firstname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
229
|
+
{'column_id' => 3, 'group_column_id' => '4_3', 'label' => 'Last Name', 'varname' => 'lastname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
230
|
+
{'column_id' => 54, 'group_column_id' => '4_54', 'label' => 'Surgery', 'varname' => 'surgery', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
231
|
+
{'column_id' => 7, 'group_column_id' => '4_7', 'label' => 'Address 1', 'varname' => 'address1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
232
|
+
{'column_id' => 8, 'group_column_id' => '4_8', 'label' => 'Address 2', 'varname' => 'address2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
233
|
+
{'column_id' => 9, 'group_column_id' => '4_9', 'label' => 'Address 3', 'varname' => 'address3', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
234
|
+
{'column_id' => 10, 'group_column_id' => '4_10', 'label' => 'Address 4', 'varname' => 'address4', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
235
|
+
{'column_id' => 11, 'group_column_id' => '4_11', 'label' => 'Postcode', 'varname' => 'postcode', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
236
|
+
{'column_id' => 18, 'group_column_id' => '4_18', 'label' => 'Phone 1', 'varname' => 'phone1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
237
|
+
{'column_id' => 20, 'group_column_id' => '4_20', 'label' => 'Phone 2', 'varname' => 'phone2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
238
|
+
{'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},
|
239
|
+
]},
|
240
|
+
{'group_id' => 6, 'description' => '', 'identifier' => 'contact_member', 'name' => 'Member', 'columns' => [
|
241
|
+
{'column_id' => 2, 'group_column_id' => '6_2', 'label' => 'First Name', 'varname' => 'firstname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
242
|
+
{'column_id' => 3, 'group_column_id' => '6_3', 'label' => 'Last Name', 'varname' => 'lastname', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
243
|
+
{'column_id' => 7, 'group_column_id' => '6_7', 'label' => 'Address 1', 'varname' => 'address1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
244
|
+
{'column_id' => 8, 'group_column_id' => '6_8', 'label' => 'Address 2', 'varname' => 'address2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
245
|
+
{'column_id' => 9, 'group_column_id' => '6_9', 'label' => 'Address 3', 'varname' => 'address3', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
246
|
+
{'column_id' => 10, 'group_column_id' => '6_10', 'label' => 'Address 4', 'varname' => 'address4', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
247
|
+
{'column_id' => 11, 'group_column_id' => '6_11', 'label' => 'Postcode', 'varname' => 'postcode', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
248
|
+
{'column_id' => 12, 'group_column_id' => '6_12', 'label' => 'Email 1', 'varname' => 'email1', 'read_only' => 'no', 'required' => 'no', 'type' => 'email', 'width' => 120},
|
249
|
+
{'column_id' => 14, 'group_column_id' => '6_14', 'label' => 'Email 2', 'varname' => 'email2', 'read_only' => 'no', 'required' => 'no', 'type' => 'email', 'width' => 120},
|
250
|
+
{'column_id' => 18, 'group_column_id' => '6_18', 'label' => 'Phone 1', 'varname' => 'phone1', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
251
|
+
{'column_id' => 20, 'group_column_id' => '6_20', 'label' => 'Phone 2', 'varname' => 'phone2', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
252
|
+
{'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},
|
253
|
+
]},
|
254
|
+
{'group_id' => 5, 'description' => 'This allows you to add extra information for your members.', 'identifier' => 'customisable_data', 'name' => 'Customisable Data', 'columns' => [
|
255
|
+
{'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},
|
256
|
+
]},
|
257
|
+
{'group_id' => 7, 'description' => '', 'identifier' => 'floating', 'name' => 'Floating', 'columns' => [
|
258
|
+
{'column_id' => 34, 'group_column_id' => '7_34', 'label' => 'Gender', 'varname' => 'gender', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
259
|
+
]},
|
260
|
+
],
|
261
|
+
},
|
262
|
+
}
|
263
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ext/members/contact/grid/?action=getMembers", :body => body.to_json, :content_type => 'application/json')
|
264
|
+
|
265
|
+
members = Osm::Member.get_for_section(@api, 1, 2)
|
266
|
+
members.size.should == 1
|
267
|
+
member = members[0]
|
268
|
+
member.id.should == 123
|
269
|
+
member.section_id.should == 1
|
270
|
+
member.first_name.should == 'John'
|
271
|
+
member.last_name.should == 'Smith'
|
272
|
+
member.date_of_birth.should == Date.new(2000, 3, 8)
|
273
|
+
member.grouping_id.should == -2
|
274
|
+
member.grouping_leader.should == 1
|
275
|
+
member.grouping_label.should == 'Leaders'
|
276
|
+
member.grouping_leader_label.should == 'Assistant leader'
|
277
|
+
member.age.should == '12 / 00'
|
278
|
+
member.gender.should == :unspecified
|
279
|
+
member.joined_movement.should == Date.new(2006, 7, 17)
|
280
|
+
member.started_section.should == Date.new(2008, 7, 12)
|
281
|
+
member.finished_section.should == Date.new(2010, 6, 3)
|
282
|
+
member.additional_information.should == {"label_for_4848" => "Data for 4848"}
|
283
|
+
member.additional_information_labels.should == {"label_for_4848" => 'Label for 4848'}
|
284
|
+
member.contact.first_name.should == 'John'
|
285
|
+
member.contact.last_name.should == 'Smith'
|
286
|
+
member.contact.address_1.should == 'Address 1'
|
287
|
+
member.contact.address_2.should == 'Address 2'
|
288
|
+
member.contact.address_3.should == 'Address 3'
|
289
|
+
member.contact.address_4.should == 'Address 4'
|
290
|
+
member.contact.postcode.should == 'Postcode'
|
291
|
+
member.contact.phone_1.should == '01234 567890'
|
292
|
+
member.contact.receive_phone_1.should == true
|
293
|
+
member.contact.phone_2.should == '0987 654321'
|
294
|
+
member.contact.receive_phone_2.should == false
|
295
|
+
member.contact.email_1.should == 'member@example.com'
|
296
|
+
member.contact.receive_email_1.should == true
|
297
|
+
member.contact.email_2.should == ''
|
298
|
+
member.contact.receive_email_2.should == false
|
299
|
+
member.contact.additional_information.should == {"label_for_8446"=>"Data for 8446"}
|
300
|
+
member.contact.additional_information_labels.should == {"label_for_8446"=>"Label for 8446"}
|
301
|
+
member.primary_contact.first_name.should == 'Primary'
|
302
|
+
member.primary_contact.last_name.should == 'Contact'
|
303
|
+
member.primary_contact.address_1.should == 'Address 1'
|
304
|
+
member.primary_contact.address_2.should == 'Address 2'
|
305
|
+
member.primary_contact.address_3.should == 'Address 3'
|
306
|
+
member.primary_contact.address_4.should == 'Address 4'
|
307
|
+
member.primary_contact.postcode.should == 'Postcode'
|
308
|
+
member.primary_contact.phone_1.should == '01234 567890'
|
309
|
+
member.primary_contact.receive_phone_1.should == true
|
310
|
+
member.primary_contact.phone_2.should == '0987 654321'
|
311
|
+
member.primary_contact.receive_phone_2.should == false
|
312
|
+
member.primary_contact.email_1.should == 'primary@example.com'
|
313
|
+
member.primary_contact.receive_email_1.should == true
|
314
|
+
member.primary_contact.email_2.should == ''
|
315
|
+
member.primary_contact.receive_email_2.should == false
|
316
|
+
member.primary_contact.additional_information.should == {"label_for_8441"=>"Data for 8441"}
|
317
|
+
member.primary_contact.additional_information_labels.should == {"label_for_8441"=>"Label for 8441"}
|
318
|
+
member.secondary_contact.first_name.should == 'Secondary'
|
319
|
+
member.secondary_contact.last_name.should == 'Contact'
|
320
|
+
member.secondary_contact.address_1.should == 'Address 1'
|
321
|
+
member.secondary_contact.address_2.should == 'Address 2'
|
322
|
+
member.secondary_contact.address_3.should == 'Address 3'
|
323
|
+
member.secondary_contact.address_4.should == 'Address 4'
|
324
|
+
member.secondary_contact.postcode.should == 'Postcode'
|
325
|
+
member.secondary_contact.phone_1.should == '01234 567890'
|
326
|
+
member.secondary_contact.receive_phone_1.should == true
|
327
|
+
member.secondary_contact.phone_2.should == '0987 654321'
|
328
|
+
member.secondary_contact.receive_phone_2.should == false
|
329
|
+
member.secondary_contact.email_1.should == 'secondary@example.com'
|
330
|
+
member.secondary_contact.receive_email_1.should == true
|
331
|
+
member.secondary_contact.email_2.should == ''
|
332
|
+
member.secondary_contact.receive_email_2.should == false
|
333
|
+
member.secondary_contact.additional_information.should == {"label_for_8442"=>"Data for 8442"}
|
334
|
+
member.secondary_contact.additional_information_labels.should == {"label_for_8442"=>"Label for 8442"}
|
335
|
+
member.emergency_contact.first_name.should == 'Emergency'
|
336
|
+
member.emergency_contact.last_name.should == 'Contact'
|
337
|
+
member.emergency_contact.address_1.should == 'Address 1'
|
338
|
+
member.emergency_contact.address_2.should == 'Address 2'
|
339
|
+
member.emergency_contact.address_3.should == 'Address 3'
|
340
|
+
member.emergency_contact.address_4.should == 'Address 4'
|
341
|
+
member.emergency_contact.postcode.should == 'Postcode'
|
342
|
+
member.emergency_contact.phone_1.should == '01234 567890'
|
343
|
+
member.emergency_contact.phone_2.should == '0987 654321'
|
344
|
+
member.emergency_contact.email_1.should == 'emergency@example.com'
|
345
|
+
member.emergency_contact.email_2.should == ''
|
346
|
+
member.emergency_contact.additional_information.should == {"label_for_8443"=>"Data for 8443"}
|
347
|
+
member.emergency_contact.additional_information_labels.should == {"label_for_8443"=>"Label for 8443"}
|
348
|
+
member.doctor.first_name.should == 'Doctor'
|
349
|
+
member.doctor.last_name.should == 'Contact'
|
350
|
+
member.doctor.surgery.should == 'Surgery'
|
351
|
+
member.doctor.address_1.should == 'Address 1'
|
352
|
+
member.doctor.address_2.should == 'Address 2'
|
353
|
+
member.doctor.address_3.should == 'Address 3'
|
354
|
+
member.doctor.address_4.should == 'Address 4'
|
355
|
+
member.doctor.postcode.should == 'Postcode'
|
356
|
+
member.doctor.phone_1.should == '01234 567890'
|
357
|
+
member.doctor.phone_2.should == '0987 654321'
|
358
|
+
member.doctor.additional_information.should == {"label_for_8444"=>"Data for 8444"}
|
359
|
+
member.doctor.additional_information_labels.should == {"label_for_8444"=>"Label for 8444"}
|
360
|
+
member.valid?.should == true
|
361
|
+
end
|
360
362
|
|
361
|
-
|
362
|
-
|
363
|
-
'status' => true,
|
364
|
-
'error' => nil,
|
365
|
-
'data' => {
|
366
|
-
'123' => {
|
367
|
-
'active' => true,
|
368
|
-
'age' => '12 / 00',
|
369
|
-
'date_of_birth' => '2000-03-08',
|
370
|
-
'end_date' => '2010-06-03',
|
371
|
-
'first_name' => 'John',
|
372
|
-
'joined' => '2008-07-12',
|
373
|
-
'last_name' => 'Smith',
|
374
|
-
'member_id' => 123,
|
375
|
-
'patrol' => 'Leaders',
|
376
|
-
'patrol_id' => -2,
|
377
|
-
'patrol_role_level' => 1,
|
378
|
-
'patrol_role_level_label' => 'Assistant leader',
|
379
|
-
'section_id' => 1,
|
380
|
-
'started' => '2006-07-17',
|
381
|
-
'custom_data' => {
|
382
|
-
'5' => {'4848' => 'Data for 4848'},
|
383
|
-
'7' => {'34' => 'Unspecified'},
|
384
|
-
},
|
385
|
-
}
|
386
|
-
},
|
387
|
-
'meta' => {
|
388
|
-
'leader_count' => 20,
|
389
|
-
'member_count' => 30,
|
363
|
+
it "Handles disabled contacts" do
|
364
|
+
body = {
|
390
365
|
'status' => true,
|
391
|
-
'
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
366
|
+
'error' => nil,
|
367
|
+
'data' => {
|
368
|
+
'123' => {
|
369
|
+
'active' => true,
|
370
|
+
'age' => '12 / 00',
|
371
|
+
'date_of_birth' => '2000-03-08',
|
372
|
+
'end_date' => '2010-06-03',
|
373
|
+
'first_name' => 'John',
|
374
|
+
'joined' => '2008-07-12',
|
375
|
+
'last_name' => 'Smith',
|
376
|
+
'member_id' => 123,
|
377
|
+
'patrol' => 'Leaders',
|
378
|
+
'patrol_id' => -2,
|
379
|
+
'patrol_role_level' => 1,
|
380
|
+
'patrol_role_level_label' => 'Assistant leader',
|
381
|
+
'section_id' => 1,
|
382
|
+
'started' => '2006-07-17',
|
383
|
+
'custom_data' => {
|
384
|
+
'5' => {'4848' => 'Data for 4848'},
|
385
|
+
'7' => {'34' => 'Unspecified'},
|
386
|
+
},
|
387
|
+
}
|
388
|
+
},
|
389
|
+
'meta' => {
|
390
|
+
'leader_count' => 20,
|
391
|
+
'member_count' => 30,
|
392
|
+
'status' => true,
|
393
|
+
'structure' => [
|
394
|
+
{'group_id' => 5, 'description' => 'This allows you to add extra information for your members.', 'identifier' => 'customisable_data', 'name' => 'Customisable Data', 'columns' => [
|
395
|
+
{'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},
|
396
|
+
]},
|
397
|
+
{'group_id' => 7, 'description' => '', 'identifier' => 'floating', 'name' => 'Floating', 'columns' => [
|
398
|
+
{'column_id' => 34, 'group_column_id' => '7_34', 'label' => 'Gender', 'varname' => 'gender', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
399
|
+
]},
|
400
|
+
],
|
401
|
+
},
|
402
|
+
}
|
403
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ext/members/contact/grid/?action=getMembers", :body => body.to_json, :content_type => 'application/json')
|
404
|
+
|
405
|
+
members = Osm::Member.get_for_section(@api, 1, 2)
|
406
|
+
members.size.should == 1
|
407
|
+
member = members[0]
|
408
|
+
member.id.should == 123
|
409
|
+
member.contact.should == nil
|
410
|
+
member.primary_contact.should == nil
|
411
|
+
member.secondary_contact.should == nil
|
412
|
+
member.emergency_contact.should == nil
|
413
|
+
member.doctor.should == nil
|
414
|
+
member.valid?.should == true
|
415
|
+
end
|
414
416
|
|
415
|
-
|
416
|
-
|
417
|
-
'status' => true,
|
418
|
-
'error' => nil,
|
419
|
-
'data' => {
|
420
|
-
'123' => {
|
421
|
-
'active' => true,
|
422
|
-
'age' => '12 / 00',
|
423
|
-
'date_of_birth' => '2000-03-08',
|
424
|
-
'end_date' => '2010-06-03',
|
425
|
-
'first_name' => 'John',
|
426
|
-
'joined' => '2008-07-12',
|
427
|
-
'last_name' => 'Smith',
|
428
|
-
'member_id' => 123,
|
429
|
-
'patrol' => 'Leaders',
|
430
|
-
'patrol_id' => -2,
|
431
|
-
'patrol_role_level' => 1,
|
432
|
-
'patrol_role_level_label' => 'Assistant leader',
|
433
|
-
'section_id' => 1,
|
434
|
-
'started' => '2006-07-17',
|
435
|
-
'custom_data' => {
|
436
|
-
'7' => {'34' => 'Unspecified'},
|
437
|
-
},
|
438
|
-
}
|
439
|
-
},
|
440
|
-
'meta' => {
|
441
|
-
'leader_count' => 20,
|
442
|
-
'member_count' => 30,
|
417
|
+
it "Handles no custom data" do
|
418
|
+
body = {
|
443
419
|
'status' => true,
|
444
|
-
'
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
420
|
+
'error' => nil,
|
421
|
+
'data' => {
|
422
|
+
'123' => {
|
423
|
+
'active' => true,
|
424
|
+
'age' => '12 / 00',
|
425
|
+
'date_of_birth' => '2000-03-08',
|
426
|
+
'end_date' => '2010-06-03',
|
427
|
+
'first_name' => 'John',
|
428
|
+
'joined' => '2008-07-12',
|
429
|
+
'last_name' => 'Smith',
|
430
|
+
'member_id' => 123,
|
431
|
+
'patrol' => 'Leaders',
|
432
|
+
'patrol_id' => -2,
|
433
|
+
'patrol_role_level' => 1,
|
434
|
+
'patrol_role_level_label' => 'Assistant leader',
|
435
|
+
'section_id' => 1,
|
436
|
+
'started' => '2006-07-17',
|
437
|
+
'custom_data' => {
|
438
|
+
'7' => {'34' => 'Unspecified'},
|
439
|
+
},
|
440
|
+
}
|
441
|
+
},
|
442
|
+
'meta' => {
|
443
|
+
'leader_count' => 20,
|
444
|
+
'member_count' => 30,
|
445
|
+
'status' => true,
|
446
|
+
'structure' => [
|
447
|
+
{'group_id' => 5, 'description' => 'This allows you to add extra information for your members.', 'identifier' => 'customisable_data', 'name' => 'Customisable Data', 'columns' => [
|
448
|
+
{'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},
|
449
|
+
]},
|
450
|
+
{'group_id' => 7, 'description' => '', 'identifier' => 'floating', 'name' => 'Floating', 'columns' => [
|
451
|
+
{'column_id' => 34, 'group_column_id' => '7_34', 'label' => 'Gender', 'varname' => 'gender', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
452
|
+
]},
|
453
|
+
],
|
454
|
+
},
|
455
|
+
}
|
456
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ext/members/contact/grid/?action=getMembers", :body => body.to_json, :content_type => 'application/json')
|
457
|
+
|
458
|
+
members = Osm::Member.get_for_section(@api, 1, 2)
|
459
|
+
members.size.should == 1
|
460
|
+
member = members[0]
|
461
|
+
member.id.should == 123
|
462
|
+
member.additional_information.should == {}
|
463
|
+
member.valid?.should == true
|
464
|
+
end
|
463
465
|
|
464
|
-
|
465
|
-
|
466
|
-
'status' => true,
|
467
|
-
'error' => nil,
|
468
|
-
'data' => {
|
469
|
-
'123' => {
|
470
|
-
'active' => true,
|
471
|
-
'age' => '12 / 00',
|
472
|
-
'date_of_birth' => '2000-03-08',
|
473
|
-
'end_date' => '2010-06-03',
|
474
|
-
'first_name' => 'John',
|
475
|
-
'joined' => '2008-07-12',
|
476
|
-
'last_name' => 'Smith',
|
477
|
-
'member_id' => 123,
|
478
|
-
'patrol' => 'Leaders',
|
479
|
-
'patrol_id' => -2,
|
480
|
-
'patrol_role_level' => 1,
|
481
|
-
'patrol_role_level_label' => 'Assistant leader',
|
482
|
-
'section_id' => 1,
|
483
|
-
'started' => '2006-07-17',
|
484
|
-
'custom_data' => {
|
485
|
-
'5' => {'4848' => 'Data for 4848'},
|
486
|
-
},
|
487
|
-
}
|
488
|
-
},
|
489
|
-
'meta' => {
|
490
|
-
'leader_count' => 20,
|
491
|
-
'member_count' => 30,
|
466
|
+
it "Handles missing floating data" do
|
467
|
+
body = {
|
492
468
|
'status' => true,
|
493
|
-
'
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
469
|
+
'error' => nil,
|
470
|
+
'data' => {
|
471
|
+
'123' => {
|
472
|
+
'active' => true,
|
473
|
+
'age' => '12 / 00',
|
474
|
+
'date_of_birth' => '2000-03-08',
|
475
|
+
'end_date' => '2010-06-03',
|
476
|
+
'first_name' => 'John',
|
477
|
+
'joined' => '2008-07-12',
|
478
|
+
'last_name' => 'Smith',
|
479
|
+
'member_id' => 123,
|
480
|
+
'patrol' => 'Leaders',
|
481
|
+
'patrol_id' => -2,
|
482
|
+
'patrol_role_level' => 1,
|
483
|
+
'patrol_role_level_label' => 'Assistant leader',
|
484
|
+
'section_id' => 1,
|
485
|
+
'started' => '2006-07-17',
|
486
|
+
'custom_data' => {
|
487
|
+
'5' => {'4848' => 'Data for 4848'},
|
488
|
+
},
|
489
|
+
}
|
490
|
+
},
|
491
|
+
'meta' => {
|
492
|
+
'leader_count' => 20,
|
493
|
+
'member_count' => 30,
|
494
|
+
'status' => true,
|
495
|
+
'structure' => [
|
496
|
+
{'group_id' => 5, 'description' => 'This allows you to add extra information for your members.', 'identifier' => 'customisable_data', 'name' => 'Customisable Data', 'columns' => [
|
497
|
+
{'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},
|
498
|
+
]},
|
499
|
+
{'group_id' => 7, 'description' => '', 'identifier' => 'floating', 'name' => 'Floating', 'columns' => [
|
500
|
+
{'column_id' => 34, 'group_column_id' => '7_34', 'label' => 'Gender', 'varname' => 'gender', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
501
|
+
]},
|
502
|
+
],
|
503
|
+
},
|
504
|
+
}
|
505
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ext/members/contact/grid/?action=getMembers", :body => body.to_json, :content_type => 'application/json')
|
506
|
+
|
507
|
+
members = Osm::Member.get_for_section(@api, 1, 2)
|
508
|
+
members.size.should == 1
|
509
|
+
member = members[0]
|
510
|
+
member.id.should == 123
|
511
|
+
member.gender.should == nil
|
512
|
+
member.valid?.should == true
|
513
|
+
end
|
512
514
|
|
515
|
+
it "Handles an empty data array" do
|
516
|
+
body = {
|
517
|
+
'status' => true,
|
518
|
+
'error' => nil,
|
519
|
+
'data' => [],
|
520
|
+
'meta' => {},
|
521
|
+
}
|
522
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ext/members/contact/grid/?action=getMembers", :body => body.to_json, :content_type => 'application/json')
|
513
523
|
|
514
|
-
|
515
|
-
|
516
|
-
'status' => true,
|
517
|
-
'error' => nil,
|
518
|
-
'data' => [],
|
519
|
-
'meta' => {},
|
520
|
-
}
|
521
|
-
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ext/members/contact/grid/?action=getMembers", :body => body.to_json, :content_type => 'application/json')
|
524
|
+
Osm::Member.get_for_section(@api, 1, 2).should == []
|
525
|
+
end
|
522
526
|
|
523
|
-
Osm::Member.get_for_section(@api, 1, 2).should == []
|
524
527
|
end
|
525
528
|
|
526
529
|
|
@@ -541,8 +544,8 @@ describe "Member" do
|
|
541
544
|
:joined_movement => '2006-01-02',
|
542
545
|
:started_section => '2006-01-07',
|
543
546
|
:finished_section => '2007-12-31',
|
544
|
-
:
|
545
|
-
:
|
547
|
+
:additional_information => {'12_3' => '123'},
|
548
|
+
:additional_information_labels => {'12_3' => 'Label for 123'},
|
546
549
|
:contact => Osm::Member::MemberContact.new(postcode: 'A'),
|
547
550
|
:primary_contact => Osm::Member::PrimaryContact.new(postcode: 'B'),
|
548
551
|
:secondary_contact => Osm::Member::PrimaryContact.new(postcode: 'C'),
|
@@ -628,13 +631,13 @@ describe "Member" do
|
|
628
631
|
:joined_movement => '2006-01-02',
|
629
632
|
:started_section => '2006-01-07',
|
630
633
|
:finished_section => '2007-12-31',
|
631
|
-
:
|
632
|
-
:
|
634
|
+
:additional_information => DirtyHashy[ '12_3', '123' ],
|
635
|
+
:additional_information_labels => {'12_3' => 'Label for 123'},
|
633
636
|
:contact => Osm::Member::MemberContact.new(postcode: 'A'),
|
634
637
|
:primary_contact => Osm::Member::PrimaryContact.new(postcode: 'B'),
|
635
638
|
:secondary_contact => Osm::Member::SecondaryContact.new(postcode: 'C'),
|
636
639
|
:emergency_contact => Osm::Member::EmergencyContact.new(postcode: 'D'),
|
637
|
-
:doctor => Osm::Member::DoctorContact.new(postcode: 'E'),
|
640
|
+
:doctor => Osm::Member::DoctorContact.new(postcode: 'E', additional_information: DirtyHashy['test_var', 'This is a test']),
|
638
641
|
}
|
639
642
|
@member = Osm::Member.new(attributes)
|
640
643
|
end
|
@@ -722,17 +725,33 @@ describe "Member" do
|
|
722
725
|
"associated_id" => 1,
|
723
726
|
"group_id" => 4,
|
724
727
|
"data[surgery]" => "Surgery",
|
728
|
+
"data[test_var]" => "This is still a test",
|
725
729
|
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"status":true}'}) }
|
726
730
|
|
731
|
+
HTTParty.should_receive(:post).with('https://www.onlinescoutmanager.co.uk/ext/customdata/?action=updateColumn§ion_id=2', {:body => {
|
732
|
+
"apiid" => "1",
|
733
|
+
"token" => "API TOKEN",
|
734
|
+
"userid" => "user_id",
|
735
|
+
"secret" => "secret",
|
736
|
+
"context" => "members",
|
737
|
+
"associated_type" => "member",
|
738
|
+
"associated_id" => 1,
|
739
|
+
"group_id" => 5,
|
740
|
+
"column_id" => "12_3",
|
741
|
+
"value" => "321",
|
742
|
+
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"data":{"value":"321"}}'}) }
|
743
|
+
|
727
744
|
Osm::Term.stub(:get_for_section) { [] }
|
728
745
|
|
729
746
|
@member.first_name = 'John'
|
730
747
|
@member.gender = :unspecified
|
748
|
+
@member.additional_information['12_3'] = '321'
|
731
749
|
@member.contact.address_1 = 'Address 1'
|
732
750
|
@member.primary_contact.address_2 = 'Address 2'
|
733
751
|
@member.secondary_contact.address_3 = 'Address 3'
|
734
752
|
@member.emergency_contact.address_4 = 'Address 4'
|
735
753
|
@member.doctor.surgery = 'Surgery'
|
754
|
+
@member.doctor.additional_information['test_var'] = 'This is still a test'
|
736
755
|
@member.update(@api).should == true
|
737
756
|
end
|
738
757
|
|
@@ -845,6 +864,7 @@ describe "Member" do
|
|
845
864
|
"data[postcode]" => "E",
|
846
865
|
"data[phone1]" => nil,
|
847
866
|
"data[phone2]" => nil,
|
867
|
+
"data[test_var]" => "This is a test",
|
848
868
|
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"status":true}'}) }
|
849
869
|
|
850
870
|
Osm::Term.stub(:get_for_section) { [] }
|
@@ -862,6 +882,16 @@ describe "Member" do
|
|
862
882
|
expect{ Osm::Member.new.create(@api) }.to raise_error(Osm::ObjectIsInvalid, 'member is invalid')
|
863
883
|
end
|
864
884
|
|
885
|
+
it "Handles disabled contacts" do
|
886
|
+
@member.contact = nil
|
887
|
+
@member.primary_contact = nil
|
888
|
+
@member.secondary_contact = nil
|
889
|
+
@member.emergency_contact = nil
|
890
|
+
@member.doctor = nil
|
891
|
+
HTTParty.stub(:post) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{}'}) }
|
892
|
+
@member.update(@api).should == true
|
893
|
+
end
|
894
|
+
|
865
895
|
end
|
866
896
|
|
867
897
|
it "Get Photo link" do
|
@@ -877,8 +907,8 @@ describe "Member" do
|
|
877
907
|
:grouping_leader => 0,
|
878
908
|
:grouping_label => 'Grouping',
|
879
909
|
:grouping_leader_label => '',
|
880
|
-
:
|
881
|
-
:
|
910
|
+
:additional_information => {},
|
911
|
+
:additional_information_labels => {},
|
882
912
|
:contact => Osm::Member::MemberContact.new(),
|
883
913
|
:primary_contact => Osm::Member::PrimaryContact.new(),
|
884
914
|
:secondary_contact => Osm::Member::PrimaryContact.new(),
|
@@ -906,8 +936,8 @@ describe "Member" do
|
|
906
936
|
:grouping_leader => 0,
|
907
937
|
:grouping_label => 'Grouping',
|
908
938
|
:grouping_leader_label => '',
|
909
|
-
:
|
910
|
-
:
|
939
|
+
:additional_information => {},
|
940
|
+
:additional_information_labels => {},
|
911
941
|
:contact => Osm::Member::MemberContact.new(),
|
912
942
|
:primary_contact => Osm::Member::PrimaryContact.new(),
|
913
943
|
:secondary_contact => Osm::Member::PrimaryContact.new(),
|