osm 1.2.18.dev.12 → 1.2.18.dev.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +0 -1
- data/lib/osm/member.rb +17 -45
- data/spec/osm/member_spec.rb +24 -48
- data/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2VjMTQzMTkxZGVmOTQwNDc5Y2U5OWZiMjA3ODEwMmY4MTMyMThiNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTRlYjNiNDlhYTZlYjM3MmI3NmUxMzE2MmEyY2JjZTdiYTA3N2YzMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjllZDZmOGQxMTVlY2YwZDc1NTFhNGI2Y2IwZmE1ODIxM2ZmNTYzYjQ2MzYz
|
10
|
+
ZjRkN2Y5MmVjZWI4ZjI3NTJmNTY2OTM3ZWIxODM1NDcxNGFkNWY2ZTJkZjAw
|
11
|
+
ODdlNWVjOTMxNjBhNjA2NzM4Zjc4NjUwM2I1NzE2ZjRmOGYwNjc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTU0OGVkNmJmZTMwNjhhOTU0ZTNkMzIzZWY4YWE0YTExMWU2MTJjMDcwMGIy
|
14
|
+
NjA1ZGM3NjQ1M2NmOTM1OTljOTEyMTRiNjg0YjRjNTYxYzM2NDBkZDIyNjYw
|
15
|
+
OWQ0MjJkMjgzYzQ4NDk5MmQyN2QzYzE3NzU4YjAxZGMwNjgwYjk=
|
data/CHANGELOG.md
CHANGED
data/lib/osm/member.rb
CHANGED
@@ -11,7 +11,6 @@ module Osm
|
|
11
11
|
GID_FLOATING = 7
|
12
12
|
|
13
13
|
# Constants for column id
|
14
|
-
CID_TITLE = 1
|
15
14
|
CID_FIRST_NAME = 2
|
16
15
|
CID_LAST_NAME = 3
|
17
16
|
CID_ADDRESS_1 = 7
|
@@ -36,8 +35,6 @@ module Osm
|
|
36
35
|
# @return [Fixnum] the id for the member
|
37
36
|
# @!attribute [rw] section_id
|
38
37
|
# @return [Fixnum] the section the member belongs to
|
39
|
-
# @!attribute [rw] title
|
40
|
-
# @return [String] the member's title (Mr, Mrs etc.)
|
41
38
|
# @!attribute [rw] first_name
|
42
39
|
# @return [String] the member's first name
|
43
40
|
# @!attribute [rw] last_name
|
@@ -79,7 +76,6 @@ module Osm
|
|
79
76
|
|
80
77
|
attribute :id, :type => Integer
|
81
78
|
attribute :section_id, :type => Integer
|
82
|
-
attribute :title, :type => String
|
83
79
|
attribute :first_name, :type => String
|
84
80
|
attribute :last_name, :type => String
|
85
81
|
attribute :grouping_id, :type => Integer
|
@@ -101,7 +97,7 @@ module Osm
|
|
101
97
|
attribute :doctor, :type => Object
|
102
98
|
|
103
99
|
if ActiveModel::VERSION::MAJOR < 4
|
104
|
-
attr_accessible :id, :section_id, :
|
100
|
+
attr_accessible :id, :section_id, :first_name, :last_name,
|
105
101
|
:grouping_id, :grouping_leader,
|
106
102
|
:date_of_birth, :started_section, :finished_section, :joined_movement, :age,
|
107
103
|
:grouping_label, :grouping_leader_label, :gender,
|
@@ -162,32 +158,30 @@ module Osm
|
|
162
158
|
structure = Hash[ structure.map{ |i| [i['group_id'].to_i, i ] } ] # Make a hash of identifier to group data hash
|
163
159
|
|
164
160
|
custom_labels = {}
|
165
|
-
|
161
|
+
key_key = 'column_id' # the key in the data from OSM to use as the key in additional_information and labels hashes
|
166
162
|
structure.each do |gid, group|
|
167
163
|
columns = group['columns'] || []
|
168
|
-
custom_labels[gid.to_i] = Hash[ columns.map.select{ |a| gid.eql?(GID_CUSTOM) || !CORE_FIELD_IDS.include?(a['column_id'].to_i) }.map{ |c| [c[
|
169
|
-
var_names[gid.to_i] = DirtyHashy[ columns.map{ |c| [c['column_id'].to_i, c['varname']] } ]
|
164
|
+
custom_labels[gid.to_i] = Hash[ columns.map.select{ |a| gid.eql?(GID_CUSTOM) || !CORE_FIELD_IDS.include?(a['column_id'].to_i) }.map{ |c| [c[key_key], c['label']] } ]
|
170
165
|
end
|
171
166
|
|
172
167
|
data.each do |item|
|
173
168
|
item_data = Hash[ item['custom_data'].map{ |k,v| [k.to_i, v] } ]
|
174
169
|
member_contact = item_data[GID_MEMBER_CONTACT].nil? ? nil : Hash[ item_data[GID_MEMBER_CONTACT].map{ |k,v| [k.to_i, v] }.select{ |k,v| CORE_FIELD_IDS.include?(k) } ]
|
175
|
-
member_custom = item_data[GID_MEMBER_CONTACT].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_MEMBER_CONTACT].select{ |k,v| !
|
170
|
+
member_custom = item_data[GID_MEMBER_CONTACT].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_MEMBER_CONTACT].select{ |k,v| !CORE_FIELD_IDS.include?(k.to_i) }.map{ |k,v| [k.to_i, v] } ]
|
176
171
|
primary_contact = item_data[GID_PRIMARY_CONTACT].nil? ? nil : Hash[ item_data[GID_PRIMARY_CONTACT].map{ |k,v| [k.to_i, v] }.select{ |k,v| CORE_FIELD_IDS.include?(k) } ]
|
177
|
-
primary_custom = item_data[GID_PRIMARY_CONTACT].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_PRIMARY_CONTACT].select{ |k,v| !CORE_FIELD_IDS.include?(k.to_i) }.map{ |k,v| [
|
172
|
+
primary_custom = item_data[GID_PRIMARY_CONTACT].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_PRIMARY_CONTACT].select{ |k,v| !CORE_FIELD_IDS.include?(k.to_i) }.map{ |k,v| [k.to_i, v] } ]
|
178
173
|
secondary_contact = item_data[GID_SECONDARY_CONTACT].nil? ? nil : Hash[ item_data[GID_SECONDARY_CONTACT].map{ |k,v| [k.to_i, v] }.select{ |k,v| CORE_FIELD_IDS.include?(k) } ]
|
179
|
-
secondary_custom = item_data[GID_SECONDARY_CONTACT].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_SECONDARY_CONTACT].select{ |k,v| !CORE_FIELD_IDS.include?(k.to_i) }.map{ |k,v| [
|
174
|
+
secondary_custom = item_data[GID_SECONDARY_CONTACT].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_SECONDARY_CONTACT].select{ |k,v| !CORE_FIELD_IDS.include?(k.to_i) }.map{ |k,v| [k.to_i, v] } ]
|
180
175
|
emergency_contact = item_data[GID_EMERGENCY_CONTACT].nil? ? nil : Hash[ item_data[GID_EMERGENCY_CONTACT].map{ |k,v| [k.to_i, v] }.select{ |k,v| CORE_FIELD_IDS.include?(k) } ]
|
181
|
-
emergency_custom = item_data[GID_EMERGENCY_CONTACT].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_EMERGENCY_CONTACT].select{ |k,v| !CORE_FIELD_IDS.include?(k.to_i) }.map{ |k,v| [
|
176
|
+
emergency_custom = item_data[GID_EMERGENCY_CONTACT].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_EMERGENCY_CONTACT].select{ |k,v| !CORE_FIELD_IDS.include?(k.to_i) }.map{ |k,v| [k.to_i, v] } ]
|
182
177
|
doctor_contact = item_data[GID_DOCTOR_CONTACT].nil? ? nil : Hash[ item_data[GID_DOCTOR_CONTACT].map{ |k,v| [k.to_i, v] }.select{ |k,v| CORE_FIELD_IDS.include?(k) } ]
|
183
|
-
doctor_custom = item_data[GID_DOCTOR_CONTACT].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_DOCTOR_CONTACT].select{ |k,v| !CORE_FIELD_IDS.include?(k.to_i) }.map{ |k,v| [
|
178
|
+
doctor_custom = item_data[GID_DOCTOR_CONTACT].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_DOCTOR_CONTACT].select{ |k,v| !CORE_FIELD_IDS.include?(k.to_i) }.map{ |k,v| [k.to_i, v] } ]
|
184
179
|
floating_data = item_data[GID_FLOATING].nil? ? {} : Hash[ item_data[GID_FLOATING].map{ |k,v| [k.to_i, v] }.select{ |k,v| CORE_FIELD_IDS.include?(k) } ]
|
185
|
-
custom_data = item_data[GID_CUSTOM].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_CUSTOM].map{ |k,v| [
|
180
|
+
custom_data = item_data[GID_CUSTOM].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_CUSTOM].map{ |k,v| [k.to_i, v] } ]
|
186
181
|
|
187
182
|
result.push Osm::Member.new(
|
188
183
|
:id => Osm::to_i_or_nil(item['member_id']),
|
189
184
|
:section_id => Osm::to_i_or_nil(item['section_id']),
|
190
|
-
:title => custom_data['title'],
|
191
185
|
:first_name => item['first_name'],
|
192
186
|
:last_name => item['last_name'],
|
193
187
|
:grouping_id => Osm::to_i_or_nil(item['patrol_id']),
|
@@ -201,7 +195,6 @@ module Osm
|
|
201
195
|
:joined_movement => Osm::parse_date(item['started']),
|
202
196
|
:gender => {'male'=>:male, 'female'=>:female, 'other'=>:other, 'unspecified'=>:unspecified}[(floating_data[CID_GENDER] || '').downcase],
|
203
197
|
:contact => member_contact.nil? ? nil : MemberContact.new(
|
204
|
-
title: member_contact[CID_TITLE],
|
205
198
|
first_name: item['first_name'],
|
206
199
|
last_name: item['last_name'],
|
207
200
|
address_1: member_contact[CID_ADDRESS_1],
|
@@ -217,11 +210,10 @@ module Osm
|
|
217
210
|
receive_phone_2: member_contact[CID_RECIEVE_PHONE_2],
|
218
211
|
receive_email_1: member_contact[CID_RECIEVE_EMAIL_1],
|
219
212
|
receive_email_2: member_contact[CID_RECIEVE_EMAIL_2],
|
220
|
-
additional_information:
|
213
|
+
additional_information: member_custom,
|
221
214
|
additional_information_labels: custom_labels[GID_MEMBER_CONTACT],
|
222
215
|
),
|
223
216
|
:primary_contact => primary_contact.nil? ? nil : PrimaryContact.new(
|
224
|
-
title: primary_contact[CID_TITLE],
|
225
217
|
first_name: primary_contact[CID_FIRST_NAME],
|
226
218
|
last_name: primary_contact[CID_LAST_NAME],
|
227
219
|
address_1: primary_contact[CID_ADDRESS_1],
|
@@ -241,7 +233,6 @@ module Osm
|
|
241
233
|
additional_information_labels: custom_labels[GID_PRIMARY_CONTACT],
|
242
234
|
),
|
243
235
|
:secondary_contact => secondary_contact.nil? ? nil : SecondaryContact.new(
|
244
|
-
title: secondary_contact[CID_TITLE],
|
245
236
|
first_name: secondary_contact[CID_FIRST_NAME],
|
246
237
|
last_name: secondary_contact[CID_LAST_NAME],
|
247
238
|
address_1: secondary_contact[CID_ADDRESS_1],
|
@@ -261,7 +252,6 @@ module Osm
|
|
261
252
|
additional_information_labels: custom_labels[GID_SECONDARY_CONTACT],
|
262
253
|
),
|
263
254
|
:emergency_contact => emergency_contact.nil? ? nil : EmergencyContact.new(
|
264
|
-
title: emergency_contact[CID_TITLE],
|
265
255
|
first_name: emergency_contact[CID_FIRST_NAME],
|
266
256
|
last_name: emergency_contact[CID_LAST_NAME],
|
267
257
|
address_1: emergency_contact[CID_ADDRESS_1],
|
@@ -277,7 +267,6 @@ module Osm
|
|
277
267
|
additional_information_labels: custom_labels[GID_EMERGENCY_CONTACT],
|
278
268
|
),
|
279
269
|
:doctor => doctor_contact.nil? ? nil : DoctorContact.new(
|
280
|
-
title: doctor_contact[CID_TITLE],
|
281
270
|
first_name: doctor_contact[CID_FIRST_NAME],
|
282
271
|
last_name: doctor_contact[CID_LAST_NAME],
|
283
272
|
surgery: doctor_contact[CID_SURGERY],
|
@@ -291,8 +280,8 @@ module Osm
|
|
291
280
|
additional_information: doctor_custom,
|
292
281
|
additional_information_labels: custom_labels[GID_DOCTOR_CONTACT],
|
293
282
|
),
|
294
|
-
additional_information:
|
295
|
-
additional_information_labels: custom_labels[GID_CUSTOM]
|
283
|
+
additional_information: custom_data,
|
284
|
+
additional_information_labels: custom_labels[GID_CUSTOM],
|
296
285
|
)
|
297
286
|
end
|
298
287
|
|
@@ -370,19 +359,6 @@ module Osm
|
|
370
359
|
updated = updated && data.is_a?(Hash) && data['ok'].eql?(true)
|
371
360
|
end # each attr to update
|
372
361
|
|
373
|
-
# Do title attribute
|
374
|
-
if force || changed_attributes.include?('title')
|
375
|
-
data = api.perform_query("ext/customdata/?action=updateColumn§ion_id=#{section_id}", {
|
376
|
-
'associated_id' => self.id,
|
377
|
-
'associated_type' => 'member',
|
378
|
-
'value' => title,
|
379
|
-
'column_id' => CID_TITLE,
|
380
|
-
'group_id' => GID_CUSTOM,
|
381
|
-
'context' => 'members',
|
382
|
-
})
|
383
|
-
updated = updated && data.is_a?(Hash) && data['data'].is_a?(Hash) && data['data']['value'].eql?(title)
|
384
|
-
end
|
385
|
-
|
386
362
|
# Do 'floating' attributes
|
387
363
|
if force || changed_attributes.include?('gender')
|
388
364
|
new_value = {male: 'Male', female: 'Female', other: 'Other'}[gender] || 'Unspecified'
|
@@ -443,10 +419,10 @@ module Osm
|
|
443
419
|
end
|
444
420
|
|
445
421
|
# Get the full name
|
446
|
-
# @param [String] seperator What to split the member's
|
422
|
+
# @param [String] seperator What to split the member's first name and last name with
|
447
423
|
# @return [String] this scout's full name seperated by the optional seperator
|
448
424
|
def name(seperator=' ')
|
449
|
-
return [
|
425
|
+
return [first_name, last_name].select{ |i| !i.blank? }.join(seperator)
|
450
426
|
end
|
451
427
|
|
452
428
|
# Check if the member is in the leaders grouping
|
@@ -634,8 +610,6 @@ module Osm
|
|
634
610
|
|
635
611
|
|
636
612
|
class Contact < Osm::Model
|
637
|
-
# @!attribute [rw] title
|
638
|
-
# @return [String] the contact's title (Mr, Ms, Dr etc.)
|
639
613
|
# @!attribute [rw] first_name
|
640
614
|
# @return [String] the contact's first name
|
641
615
|
# @!attribute [rw] last_name
|
@@ -659,7 +633,6 @@ module Osm
|
|
659
633
|
# @!attribute [rw] additional_information_labels
|
660
634
|
# @return [DirtyHashy] the labels for the additional information (key is OSM's variable name, value is the label)
|
661
635
|
|
662
|
-
attribute :title, :type => String
|
663
636
|
attribute :first_name, :type => String
|
664
637
|
attribute :last_name, :type => String
|
665
638
|
attribute :address_1, :type => String
|
@@ -673,7 +646,7 @@ module Osm
|
|
673
646
|
attribute :additional_information_labels, :type => Object, :default => DirtyHashy.new
|
674
647
|
|
675
648
|
if ActiveModel::VERSION::MAJOR < 4
|
676
|
-
attr_accessible :
|
649
|
+
attr_accessible :first_name, :last_name,
|
677
650
|
:address_1, :address_2, :address_3, :address_4,
|
678
651
|
:postcode, :phone_1, :phone_2,
|
679
652
|
:additional_information, :additional_information_labels
|
@@ -684,10 +657,10 @@ module Osm
|
|
684
657
|
# @param [Hash] attributes The hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
|
685
658
|
|
686
659
|
# Get the full name
|
687
|
-
# @param [String] seperator What to split the contact's
|
660
|
+
# @param [String] seperator What to split the contact's first name and last name with
|
688
661
|
# @return [String] this scout's full name seperated by the optional seperator
|
689
662
|
def name(seperator=' ')
|
690
|
-
return [
|
663
|
+
return [first_name, last_name].select{ |i| !i.blank? }.join(seperator)
|
691
664
|
end
|
692
665
|
|
693
666
|
# Get an array of all phone numbers for the contact
|
@@ -707,7 +680,6 @@ module Osm
|
|
707
680
|
require_ability_to(api, :write, :member, member.section_id)
|
708
681
|
|
709
682
|
attribute_map = {
|
710
|
-
'title' => 'data[title]',
|
711
683
|
'first_name' => 'data[firstname]',
|
712
684
|
'last_name' => 'data[lastname]',
|
713
685
|
'surgery' => 'data[surgery]',
|
data/spec/osm/member_spec.rb
CHANGED
@@ -7,7 +7,6 @@ describe "Member" do
|
|
7
7
|
attributes = {
|
8
8
|
:id => 1,
|
9
9
|
:section_id => 2,
|
10
|
-
:title => 'Title',
|
11
10
|
:first_name => 'First',
|
12
11
|
:last_name => 'Last',
|
13
12
|
:date_of_birth => '2000-01-02',
|
@@ -32,7 +31,6 @@ describe "Member" do
|
|
32
31
|
|
33
32
|
member.id.should == 1
|
34
33
|
member.section_id.should == 2
|
35
|
-
member.title.should == 'Title'
|
36
34
|
member.first_name.should == 'First'
|
37
35
|
member.last_name.should == 'Last'
|
38
36
|
member.date_of_birth.should == Date.new(2000, 1, 2)
|
@@ -60,16 +58,16 @@ describe "Member" do
|
|
60
58
|
|
61
59
|
it "Member" do
|
62
60
|
Osm::Member.new(first_name: 'First').name.should == 'First'
|
61
|
+
Osm::Member.new(last_name: 'Last').name.should == 'Last'
|
63
62
|
Osm::Member.new(first_name: 'First', last_name: 'Last').name.should == 'First Last'
|
64
|
-
Osm::Member.new(
|
65
|
-
Osm::Member.new(title: 'Mr', first_name: 'First', last_name: 'Last').name('*').should == 'Mr.*First*Last'
|
63
|
+
Osm::Member.new(first_name: 'First', last_name: 'Last').name('*').should == 'First*Last'
|
66
64
|
end
|
67
65
|
|
68
66
|
it "Contact" do
|
69
67
|
Osm::Member::Contact.new(first_name: 'First').name.should == 'First'
|
68
|
+
Osm::Member::Contact.new(last_name: 'Last').name.should == 'Last'
|
70
69
|
Osm::Member::Contact.new(first_name: 'First', last_name: 'Last').name.should == 'First Last'
|
71
|
-
Osm::Member::Contact.new(
|
72
|
-
Osm::Member::Contact.new(title: 'Mr', first_name: 'First', last_name: 'Last').name('*').should == 'Mr.*First*Last'
|
70
|
+
Osm::Member::Contact.new(first_name: 'First', last_name: 'Last').name('*').should == 'First*Last'
|
73
71
|
end
|
74
72
|
|
75
73
|
end
|
@@ -177,11 +175,11 @@ describe "Member" do
|
|
177
175
|
'section_id' => 1,
|
178
176
|
'started' => '2006-07-17',
|
179
177
|
'custom_data' => {
|
180
|
-
'1' => {'
|
178
|
+
'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'},
|
181
179
|
'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'},
|
182
180
|
'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'},
|
183
|
-
'4' => {'
|
184
|
-
'5' => {'
|
181
|
+
'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'},
|
182
|
+
'5' => {'4848' => 'Data for 4848'},
|
185
183
|
'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'},
|
186
184
|
'7' => {'34' => 'Unspecified'},
|
187
185
|
},
|
@@ -262,7 +260,6 @@ describe "Member" do
|
|
262
260
|
{'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},
|
263
261
|
]},
|
264
262
|
{'group_id' => 5, 'description' => 'This allows you to add extra information for your members.', 'identifier' => 'customisable_data', 'name' => 'Customisable Data', 'columns' => [
|
265
|
-
{'column_id' => 1, 'group_column_id' => '5_1', 'label' => 'Title', 'varname' => 'title', 'read_only' => 'no', 'required' => 'no', 'type' => 'text', 'width' => 120},
|
266
263
|
{'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},
|
267
264
|
]},
|
268
265
|
{'group_id' => 7, 'description' => '', 'identifier' => 'floating', 'name' => 'Floating', 'columns' => [
|
@@ -278,7 +275,6 @@ describe "Member" do
|
|
278
275
|
member = members[0]
|
279
276
|
member.id.should == 123
|
280
277
|
member.section_id.should == 1
|
281
|
-
member.title.should == 'Mr'
|
282
278
|
member.first_name.should == 'John'
|
283
279
|
member.last_name.should == 'Smith'
|
284
280
|
member.date_of_birth.should == Date.new(2000, 3, 8)
|
@@ -291,8 +287,8 @@ describe "Member" do
|
|
291
287
|
member.joined_movement.should == Date.new(2006, 7, 17)
|
292
288
|
member.started_section.should == Date.new(2008, 7, 12)
|
293
289
|
member.finished_section.should == Date.new(2010, 6, 3)
|
294
|
-
member.additional_information.should == {
|
295
|
-
member.additional_information_labels.should == {
|
290
|
+
member.additional_information.should == {4848 => "Data for 4848"}
|
291
|
+
member.additional_information_labels.should == {4848 => 'Label for 4848'}
|
296
292
|
member.contact.first_name.should == 'John'
|
297
293
|
member.contact.last_name.should == 'Smith'
|
298
294
|
member.contact.address_1.should == 'Address 1'
|
@@ -308,9 +304,8 @@ describe "Member" do
|
|
308
304
|
member.contact.receive_email_1.should == true
|
309
305
|
member.contact.email_2.should == ''
|
310
306
|
member.contact.receive_email_2.should == false
|
311
|
-
member.contact.additional_information.should == {
|
312
|
-
member.contact.additional_information_labels.should == {
|
313
|
-
member.primary_contact.title.should == 'Mrs'
|
307
|
+
member.contact.additional_information.should == {8446=>"Data for 8446"}
|
308
|
+
member.contact.additional_information_labels.should == {8446=>"Label for 8446"}
|
314
309
|
member.primary_contact.first_name.should == 'Primary'
|
315
310
|
member.primary_contact.last_name.should == 'Contact'
|
316
311
|
member.primary_contact.address_1.should == 'Address 1'
|
@@ -326,8 +321,8 @@ describe "Member" do
|
|
326
321
|
member.primary_contact.receive_email_1.should == true
|
327
322
|
member.primary_contact.email_2.should == ''
|
328
323
|
member.primary_contact.receive_email_2.should == false
|
329
|
-
member.primary_contact.additional_information.should == {
|
330
|
-
member.primary_contact.additional_information_labels.should == {
|
324
|
+
member.primary_contact.additional_information.should == {8441=>"Data for 8441"}
|
325
|
+
member.primary_contact.additional_information_labels.should == {8441=>"Label for 8441"}
|
331
326
|
member.secondary_contact.first_name.should == 'Secondary'
|
332
327
|
member.secondary_contact.last_name.should == 'Contact'
|
333
328
|
member.secondary_contact.address_1.should == 'Address 1'
|
@@ -343,8 +338,8 @@ describe "Member" do
|
|
343
338
|
member.secondary_contact.receive_email_1.should == true
|
344
339
|
member.secondary_contact.email_2.should == ''
|
345
340
|
member.secondary_contact.receive_email_2.should == false
|
346
|
-
member.secondary_contact.additional_information.should == {
|
347
|
-
member.secondary_contact.additional_information_labels.should == {
|
341
|
+
member.secondary_contact.additional_information.should == {8442=>"Data for 8442"}
|
342
|
+
member.secondary_contact.additional_information_labels.should == {8442=>"Label for 8442"}
|
348
343
|
member.emergency_contact.first_name.should == 'Emergency'
|
349
344
|
member.emergency_contact.last_name.should == 'Contact'
|
350
345
|
member.emergency_contact.address_1.should == 'Address 1'
|
@@ -356,9 +351,8 @@ describe "Member" do
|
|
356
351
|
member.emergency_contact.phone_2.should == '0987 654321'
|
357
352
|
member.emergency_contact.email_1.should == 'emergency@example.com'
|
358
353
|
member.emergency_contact.email_2.should == ''
|
359
|
-
member.emergency_contact.additional_information.should == {
|
360
|
-
member.emergency_contact.additional_information_labels.should == {
|
361
|
-
member.doctor.title.should == 'Dr'
|
354
|
+
member.emergency_contact.additional_information.should == {8443=>"Data for 8443"}
|
355
|
+
member.emergency_contact.additional_information_labels.should == {8443=>"Label for 8443"}
|
362
356
|
member.doctor.first_name.should == 'Doctor'
|
363
357
|
member.doctor.last_name.should == 'Contact'
|
364
358
|
member.doctor.surgery.should == 'Surgery'
|
@@ -369,8 +363,8 @@ describe "Member" do
|
|
369
363
|
member.doctor.postcode.should == 'Postcode'
|
370
364
|
member.doctor.phone_1.should == '01234 567890'
|
371
365
|
member.doctor.phone_2.should == '0987 654321'
|
372
|
-
member.doctor.additional_information.should == {
|
373
|
-
member.doctor.additional_information_labels.should == {
|
366
|
+
member.doctor.additional_information.should == {8444=>"Data for 8444"}
|
367
|
+
member.doctor.additional_information_labels.should == {8444=>"Label for 8444"}
|
374
368
|
member.valid?.should == true
|
375
369
|
end
|
376
370
|
|
@@ -546,7 +540,6 @@ describe "Member" do
|
|
546
540
|
before :each do
|
547
541
|
attributes = {
|
548
542
|
:section_id => 2,
|
549
|
-
:title => 'Title',
|
550
543
|
:first_name => 'First',
|
551
544
|
:last_name => 'Last',
|
552
545
|
:date_of_birth => '2000-01-02',
|
@@ -634,7 +627,6 @@ describe "Member" do
|
|
634
627
|
attributes = {
|
635
628
|
:id => 1,
|
636
629
|
:section_id => 2,
|
637
|
-
:title => 'Title',
|
638
630
|
:first_name => 'First',
|
639
631
|
:last_name => 'Last',
|
640
632
|
:date_of_birth => '2000-01-02',
|
@@ -647,8 +639,8 @@ describe "Member" do
|
|
647
639
|
:joined_movement => '2006-01-02',
|
648
640
|
:started_section => '2006-01-07',
|
649
641
|
:finished_section => '2007-12-31',
|
650
|
-
:additional_information => DirtyHashy[
|
651
|
-
:additional_information_labels => {
|
642
|
+
:additional_information => DirtyHashy[ 123, '123' ],
|
643
|
+
:additional_information_labels => {123 => 'Label for 123'},
|
652
644
|
:contact => Osm::Member::MemberContact.new(postcode: 'A'),
|
653
645
|
:primary_contact => Osm::Member::PrimaryContact.new(postcode: 'B'),
|
654
646
|
:secondary_contact => Osm::Member::SecondaryContact.new(postcode: 'C'),
|
@@ -753,7 +745,7 @@ describe "Member" do
|
|
753
745
|
"associated_type" => "member",
|
754
746
|
"associated_id" => 1,
|
755
747
|
"group_id" => 5,
|
756
|
-
"column_id" =>
|
748
|
+
"column_id" => 123,
|
757
749
|
"value" => "321",
|
758
750
|
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"data":{"value":"321"}}'}) }
|
759
751
|
|
@@ -761,7 +753,7 @@ describe "Member" do
|
|
761
753
|
|
762
754
|
@member.first_name = 'John'
|
763
755
|
@member.gender = :unspecified
|
764
|
-
@member.additional_information[
|
756
|
+
@member.additional_information[123] = '321'
|
765
757
|
@member.contact.address_1 = 'Address 1'
|
766
758
|
@member.primary_contact.address_2 = 'Address 2'
|
767
759
|
@member.secondary_contact.address_3 = 'Address 3'
|
@@ -807,7 +799,7 @@ describe "Member" do
|
|
807
799
|
"associated_type" => "member",
|
808
800
|
"associated_id" => 1,
|
809
801
|
"group_id" => 5,
|
810
|
-
"column_id" =>
|
802
|
+
"column_id" => 123,
|
811
803
|
"value" => "123",
|
812
804
|
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"data":{"value":"123"}}'}) }
|
813
805
|
|
@@ -821,7 +813,6 @@ describe "Member" do
|
|
821
813
|
"associated_type" => "member",
|
822
814
|
"associated_id" => 1,
|
823
815
|
"group_id" => group_id,
|
824
|
-
"data[title]" => nil,
|
825
816
|
"data[firstname]" => nil,
|
826
817
|
"data[lastname]" => nil,
|
827
818
|
"data[address1]" => nil,
|
@@ -849,7 +840,6 @@ describe "Member" do
|
|
849
840
|
"associated_type" => "member",
|
850
841
|
"associated_id" => 1,
|
851
842
|
"group_id" => 3,
|
852
|
-
"data[title]" => nil,
|
853
843
|
"data[firstname]" => nil,
|
854
844
|
"data[lastname]" => nil,
|
855
845
|
"data[address1]" => nil,
|
@@ -872,7 +862,6 @@ describe "Member" do
|
|
872
862
|
"associated_type" => "member",
|
873
863
|
"associated_id" => 1,
|
874
864
|
"group_id" => 4,
|
875
|
-
"data[title]" => nil,
|
876
865
|
"data[firstname]" => nil,
|
877
866
|
"data[lastname]" => nil,
|
878
867
|
"data[surgery]" => nil,
|
@@ -886,19 +875,6 @@ describe "Member" do
|
|
886
875
|
"data[test_var]" => "This is a test",
|
887
876
|
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"status":true}'}) }
|
888
877
|
|
889
|
-
HTTParty.should_receive(:post).with('https://www.onlinescoutmanager.co.uk/ext/customdata/?action=updateColumn§ion_id=2', {:body => {
|
890
|
-
"apiid" => "1",
|
891
|
-
"token" => "API TOKEN",
|
892
|
-
"userid" => "user_id",
|
893
|
-
"secret" => "secret",
|
894
|
-
"context" => "members",
|
895
|
-
"associated_type" => "member",
|
896
|
-
"associated_id" => 1,
|
897
|
-
"group_id" => 5,
|
898
|
-
"column_id" => 1,
|
899
|
-
"value" => "Title",
|
900
|
-
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"data":{"value":"Title"}}'}) }
|
901
|
-
|
902
878
|
Osm::Term.stub(:get_for_section) { [] }
|
903
879
|
|
904
880
|
@member.update(@api, true).should == true
|
data/version.rb
CHANGED