ucb_ldap 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.irbrc +8 -0
- data/.travis.yml +19 -0
- data/CHANGELOG +8 -0
- data/README.md +27 -15
- data/lib/ucb_ldap.rb +11 -27
- data/lib/ucb_ldap/address.rb +14 -9
- data/lib/ucb_ldap/affiliation.rb +5 -3
- data/lib/ucb_ldap/entry.rb +6 -101
- data/lib/ucb_ldap/job_appointment.rb +22 -13
- data/lib/ucb_ldap/namespace.rb +4 -2
- data/lib/ucb_ldap/person.rb +8 -6
- data/lib/ucb_ldap/person/affiliation_methods.rb +6 -3
- data/lib/ucb_ldap/person/common_attributes.rb +6 -3
- data/lib/ucb_ldap/schema.rb +2 -2
- data/lib/ucb_ldap/schema_attribute.rb +3 -3
- data/lib/ucb_ldap/service.rb +2 -3
- data/lib/ucb_ldap/student_term.rb +34 -19
- data/lib/ucb_ldap/version.rb +1 -1
- data/ucb_ldap.gemspec +8 -5
- metadata +10 -36
- data/spec/rails_binds.yml +0 -9
- data/spec/spec_helper.rb +0 -43
- data/spec/ucb_ldap/address_spec.rb +0 -54
- data/spec/ucb_ldap/affiliation_spec.rb +0 -85
- data/spec/ucb_ldap/entry_spec.rb +0 -241
- data/spec/ucb_ldap/job_appointment_spec.rb +0 -65
- data/spec/ucb_ldap/namespace_spec.rb +0 -72
- data/spec/ucb_ldap/org_spec.rb +0 -217
- data/spec/ucb_ldap/person_spec.rb +0 -225
- data/spec/ucb_ldap/schema_attribute_spec.rb +0 -122
- data/spec/ucb_ldap/schema_spec.rb +0 -104
- data/spec/ucb_ldap/service_spec.rb +0 -127
- data/spec/ucb_ldap/student_term_spec.rb +0 -121
- data/spec/ucb_ldap_spec.rb +0 -182
@@ -1,72 +0,0 @@
|
|
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
|
data/spec/ucb_ldap/org_spec.rb
DELETED
@@ -1,217 +0,0 @@
|
|
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
|
@@ -1,225 +0,0 @@
|
|
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
|
-
|