osm 1.2.18.dev.9 → 1.2.18.dev.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWZhOTg0ZjAwNzk1YjE3ZmY0YTJlNjI0ZWRjZmFiMWFkMTc5YTk1OQ==
4
+ NjE5NjExMzM1NDIwMDc5OWQxYjRkNmM2MWE3YzBkZTNlOGE4ZGQ4Nw==
5
5
  data.tar.gz: !binary |-
6
- MGQ3M2MyNTk0MWRlNjNkMmYwNWU2OTc4MjBhYjAxMmQ4OGUxZjE1Nw==
6
+ MWU4NzAwZDE0ZjVkYzhmOGYyNDQwZmZjNGE3MTVlYThlNzFmYzIzMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDkwMjA5NTYyYTRiMTEzMGNiMzNhNzFiM2E2MTEwZmQwNDc1NjE3NDcyYjM2
10
- ZTcxNGQwOTE5YjFhMTU5ZmMyMWQxODNmMTExN2MyNDNjMWIwY2ExMjYxNDdh
11
- OTM3ZmQ3NWEyOWJlMmUxMGMyM2QzMmE4MmE1M2FhNjc1NDIzYzM=
9
+ MmZkZDQ4YjFmMmVkNWY4NGQ0MzFlNzAyZGE0NGRhOTVlYjhkMDdhYjVlNzVh
10
+ NmE2YjYzYWY1ZDYyMzUzNzY2ZTcwODg2MzIzZDU5ZjM5YWViMWJiN2Q4ZTA1
11
+ ZGQ2ZGFiYzFmOWViZDE4MDJkMGRhMWI0NDJkM2FkNzI2ODE5NWY=
12
12
  data.tar.gz: !binary |-
13
- YzhjNDRkZWVlNjdlZjljYWU2ODkyNDZjODliODllYzcyZmI4Y2RiYTBhNTQx
14
- MGRiZWM5YzMyMWI4NzJmYTJhYzc1YzgzNTMxZWMwZmIxM2MzNTcwNGNiNGFk
15
- MDc2OWMzMDFiNTIxNmUwYjE3YTQzMGM4ODQ2YTc4MWUwZmI1ZDc=
13
+ ZWVlN2YyZDRhY2U4OTJiNzcwNzgxZDRlN2RmOWYwODkzYTI3NDA0Yzc4YmE0
14
+ NjBiZWUxNDQzMDQ0ZWY1NjRlYTRkM2VhZmNhZjlhOGY5NjY2NDdmOTI0M2Yy
15
+ MTM3MzQ3YTkwZmM1OTA4MDBhOWMzY2I4ZGE0N2IzYmEzMmUyNmI=
data/CHANGELOG.md CHANGED
@@ -14,6 +14,7 @@
14
14
  * grouping_leader
15
15
  * age
16
16
  * Addition of attibutes:
17
+ * title (String)
17
18
  * gender (Symbol - :male, :female, :other or :unspecified)
18
19
  * finished_section (Date, nil)
19
20
  * additional_information (DirtyHashy) - The customisable data part from OSM
data/lib/osm/member.rb CHANGED
@@ -11,9 +11,7 @@ module Osm
11
11
  GID_FLOATING = 7
12
12
 
13
13
  # Constants for column id
14
- CUSTOM_FIELD_IDS_START_AT = 55
15
- CORE_FIELD_IDS_FINISH_AT = CUSTOM_FIELD_IDS_START_AT - 1
16
- CORE_FIELD_IDS = (1..54).to_a
14
+ CID_TITLE = 1
17
15
  CID_FIRST_NAME = 2
18
16
  CID_LAST_NAME = 3
19
17
  CID_ADDRESS_1 = 7
@@ -31,12 +29,15 @@ module Osm
31
29
  CID_RECIEVE_PHONE_2 = 21
32
30
  CID_GENDER = 34
33
31
  CID_SURGERY = 54
32
+ CORE_FIELD_IDS = (1..21).to_a + [34, 54]
34
33
 
35
34
 
36
35
  # @!attribute [rw] id
37
36
  # @return [Fixnum] the id for the member
38
37
  # @!attribute [rw] section_id
39
38
  # @return [Fixnum] the section the member belongs to
39
+ # @!attribute [rw] title
40
+ # @return [String] the member's title (Mr, Mrs etc.)
40
41
  # @!attribute [rw] first_name
41
42
  # @return [String] the member's first name
42
43
  # @!attribute [rw] last_name
@@ -78,6 +79,7 @@ module Osm
78
79
 
79
80
  attribute :id, :type => Integer
80
81
  attribute :section_id, :type => Integer
82
+ attribute :title, :type => String
81
83
  attribute :first_name, :type => String
82
84
  attribute :last_name, :type => String
83
85
  attribute :grouping_id, :type => Integer
@@ -99,7 +101,8 @@ module Osm
99
101
  attribute :doctor, :type => Object
100
102
 
101
103
  if ActiveModel::VERSION::MAJOR < 4
102
- attr_accessible :id, :section_id, :first_name, :last_name, :grouping_id, :grouping_leader,
104
+ attr_accessible :id, :section_id, :title, :first_name, :last_name,
105
+ :grouping_id, :grouping_leader,
103
106
  :date_of_birth, :started_section, :finished_section, :joined_movement, :age,
104
107
  :grouping_label, :grouping_leader_label, :gender,
105
108
  :additional_information, :additional_information_labels,
@@ -162,29 +165,29 @@ module Osm
162
165
  var_names = {}
163
166
  structure.each do |gid, group|
164
167
  columns = group['columns'] || []
165
- columns.select!{ |a| (gid == GID_CUSTOM) || (a['column_id'].to_i > CORE_FIELD_IDS_FINISH_AT) }
166
- custom_labels[gid.to_i] = Hash[ columns.map{ |c| [c['varname'], c['label']] } ]
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['varname'], c['label']] } ]
167
169
  var_names[gid.to_i] = DirtyHashy[ columns.map{ |c| [c['column_id'].to_i, c['varname']] } ]
168
170
  end
169
171
 
170
172
  data.each do |item|
171
173
  item_data = Hash[ item['custom_data'].map{ |k,v| [k.to_i, v] } ]
172
- 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| k < CUSTOM_FIELD_IDS_START_AT } ]
173
- member_custom = item_data[GID_MEMBER_CONTACT].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_MEMBER_CONTACT].select{ |k,v| k.to_i >= CUSTOM_FIELD_IDS_START_AT }.map{ |k,v| [var_names[GID_MEMBER_CONTACT][k.to_i], v] } ]
174
- 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| k < CUSTOM_FIELD_IDS_START_AT } ]
175
- primary_custom = item_data[GID_PRIMARY_CONTACT].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_PRIMARY_CONTACT].select{ |k,v| k.to_i >= CUSTOM_FIELD_IDS_START_AT }.map{ |k,v| [var_names[GID_PRIMARY_CONTACT][k.to_i], v] } ]
176
- 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| k < CUSTOM_FIELD_IDS_START_AT } ]
177
- secondary_custom = item_data[GID_SECONDARY_CONTACT].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_SECONDARY_CONTACT].select{ |k,v| k.to_i >= CUSTOM_FIELD_IDS_START_AT }.map{ |k,v| [var_names[GID_SECONDARY_CONTACT][k.to_i], v] } ]
178
- 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| k < CUSTOM_FIELD_IDS_START_AT } ]
179
- emergency_custom = item_data[GID_EMERGENCY_CONTACT].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_EMERGENCY_CONTACT].select{ |k,v| k.to_i >= CUSTOM_FIELD_IDS_START_AT }.map{ |k,v| [var_names[GID_EMERGENCY_CONTACT][k.to_i], v] } ]
180
- 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| k < CUSTOM_FIELD_IDS_START_AT } ]
181
- doctor_custom = item_data[GID_DOCTOR_CONTACT].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_DOCTOR_CONTACT].select{ |k,v| k.to_i >= CUSTOM_FIELD_IDS_START_AT }.map{ |k,v| [var_names[GID_DOCTOR_CONTACT][k.to_i], v] } ]
182
- floating_data = item_data[GID_FLOATING].nil? ? {} : Hash[ item_data[GID_FLOATING].map{ |k,v| [k.to_i, v] }.select{ |k,v| k < CUSTOM_FIELD_IDS_START_AT } ]
174
+ 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| !(CORE_FIELD_IDS - [CID_TITLE]).include?(k.to_i) }.map{ |k,v| [var_names[GID_MEMBER_CONTACT][k.to_i], v] } ]
176
+ 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| [var_names[GID_PRIMARY_CONTACT][k.to_i], v] } ]
178
+ 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| [var_names[GID_SECONDARY_CONTACT][k.to_i], v] } ]
180
+ 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| [var_names[GID_EMERGENCY_CONTACT][k.to_i], v] } ]
182
+ 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| [var_names[GID_DOCTOR_CONTACT][k.to_i], v] } ]
184
+ 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) } ]
183
185
  custom_data = item_data[GID_CUSTOM].nil? ? DirtyHashy.new : DirtyHashy[ item_data[GID_CUSTOM].map{ |k,v| [var_names[GID_CUSTOM][k.to_i], v] } ]
184
186
 
185
187
  result.push Osm::Member.new(
186
188
  :id => Osm::to_i_or_nil(item['member_id']),
187
189
  :section_id => Osm::to_i_or_nil(item['section_id']),
190
+ :title => custom_data['title'],
188
191
  :first_name => item['first_name'],
189
192
  :last_name => item['last_name'],
190
193
  :grouping_id => Osm::to_i_or_nil(item['patrol_id']),
@@ -198,6 +201,7 @@ module Osm
198
201
  :joined_movement => Osm::parse_date(item['started']),
199
202
  :gender => {'male'=>:male, 'female'=>:female, 'other'=>:other, 'unspecified'=>:unspecified}[(floating_data[CID_GENDER] || '').downcase],
200
203
  :contact => member_contact.nil? ? nil : MemberContact.new(
204
+ title: member_contact[CID_TITLE],
201
205
  first_name: item['first_name'],
202
206
  last_name: item['last_name'],
203
207
  address_1: member_contact[CID_ADDRESS_1],
@@ -217,6 +221,7 @@ module Osm
217
221
  additional_information_labels: custom_labels[GID_MEMBER_CONTACT],
218
222
  ),
219
223
  :primary_contact => primary_contact.nil? ? nil : PrimaryContact.new(
224
+ title: primary_contact[CID_TITLE],
220
225
  first_name: primary_contact[CID_FIRST_NAME],
221
226
  last_name: primary_contact[CID_LAST_NAME],
222
227
  address_1: primary_contact[CID_ADDRESS_1],
@@ -236,6 +241,7 @@ module Osm
236
241
  additional_information_labels: custom_labels[GID_PRIMARY_CONTACT],
237
242
  ),
238
243
  :secondary_contact => secondary_contact.nil? ? nil : SecondaryContact.new(
244
+ title: secondary_contact[CID_TITLE],
239
245
  first_name: secondary_contact[CID_FIRST_NAME],
240
246
  last_name: secondary_contact[CID_LAST_NAME],
241
247
  address_1: secondary_contact[CID_ADDRESS_1],
@@ -255,6 +261,7 @@ module Osm
255
261
  additional_information_labels: custom_labels[GID_SECONDARY_CONTACT],
256
262
  ),
257
263
  :emergency_contact => emergency_contact.nil? ? nil : EmergencyContact.new(
264
+ title: emergency_contact[CID_TITLE],
258
265
  first_name: emergency_contact[CID_FIRST_NAME],
259
266
  last_name: emergency_contact[CID_LAST_NAME],
260
267
  address_1: emergency_contact[CID_ADDRESS_1],
@@ -270,6 +277,7 @@ module Osm
270
277
  additional_information_labels: custom_labels[GID_EMERGENCY_CONTACT],
271
278
  ),
272
279
  :doctor => doctor_contact.nil? ? nil : DoctorContact.new(
280
+ title: doctor_contact[CID_TITLE],
273
281
  first_name: doctor_contact[CID_FIRST_NAME],
274
282
  last_name: doctor_contact[CID_LAST_NAME],
275
283
  surgery: doctor_contact[CID_SURGERY],
@@ -280,11 +288,11 @@ module Osm
280
288
  postcode: doctor_contact[CID_POSTCODE],
281
289
  phone_1: doctor_contact[CID_PHONE_1],
282
290
  phone_2: doctor_contact[CID_PHONE_2],
283
- additional_information:doctor_custom,
291
+ additional_information: doctor_custom,
284
292
  additional_information_labels: custom_labels[GID_DOCTOR_CONTACT],
285
293
  ),
286
- additional_information: custom_data,
287
- additional_information_labels: custom_labels[GID_CUSTOM],
294
+ additional_information: custom_data.select{ |k,v| ! ['title'].include?(k) },
295
+ additional_information_labels: custom_labels[GID_CUSTOM].select{ |k,v| ! ['title'].include?(k) },
288
296
  )
289
297
  end
290
298
 
@@ -362,6 +370,20 @@ module Osm
362
370
  updated = updated && data.is_a?(Hash) && data['ok'].eql?(true)
363
371
  end # each attr to update
364
372
 
373
+ # Do title attribute
374
+ if force || changed_attributes.include?('title')
375
+ data = api.perform_query("ext/members/contact/?action=update", {
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
+
365
387
  # Do 'floating' attributes
366
388
  if force || changed_attributes.include?('gender')
367
389
  new_value = {male: 'Male', female: 'Female', other: 'Other'}[gender] || 'Unspecified'
@@ -422,10 +444,10 @@ module Osm
422
444
  end
423
445
 
424
446
  # Get the full name
425
- # @param [String] seperator What to split the scout's first name and last name with
447
+ # @param [String] seperator What to split the member's title, first name and last name with
426
448
  # @return [String] this scout's full name seperated by the optional seperator
427
449
  def name(seperator=' ')
428
- return "#{first_name}#{seperator.to_s}#{last_name}"
450
+ return [(title? ? "#{title}." : nil), first_name, last_name].select{ |i| !i.blank? }.join(seperator)
429
451
  end
430
452
 
431
453
  # Check if the member is in the leaders grouping
@@ -613,6 +635,8 @@ module Osm
613
635
 
614
636
 
615
637
  class Contact < Osm::Model
638
+ # @!attribute [rw] title
639
+ # @return [String] the contact's title (Mr, Ms, Dr etc.)
616
640
  # @!attribute [rw] first_name
617
641
  # @return [String] the contact's first name
618
642
  # @!attribute [rw] last_name
@@ -636,6 +660,7 @@ module Osm
636
660
  # @!attribute [rw] additional_information_labels
637
661
  # @return [DirtyHashy] the labels for the additional information (key is OSM's variable name, value is the label)
638
662
 
663
+ attribute :title, :type => String
639
664
  attribute :first_name, :type => String
640
665
  attribute :last_name, :type => String
641
666
  attribute :address_1, :type => String
@@ -649,7 +674,8 @@ module Osm
649
674
  attribute :additional_information_labels, :type => Object, :default => DirtyHashy.new
650
675
 
651
676
  if ActiveModel::VERSION::MAJOR < 4
652
- attr_accessible :first_name, :last_name, :address_1, :address_2, :address_3, :address_4,
677
+ attr_accessible :title, :first_name, :last_name,
678
+ :address_1, :address_2, :address_3, :address_4,
653
679
  :postcode, :phone_1, :phone_2,
654
680
  :additional_information, :additional_information_labels
655
681
  end
@@ -659,10 +685,10 @@ module Osm
659
685
  # @param [Hash] attributes The hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
660
686
 
661
687
  # Get the full name
662
- # @param [String] seperator What to split the scout's first name and last name with
688
+ # @param [String] seperator What to split the contact's title, first name and last name with
663
689
  # @return [String] this scout's full name seperated by the optional seperator
664
690
  def name(seperator=' ')
665
- return "#{first_name}#{seperator.to_s}#{last_name}"
691
+ return [(title? ? "#{title}." : nil), first_name, last_name].select{ |i| !i.blank? }.join(seperator)
666
692
  end
667
693
 
668
694
  # Get an array of all phone numbers for the contact
@@ -682,6 +708,7 @@ module Osm
682
708
  require_ability_to(api, :write, :member, member.section_id)
683
709
 
684
710
  attribute_map = {
711
+ 'title' => 'data[title]',
685
712
  'first_name' => 'data[firstname]',
686
713
  'last_name' => 'data[lastname]',
687
714
  'surgery' => 'data[surgery]',
@@ -828,39 +855,21 @@ module Osm
828
855
  attr_accessible :email_1, :email_2
829
856
  end
830
857
 
831
- # Get the full name
832
- # @param [String] seperator What to split the scout's first name and last name with
833
- # @return [String] this scout's full name seperated by the optional seperator
834
- def name(seperator=' ')
835
- return "#{first_name}#{seperator.to_s}#{last_name}"
836
- end
837
858
  end # class EmergencyContact
838
859
 
839
860
 
840
861
  class DoctorContact < Osm::Member::Contact
841
862
  GROUP_ID = Osm::Member::GID_DOCTOR_CONTACT
842
863
 
843
- # @!attribute [rw] first_name
844
- # @return [String] the contact's first name
845
- # @!attribute [rw] last_name
846
- # @return [String] the contact's last name
847
864
  # @!attribute [rw] surgery
848
865
  # @return [String] the surgery name
849
866
 
850
- attribute :first_name, :type => String
851
- attribute :last_name, :type => String
852
867
  attribute :surgery, :type => String
853
868
 
854
869
  if ActiveModel::VERSION::MAJOR < 4
855
- attr_accessible :first_name, :last_name, :surgery
870
+ attr_accessible :surgery
856
871
  end
857
872
 
858
- # Get the full name
859
- # @param [String] seperator What to split the scout's first name and last name with
860
- # @return [String] this scout's full name seperated by the optional seperator
861
- def name(seperator=' ')
862
- return "Dr. #{first_name}#{seperator.to_s}#{last_name}"
863
- end
864
873
  end # class DoctorContact
865
874
 
866
875
  end # Class Member
@@ -7,6 +7,7 @@ describe "Member" do
7
7
  attributes = {
8
8
  :id => 1,
9
9
  :section_id => 2,
10
+ :title => 'Title',
10
11
  :first_name => 'First',
11
12
  :last_name => 'Last',
12
13
  :date_of_birth => '2000-01-02',
@@ -31,6 +32,7 @@ describe "Member" do
31
32
 
32
33
  member.id.should == 1
33
34
  member.section_id.should == 2
35
+ member.title.should == 'Title'
34
36
  member.first_name.should == 'First'
35
37
  member.last_name.should == 'Last'
36
38
  member.date_of_birth.should == Date.new(2000, 1, 2)
@@ -54,17 +56,25 @@ describe "Member" do
54
56
  end
55
57
 
56
58
 
57
- it "Provides member's full name" do
58
- data = {
59
- :first_name => 'First',
60
- :last_name => 'Last',
61
- }
62
- member = Osm::Member.new(data)
59
+ describe "Provides full name" do
60
+
61
+ it "Member" do
62
+ Osm::Member.new(first_name: 'First').name.should == 'First'
63
+ Osm::Member.new(first_name: 'First', last_name: 'Last').name.should == 'First Last'
64
+ Osm::Member.new(title: 'Mr', first_name: 'First', last_name: 'Last').name.should == 'Mr. First Last'
65
+ Osm::Member.new(title: 'Mr', first_name: 'First', last_name: 'Last').name('*').should == 'Mr.*First*Last'
66
+ end
67
+
68
+ it "Contact" do
69
+ Osm::Member::Contact.new(first_name: 'First').name.should == 'First'
70
+ Osm::Member::Contact.new(first_name: 'First', last_name: 'Last').name.should == 'First Last'
71
+ Osm::Member::Contact.new(title: 'Mr', first_name: 'First', last_name: 'Last').name.should == 'Mr. First Last'
72
+ Osm::Member::Contact.new(title: 'Mr', first_name: 'First', last_name: 'Last').name('*').should == 'Mr.*First*Last'
73
+ end
63
74
 
64
- member.name.should == 'First Last'
65
- member.name('_').should == 'First_Last'
66
75
  end
67
76
 
77
+
68
78
  it "Tells if member is a leader" do
69
79
  Osm::Member.new(grouping_id: -2).leader?.should == true # In the leader grouping
70
80
  Osm::Member.new(grouping_id: 2).leader?.should == false # In a youth grouping
@@ -167,11 +177,11 @@ describe "Member" do
167
177
  'section_id' => 1,
168
178
  'started' => '2006-07-17',
169
179
  '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'},
180
+ '1' => {'1' => 'Mrs', '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
181
  '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
182
  '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'},
183
+ '4' => {'1' => 'Dr', '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'},
184
+ '5' => {'1' => 'Mr', '4848' => 'Data for 4848'},
175
185
  '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
186
  '7' => {'34' => 'Unspecified'},
177
187
  },
@@ -252,6 +262,7 @@ describe "Member" do
252
262
  {'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
263
  ]},
254
264
  {'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},
255
266
  {'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
267
  ]},
257
268
  {'group_id' => 7, 'description' => '', 'identifier' => 'floating', 'name' => 'Floating', 'columns' => [
@@ -267,6 +278,7 @@ describe "Member" do
267
278
  member = members[0]
268
279
  member.id.should == 123
269
280
  member.section_id.should == 1
281
+ member.title.should == 'Mr'
270
282
  member.first_name.should == 'John'
271
283
  member.last_name.should == 'Smith'
272
284
  member.date_of_birth.should == Date.new(2000, 3, 8)
@@ -298,6 +310,7 @@ describe "Member" do
298
310
  member.contact.receive_email_2.should == false
299
311
  member.contact.additional_information.should == {"label_for_8446"=>"Data for 8446"}
300
312
  member.contact.additional_information_labels.should == {"label_for_8446"=>"Label for 8446"}
313
+ member.primary_contact.title.should == 'Mrs'
301
314
  member.primary_contact.first_name.should == 'Primary'
302
315
  member.primary_contact.last_name.should == 'Contact'
303
316
  member.primary_contact.address_1.should == 'Address 1'
@@ -345,6 +358,7 @@ describe "Member" do
345
358
  member.emergency_contact.email_2.should == ''
346
359
  member.emergency_contact.additional_information.should == {"label_for_8443"=>"Data for 8443"}
347
360
  member.emergency_contact.additional_information_labels.should == {"label_for_8443"=>"Label for 8443"}
361
+ member.doctor.title.should == 'Dr'
348
362
  member.doctor.first_name.should == 'Doctor'
349
363
  member.doctor.last_name.should == 'Contact'
350
364
  member.doctor.surgery.should == 'Surgery'
@@ -532,6 +546,7 @@ describe "Member" do
532
546
  before :each do
533
547
  attributes = {
534
548
  :section_id => 2,
549
+ :title => 'Title',
535
550
  :first_name => 'First',
536
551
  :last_name => 'Last',
537
552
  :date_of_birth => '2000-01-02',
@@ -619,6 +634,7 @@ describe "Member" do
619
634
  attributes = {
620
635
  :id => 1,
621
636
  :section_id => 2,
637
+ :title => 'Title',
622
638
  :first_name => 'First',
623
639
  :last_name => 'Last',
624
640
  :date_of_birth => '2000-01-02',
@@ -805,6 +821,7 @@ describe "Member" do
805
821
  "associated_type" => "member",
806
822
  "associated_id" => 1,
807
823
  "group_id" => group_id,
824
+ "data[title]" => nil,
808
825
  "data[firstname]" => nil,
809
826
  "data[lastname]" => nil,
810
827
  "data[address1]" => nil,
@@ -832,6 +849,7 @@ describe "Member" do
832
849
  "associated_type" => "member",
833
850
  "associated_id" => 1,
834
851
  "group_id" => 3,
852
+ "data[title]" => nil,
835
853
  "data[firstname]" => nil,
836
854
  "data[lastname]" => nil,
837
855
  "data[address1]" => nil,
@@ -854,6 +872,7 @@ describe "Member" do
854
872
  "associated_type" => "member",
855
873
  "associated_id" => 1,
856
874
  "group_id" => 4,
875
+ "data[title]" => nil,
857
876
  "data[firstname]" => nil,
858
877
  "data[lastname]" => nil,
859
878
  "data[surgery]" => nil,
@@ -867,6 +886,19 @@ describe "Member" do
867
886
  "data[test_var]" => "This is a test",
868
887
  }}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"status":true}'}) }
869
888
 
889
+ HTTParty.should_receive(:post).with('https://www.onlinescoutmanager.co.uk/ext/members/contact/?action=update', {: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
+
870
902
  Osm::Term.stub(:get_for_section) { [] }
871
903
 
872
904
  @member.update(@api, true).should == true
data/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Osm
2
- VERSION = "1.2.18.dev.9"
2
+ VERSION = "1.2.18.dev.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.18.dev.9
4
+ version: 1.2.18.dev.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Gauld
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-30 00:00:00.000000000 Z
11
+ date: 2015-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport