ucb_ldap 2.0.0.pre1 → 2.0.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/CHANGELOG +137 -135
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/{README → README.md} +82 -80
  7. data/Rakefile +38 -20
  8. data/lib/ucb_ldap.rb +238 -204
  9. data/lib/{ucb_ldap_address.rb → ucb_ldap/address.rb} +106 -106
  10. data/lib/{ucb_ldap_affiliation.rb → ucb_ldap/affiliation.rb} +16 -16
  11. data/lib/{ucb_ldap_entry.rb → ucb_ldap/entry.rb} +455 -448
  12. data/lib/{ucb_ldap_person_job_appointment.rb → ucb_ldap/job_appointment.rb} +77 -79
  13. data/lib/{ucb_ldap_namespace.rb → ucb_ldap/namespace.rb} +40 -50
  14. data/lib/{ucb_ldap_org.rb → ucb_ldap/org.rb} +427 -429
  15. data/lib/{ucb_ldap_person.rb → ucb_ldap/person.rb} +157 -148
  16. data/lib/{person → ucb_ldap/person}/affiliation_methods.rb +23 -22
  17. data/lib/ucb_ldap/person/common_attributes.rb +63 -0
  18. data/lib/{ucb_ldap_schema.rb → ucb_ldap/schema.rb} +28 -28
  19. data/lib/{ucb_ldap_schema_attribute.rb → ucb_ldap/schema_attribute.rb} +152 -153
  20. data/lib/{ucb_ldap_service.rb → ucb_ldap/service.rb} +17 -19
  21. data/lib/{ucb_ldap_student_term.rb → ucb_ldap/student_term.rb} +29 -31
  22. data/lib/ucb_ldap/version.rb +3 -0
  23. data/spec/rails_binds.yml +9 -0
  24. data/spec/spec_helper.rb +43 -0
  25. data/spec/ucb_ldap/address_spec.rb +54 -0
  26. data/spec/ucb_ldap/affiliation_spec.rb +85 -0
  27. data/spec/ucb_ldap/entry_spec.rb +241 -0
  28. data/spec/ucb_ldap/job_appointment_spec.rb +65 -0
  29. data/spec/ucb_ldap/namespace_spec.rb +72 -0
  30. data/spec/ucb_ldap/org_spec.rb +217 -0
  31. data/spec/ucb_ldap/person_spec.rb +225 -0
  32. data/spec/ucb_ldap/schema_attribute_spec.rb +122 -0
  33. data/spec/ucb_ldap/schema_spec.rb +104 -0
  34. data/spec/ucb_ldap/service_spec.rb +127 -0
  35. data/spec/ucb_ldap/student_term_spec.rb +121 -0
  36. data/spec/ucb_ldap_spec.rb +182 -0
  37. data/ucb_ldap.gemspec +20 -27
  38. metadata +113 -64
  39. data/Manifest +0 -23
  40. data/TODO +0 -2
  41. data/lib/person/adv_con_person.rb +0 -0
  42. data/lib/person/generic_attributes.rb +0 -68
  43. data/lib/ucb_ldap_exceptions.rb +0 -27
  44. data/version.yml +0 -1
@@ -0,0 +1,65 @@
1
+ require_relative "../spec_helper"
2
+
3
+
4
+ describe "UCB::LDAP::JobAppointment" do
5
+ before(:all) do
6
+ job_appointment_bind
7
+ @sh_appts = JobAppointment.find_by_uid('61065')
8
+ @sh_appt = @sh_appts.first
9
+ end
10
+
11
+ after(:all) do
12
+ UCB::LDAP.clear_authentication
13
+ end
14
+
15
+ it "should find job appointments by uid" do
16
+ @sh_appts.should be_instance_of(Array)
17
+ @sh_appts.first.should be_instance_of(JobAppointment)
18
+ @sh_appts.size.should == 1
19
+ end
20
+
21
+ it "should return cto code" do
22
+ @sh_appt.cto_code.should == 'F15'
23
+ end
24
+
25
+ it "should return deptid" do
26
+ @sh_appt.deptid.should == 'JKASD'
27
+ end
28
+
29
+ it "should return record number" do
30
+ @sh_appt.record_number.should == 0
31
+ end
32
+
33
+ it "should return Personnel Program Code" do
34
+ @sh_appt.personnel_program_code.should == "2"
35
+ end
36
+
37
+ it "should return primary? flag" do
38
+ @sh_appt.should be_primary
39
+ end
40
+
41
+ it "should return primary? flag" do
42
+ @sh_appt.should be_primary
43
+ end
44
+
45
+ it "should return ERC code" do
46
+ @sh_appt.erc_code.should == "E"
47
+ end
48
+
49
+ it "should return represented? flag" do
50
+ @sh_appt.should_not be_represented
51
+ end
52
+
53
+ it "should return title code" do
54
+ @sh_appt.title_code.should == '0531'
55
+ end
56
+
57
+ it "should return appointment type" do
58
+ @sh_appt.appointment_type.should == '2'
59
+ end
60
+
61
+ it "should return wos? flag" do
62
+ @sh_appt.should_not be_wos
63
+ end
64
+ end
65
+
@@ -0,0 +1,72 @@
1
+ require_relative "../spec_helper"
2
+
3
+
4
+ describe UCB::LDAP::Namespace do
5
+ before(:all) do
6
+ namespace_bind()
7
+ end
8
+
9
+ before(:each) do
10
+ @uid = '61065'
11
+ @cn = 'runner'
12
+ end
13
+
14
+ after(:all) do
15
+ UCB::LDAP.clear_authentication
16
+ end
17
+
18
+ it "should set tree base" do
19
+ Namespace.tree_base.should == 'ou=names,ou=namespace,dc=berkeley,dc=edu'
20
+ end
21
+
22
+ it "should set entity name" do
23
+ Namespace.entity_name.should == "namespaceName"
24
+ end
25
+
26
+ it "should set schema attributes" do
27
+ Namespace.schema_attributes_array.should be_instance_of(Array)
28
+ Namespace.schema_attributes_array[0].should be_instance_of(Schema::Attribute)
29
+ lambda { Namespace.schema_attribute('berkeleyEduServices') }.should_not raise_error
30
+ lambda { Namespace.schema_attribute('bogus') }.should raise_error(BadAttributeNameException)
31
+ end
32
+
33
+ it "should find namespaces by uid and return Array of Namespace" do
34
+ ns = Namespace.find_by_uid(@uid)
35
+ ns.should be_instance_of(Array)
36
+ ns.first.should be_instance_of(Namespace)
37
+ ns.first.uid.should == @uid
38
+ end
39
+
40
+ it "should find namespaces by cn and return single Namespace" do
41
+ ns = Namespace.find_by_cn(@cn)
42
+ ns.class.should == Namespace
43
+ ns.name.should == @cn
44
+ ns.uid.should == @uid
45
+ end
46
+ end
47
+
48
+
49
+ describe "UCB::LDAP::Namespace instance" do
50
+ before(:all) do
51
+ namespace_bind()
52
+ @cn = 'runner'
53
+ @n = Namespace.find_by_cn(@cn)
54
+ end
55
+
56
+ after(:all) do
57
+ UCB::LDAP.clear_authentication
58
+ end
59
+
60
+ it "should return uid as scalar" do
61
+ @n.uid.should == '61065'
62
+ end
63
+
64
+ it "should return name as scalar" do
65
+ @n.name.should == @cn
66
+ end
67
+
68
+ it "should return services as an array" do
69
+ @n.services.class.should == Array
70
+ @n.services.should == ['calmail', "calnet"]
71
+ end
72
+ end
@@ -0,0 +1,217 @@
1
+ require_relative "../spec_helper"
2
+
3
+
4
+ describe UCB::LDAP::Org do
5
+ before(:all) do
6
+ # when fetching > 200 entries, we need to point to production
7
+ UCB::LDAP.host = UCB::LDAP::HOST_PRODUCTION
8
+ end
9
+
10
+ after(:all) do
11
+ # revert to test host in case suite of specs are being run
12
+ UCB::LDAP.host = HOST_TEST
13
+ end
14
+
15
+ it "should set tree base" do
16
+ UCB::LDAP::Org.tree_base.should == 'ou=org units,dc=berkeley,dc=edu'
17
+ end
18
+
19
+ it "should set entity name" do
20
+ UCB::LDAP::Org.entity_name.should == "org"
21
+ end
22
+
23
+ it "should set schema attributes" do
24
+ UCB::LDAP::Org.schema_attributes_array.should be_instance_of(Array)
25
+ UCB::LDAP::Org.schema_attributes_array[0].should be_instance_of(UCB::LDAP::Schema::Attribute)
26
+ ou_attr = UCB::LDAP::Org.schema_attribute(:ou)
27
+ end
28
+
29
+ it "find_by_ou should fetch Org instance" do
30
+ UCB::LDAP::Org.clear_all_nodes
31
+ e = UCB::LDAP::Org.find_by_ou('jkasd')
32
+ e.should be_instance_of(UCB::LDAP::Org)
33
+ e.ou.should == ['JKASD']
34
+ # verify cache empty
35
+ UCB::LDAP::Org.all_nodes_i.should be_nil
36
+ end
37
+
38
+ it 'org_by_ou is alias for find_by_ou' do
39
+ e = UCB::LDAP::Org.org_by_ou('jkasd')
40
+ e.should be_instance_of(UCB::LDAP::Org)
41
+ end
42
+
43
+ it 'search should return Array of UCB::LDAP::Org' do
44
+ entries = UCB::LDAP::Org.search(:filter => {:ou => 'jkasd'})
45
+ entries.should be_instance_of(Array)
46
+ entries[0].should be_instance_of(UCB::LDAP::Org)
47
+ end
48
+
49
+ it 'root_node should return the root node' do
50
+ UCB::LDAP::Org.root_node.deptid.should == 'UCBKL'
51
+ end
52
+
53
+ it "should load_all_nodes" do
54
+ UCB::LDAP::Org.clear_all_nodes
55
+ UCB::LDAP::Org.all_nodes_i.should be_nil
56
+ UCB::LDAP::Org.load_all_nodes
57
+ UCB::LDAP::Org.all_nodes_i.should have_at_least(1000).keys
58
+ end
59
+
60
+ it "should return Array of all org nodes when sent all_nodes()" do
61
+ all_nodes = UCB::LDAP::Org.all_nodes
62
+ all_nodes.should have_at_least(1000).keys
63
+ all_nodes[all_nodes.keys.first].should be_instance_of(UCB::LDAP::Org)
64
+ end
65
+
66
+ it "should cache the org tree" do
67
+ UCB::LDAP::Org.clear_all_nodes
68
+ UCB::LDAP::Org.all_nodes_i.should be_nil
69
+ UCB::LDAP::Org.all_nodes
70
+ UCB::LDAP::Org.all_nodes_i.should_not be_nil
71
+ # In the future, additional nodes may be added or deleted directly beneath
72
+ # the root node, in which case this test would fail need to be altered.
73
+ UCB::LDAP::Org.root_node.child_nodes_i.should have(14).keys
74
+ end
75
+
76
+ it "should be able to fetch orgs from cache" do
77
+ UCB::LDAP::Org.clear_all_nodes
78
+ UCB::LDAP::Org.find_by_ou_from_cache("jkasd").should be_nil
79
+ UCB::LDAP::Org.all_nodes # forces load of cache
80
+ UCB::LDAP::Org.find_by_ou_from_cache("jkasd").deptid.should == 'JKASD'
81
+ end
82
+
83
+ it "should return flattened_tree" do
84
+ UCB::LDAP::Org.flattened_tree.should be_instance_of(Array)
85
+ UCB::LDAP::Org.flattened_tree.size.should == UCB::LDAP::Org.all_nodes.keys.size
86
+ UCB::LDAP::Org.flattened_tree.first.should equal(UCB::LDAP::Org.root_node)
87
+ end
88
+
89
+ it "should return flattened_tree down to certain level" do
90
+ UCB::LDAP::Org.flattened_tree.map { |o| o.level }.sort.last.should == 6
91
+ UCB::LDAP::Org.flattened_tree(:level => 4).map { |o| o.level }.sort.last.should == 4
92
+ end
93
+ end
94
+
95
+
96
+ describe "UCB::LDAP::Org instance" do
97
+ before(:all) { UCB::LDAP.host = UCB::LDAP::HOST_PRODUCTION }
98
+ after(:all) { UCB::LDAP.host = HOST_TEST }
99
+
100
+ before(:each) do
101
+ @e = UCB::LDAP::Org.find_by_ou('jkasd')
102
+ end
103
+
104
+ it "should return deptid" do
105
+ @e.deptid.should == 'JKASD'
106
+ @e.ou.should == ['JKASD']
107
+ end
108
+
109
+ it "should return name" do
110
+ @e.name.should == 'Enterprise Application Service'
111
+ end
112
+
113
+ it "should return processing_unit?" do
114
+ UCB::LDAP::Org.find_by_ou('UCBKL').should_not be_processing_unit
115
+ UCB::LDAP::Org.find_by_ou('jkasd').should_not be_processing_unit
116
+ UCB::LDAP::Org.find_by_ou('jkweb').should be_processing_unit
117
+ end
118
+
119
+ it "should return parent_deptids" do
120
+ @e.parent_deptids.should == %w{UCBKL AVCIS VRIST}
121
+ end
122
+
123
+ it "should return parent_deptid" do
124
+ UCB::LDAP::Org.find_by_ou("avcis").parent_deptid.should == 'UCBKL'
125
+ end
126
+
127
+ it "should return level" do
128
+ @e.level.should == 4
129
+ end
130
+
131
+ it "should return parent_node" do
132
+ @e.parent_node.deptid.should == 'VRIST'
133
+ UCB::LDAP::Org.root_node.parent_node.should be_nil
134
+ end
135
+
136
+ it "should return parent_nodes" do
137
+ @e.parent_deptids.should == @e.parent_nodes.map{|n| n.deptid}
138
+ end
139
+
140
+ it "should return child_nodes" do
141
+ r = UCB::LDAP::Org.root_node
142
+ r.child_nodes.should have(14).items
143
+ r.child_nodes.first.deptid.should == 'AVCIS'
144
+ r.child_nodes.last.deptid.should == 'VCURL'
145
+
146
+ # test_push_child_node
147
+ o = UCB::LDAP::Org.new({})
148
+ o.child_nodes_i.should be_nil
149
+
150
+ # add 1
151
+ o.push_child_node(@e)
152
+ o.should have(1).child_nodes_i
153
+
154
+ # add another
155
+ o.push_child_node(UCB::LDAP::Org.find_by_ou('VCURL'))
156
+ o.should have(2).child_nodes_i
157
+
158
+ # can't add one a second time
159
+ o.push_child_node(UCB::LDAP::Org.find_by_ou('VCURL'))
160
+ o.should have(2).child_nodes_i
161
+ end
162
+
163
+ it "should return child_nodes sorted by deptid" do
164
+ UCB::LDAP::Org.root_node.child_nodes.should == UCB::LDAP::Org.root_node.child_nodes.sort_by { |n| n.deptid }
165
+ end
166
+
167
+ it "should load department persons" do
168
+ org = UCB::LDAP::Org.find_by_ou('JFAVC')
169
+ org.persons.first.should be_instance_of(UCB::LDAP::Person)
170
+ org.persons.first.deptid.should == 'JFAVC'
171
+ end
172
+ end
173
+
174
+
175
+ describe "UCB::LDAP::Org levels" do
176
+ before(:all) do
177
+ UCB::LDAP.host = UCB::LDAP::HOST_PRODUCTION
178
+ @okliv = UCB::LDAP::Org.find_by_ou('okliv')
179
+ @root = UCB::LDAP::Org.root_node
180
+ end
181
+
182
+ after(:all) do
183
+ UCB::LDAP.host = HOST_TEST
184
+ end
185
+
186
+ it "should return level_1_org_code, level_1_org_description" do
187
+ @okliv.level_1_code.should == 'UCBKL'
188
+ @okliv.level_1_name.should == 'UC Berkeley Campus'
189
+ end
190
+
191
+ it "should return level_2_org_code, level_2_org_description" do
192
+ @okliv.level_2_code.should == 'VCUGA'
193
+ @okliv.level_2_name.should_not be_nil
194
+ @root.level_2_code.should be_nil
195
+ @root.level_2_name.should be_nil
196
+ end
197
+
198
+ it "should return level_3_org_code, level_3_org_description" do
199
+ @okliv.level_3_code.should == 'UG1VC'
200
+ @okliv.level_3_name.should_not be_nil
201
+ end
202
+
203
+ it "should return level_4_org_code, level_4_org_description" do
204
+ @okliv.level_4_code.should == 'OKLHS'
205
+ @okliv.level_4_name.should_not be_nil
206
+ end
207
+
208
+ it "should return level_5_org_code, level_5_org_description" do
209
+ @okliv.level_5_code.should == 'OKCUR'
210
+ @okliv.level_5_name.should_not be_nil
211
+ end
212
+
213
+ it "should return level_6_org_code, level_6_org_description" do
214
+ @okliv.level_6_code.should == 'OKLIV'
215
+ @okliv.level_6_name.should_not be_nil
216
+ end
217
+ end
@@ -0,0 +1,225 @@
1
+ require_relative "../spec_helper"
2
+
3
+
4
+ describe UCB::LDAP::Person, "searching for test entries" do
5
+ it "excludes test entries by default" do
6
+ Person.instance_variable_set(:@include_test_entries, nil)
7
+ Person.include_test_entries?.should be_false
8
+ Person.find_by_uid("212387").should be_nil
9
+ end
10
+
11
+ it "allows for test entries to be included" do
12
+ Person.include_test_entries = true
13
+ Person.include_test_entries?.should be_true
14
+ Person.find_by_uid("212387").uid.should == "212387"
15
+ end
16
+ end
17
+
18
+
19
+ describe UCB::LDAP::Person do
20
+ before(:all) do
21
+ Person.include_test_entries = true
22
+ @staff = Person.find_by_uid "212387"
23
+ @student = Person.find_by_uid "232588"
24
+ end
25
+
26
+ it "constructor should return Person instances" do
27
+ @staff.should be_instance_of(Person)
28
+ @student.should be_instance_of(Person)
29
+ end
30
+
31
+ it "persons_by_uid should return Array of Person" do
32
+ persons = Person.find_by_uids ['212386', '212387']
33
+ persons.should be_instance_of(Array)
34
+ persons.should have(2).items
35
+ persons[0].should be_instance_of(Person)
36
+ persons[0].uid.should == '212386'
37
+ persons[1].uid.should == '212387'
38
+
39
+ Person.persons_by_uids([]).should == []
40
+ end
41
+
42
+ it "find_by_uid(s) is an alias for person(s)_by_uid" do
43
+ Person.respond_to?(:find_by_uids).should be_true
44
+ Person.respond_to?(:find_by_uid).should be_true
45
+ end
46
+
47
+ it "find_by_uid works with a String or an Integer" do
48
+ staff_from_int_uid = Person.find_by_uid(212387)
49
+ staff_from_int_uid.uid.should == @staff.uid
50
+ end
51
+ end
52
+
53
+
54
+ describe "UCB::LDAP::Person instance" do
55
+ before(:all) do
56
+ UCB::LDAP::Person.include_test_entries = true
57
+ @staff = Person.find_by_uid("212387")
58
+ @student = Person.find_by_uid("232588")
59
+ end
60
+
61
+ it "should know if an person is a test entry" do
62
+ @staff.test?.should be_true
63
+ Person.find_by_uid('61065').test?.should_not be_true
64
+ end
65
+
66
+ it "should return uid as scalar" do
67
+ @staff.uid.should == "212387"
68
+ end
69
+
70
+ it "should return firstname and first_name as (scalar) synonyms for givenname" do
71
+ @staff.givenname.should == ['EMP-STAFF']
72
+ @staff.firstname.should == 'EMP-STAFF'
73
+ @staff.first_name.should == 'EMP-STAFF'
74
+ end
75
+
76
+ it "should return lastname and last_name as (scalar) synonyms for sn" do
77
+ @staff.sn.should == ['TEST']
78
+ @staff.lastname.should == 'TEST'
79
+ @staff.last_name.should == 'TEST'
80
+ end
81
+
82
+ it "should return email as scalar synonym for mail" do
83
+ @staff.mail.should == %w(test-212387@berkeley.edu)
84
+ @staff.email.should == 'test-212387@berkeley.edu'
85
+ end
86
+
87
+ it "should return phone as scalar synonym for telephoneNumber" do
88
+ @staff.telephoneNumber.should == ['+1 (510) 643-1234']
89
+ @staff.phone.should == '+1 (510) 643-1234'
90
+ end
91
+
92
+ it "should return deptid, dept_code as scalar synonym for berkeleyEduPrimaryDeptUnit" do
93
+ @staff.berkeleyEduPrimaryDeptUnit.should == 'JICCS'
94
+ @staff.deptid.should == 'JICCS'
95
+ @staff.dept_code.should == 'JICCS'
96
+ end
97
+
98
+ it "should return dept_name as scalar synonym for berkeleyEduUnitCalNetDeptName" do
99
+ # here we aren't using a test entry as no test entires have values
100
+ # for the below attributes
101
+ p = UCB::LDAP::Person.find_by_uid(61065)
102
+ p.berkeleyEduUnitCalNetDeptName.should == "IST-Application Services"
103
+ p.dept_name.should == "IST-Application Services"
104
+ end
105
+
106
+ it "should return org_node (UCB::LDAP::Org instance)" do
107
+ @staff.org_node.should be_instance_of(Org)
108
+ @staff.org_node.deptid.should == 'JICCS'
109
+ end
110
+
111
+ it "should return affiliations" do
112
+ @staff.affiliations.should include('EMPLOYEE-TYPE-STAFF')
113
+ @student.affiliations.should include('STUDENT-TYPE-REGISTERED')
114
+
115
+ @staff.has_affiliation?("bogus").should be_false
116
+ @staff.has_affiliation?('EMPLOYEE-TYPE-STAFF').should be_true
117
+ @staff.has_affiliation?('employee-type-staff').should be_true
118
+
119
+ @student.has_affiliation?("bogus").should be_false
120
+ @student.has_affiliation?('STUDENT-TYPE-REGISTERED').should be_true
121
+ @student.has_affiliation?('student-type-registered').should be_true
122
+ end
123
+
124
+ it "should return has_affiliation_of_type?()" do
125
+ Person.new({}).has_affiliation_of_type?(:affiliate).should be_false
126
+ Person.new({:berkeleyEduAffiliations => ["AFFILIATE-TYPE-FOO"]}).has_affiliation_of_type?(:affiliate).should be_true
127
+ end
128
+
129
+ it "should return addresses" do
130
+ address_bind()
131
+ Person.find_by_uid('61065').addresses.first.should be_instance_of(Address)
132
+ UCB::LDAP.clear_authentication
133
+ end
134
+
135
+ it "should return job appointments" do
136
+ job_appointment_bind()
137
+ Person.find_by_uid('61065').job_appointments.first.should be_instance_of(JobAppointment)
138
+ UCB::LDAP.clear_authentication
139
+ end
140
+
141
+ it "should return namespaces" do
142
+ namespace_bind()
143
+ Person.find_by_uid('61065').namespaces.first.class.should == Namespace
144
+ UCB::LDAP.clear_authentication
145
+ end
146
+ end
147
+
148
+
149
+ describe "Employee" do
150
+ it "should return employee_staff?" do
151
+ Person.new(:berkeleyEduAffiliations => ["EMPLOYEE-TYPE-STAFF"]).should be_employee_staff
152
+ Person.new({}).should_not be_employee_staff
153
+ end
154
+
155
+ it "should return employee_academic?" do
156
+ Person.new(:berkeleyEduAffiliations => ["EMPLOYEE-TYPE-ACADEMIC"]).should be_employee_academic
157
+ Person.new({}).should_not be_employee_academic
158
+ end
159
+
160
+ it "should return employee_expired?" do
161
+ Person.new(:berkeleyEduAffiliations => ["EMPLOYEE-STATUS-EXPIRED"]).should be_employee_expired
162
+ Person.new({}).should_not be_employee_expired
163
+ end
164
+
165
+ it "should return employee?" do
166
+ Person.new({}).should_not be_employee
167
+ Person.new(:berkeleyEduAffiliations => ["EMPLOYEE-TYPE-STAFF"]).should be_employee
168
+ Person.new(:berkeleyEduAffiliations => ["EMPLOYEE-TYPE-ACADEMIC"]).should be_employee
169
+ Person.new(:berkeleyEduAffiliations => ["EMPLOYEE-TYPE-STAFF", "EMPLOYEE-STATUS-EXPIRED"]).should_not be_employee
170
+ end
171
+
172
+ it "should return employee_expiration_date" do
173
+ p = Person.new({:berkeleyEduEmpExpDate => ['20000102080000Z']})
174
+ p.employee_expiration_date.to_s.should == '2000-01-02'
175
+ end
176
+ end
177
+
178
+
179
+ describe "Student" do
180
+ it "should return student_registered?" do
181
+ Person.new({}).should_not be_student_registered
182
+ Person.new(:berkeleyEduAffiliations => ["STUDENT-TYPE-REGISTERED"]).should be_student_registered
183
+ end
184
+
185
+ it "should return student_not_registered?" do
186
+ Person.new({}).should_not be_student_not_registered
187
+ Person.new(:berkeleyEduAffiliations => ["STUDENT-TYPE-NOT REGISTERED"]).should be_student_not_registered
188
+ end
189
+
190
+ it "should return student_expired?" do
191
+ Person.new({}).should_not be_student_expired
192
+ Person.new(:berkeleyEduAffiliations => ["STUDENT-STATUS-EXPIRED"]).should be_student_expired
193
+ end
194
+
195
+ it "should return student?" do
196
+ Person.new({}).should_not be_student
197
+ Person.new(:berkeleyEduAffiliations => ["STUDENT-TYPE-FOO"]).should be_student
198
+ Person.new(:berkeleyEduAffiliations => ["STUDENT-TYPE-FOO", "STUDENT-STATUS-EXPIRED"]).should_not be_student
199
+ end
200
+
201
+ it "should return student_expiration_date()" do
202
+ student = Person.new(:berkeleyEduStuExpDate => ['20070912080000Z'])
203
+ student.student_expiration_date.to_s.should == '2007-09-12'
204
+ end
205
+ end
206
+
207
+
208
+ describe "Affiliate" do
209
+ it "should return affiliate?" do
210
+ Person.new({}).should_not be_affiliate
211
+ Person.new(:berkeleyEduAffiliations => ["AFFILIATE-TYPE-FOO"]).should be_affiliate
212
+ Person.new(:berkeleyEduAffiliations => ["AFFILIATE-TYPE-FOO", "AFFILIATE-STATUS-EXPIRED"]).should_not be_affiliate
213
+ end
214
+
215
+ it "should return affiliate_expiration_date()" do
216
+ student = Person.new(:berkeleyEduAffExpDate => ['20070912080000Z'])
217
+ student.affiliate_expiration_date.to_s.should == '2007-09-12'
218
+ end
219
+
220
+ it "should return affiliate_expired?" do
221
+ Person.new({}).should_not be_affiliate_expired
222
+ Person.new(:berkeleyEduAffiliations => ["AFFILIATE-STATUS-EXPIRED"]).should be_affiliate_expired
223
+ end
224
+ end
225
+