dm-ldap-adapter 0.3.5 → 0.4.0.alpha2

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.
@@ -1,185 +1,160 @@
1
1
  $LOAD_PATH << File.dirname(__FILE__)
2
2
  require 'spec_helper'
3
3
 
4
- [
5
- :default,
6
- :ldap,
7
- :memory
8
- ].each do |adapter|
9
-
10
- puts "#{DataMapper.repository(adapter).adapter.class.name}"
11
-
12
- describe "A #{DataMapper.repository(adapter).adapter.class.name}" do
13
-
14
- before(:each) do
15
- DataMapper.repository(adapter) do
16
- @user1 = User.create(:login => "black", :name => 'Black', :age => 0)
17
- @user2 = User.create(:login => "brown", :name => 'Brown', :age => 25)
18
- @user3 = User.create(:login => "blue", :name => 'Blue', :age => nil)
19
- end
20
- end
21
-
22
- after(:each) do
23
- DataMapper.repository(adapter) do
24
- @user1.destroy
25
- @user2.destroy
26
- @user3.destroy
27
- end
4
+ describe DataMapper::Adapters::LdapAdapter do
5
+
6
+ before(:each) do
7
+ DataMapper.repository(:ldap) do
8
+ User.all.destroy!
9
+ @user1 = User.create(:login => "black", :name => 'Black', :age => 0)
10
+ @user2 = User.create(:login => "brown", :name => 'Brown', :age => 25)
11
+ @user3 = User.create(:login => "blue", :name => 'Blue', :age => nil)
28
12
  end
13
+ end
29
14
 
30
- it 'should create an uid' do
31
- class User
32
- # put the assert here
33
- dn_prefix { |user| user.id.should_not == nil; "uid=#{user.login}"}
34
- end
15
+ it 'should create an uid' do
16
+ class User
17
+ # put the assert here
18
+ dn_prefix { |user| user.id.should_not == nil; "uid=#{user.login}"}
19
+ end
35
20
 
36
- DataMapper.repository(adapter) do
37
- id = @user1.id
38
- @user1.destroy
39
- @user1 = User.create(:login => "black", :name => 'Black', :age => 0)
40
- @user1.id.should_not == id
41
- end
21
+ DataMapper.repository(:ldap) do
22
+ id = @user1.id
23
+ @user1.destroy
24
+ @user1 = User.create(:login => "black", :name => 'Black', :age => 0)
25
+ @user1.id.should_not == id
42
26
  end
27
+ end
43
28
 
44
- it 'should successfully save an object' do
45
- DataMapper.repository(adapter) do
46
- @user1.new_record?.should be_false
47
- User.first(:login => @user1.login).new_record?.should be_false
48
- end
29
+ it 'should successfully save an object' do
30
+ DataMapper.repository(:ldap) do
31
+ @user1.new?.should be_false
32
+ User.first(:login => @user1.login).new?.should be_false
49
33
  end
34
+ end
50
35
 
51
- it 'should raise an error when trying to create an entity with already used key' do
52
- DataMapper.repository(adapter) do
53
- #p User.first(:login => "black")
54
- lambda { User.create(:login => "black", :name => 'Black', :age => 0) }.should raise_error
36
+ it 'should raise an error when trying to create an entity with already used key' do
37
+ DataMapper.repository(:ldap) do
38
+ #p User.first(:login => "black")
39
+ lambda { User.create(:login => "black", :name => 'Black', :age => 0) }.should raise_error
55
40
  #p User.all
56
- end
57
41
  end
42
+ end
58
43
 
59
- it 'should be able to get all the objects' do
60
- DataMapper.repository(adapter) do
61
- User.all(:login.like => "b%").should == [@user1, @user2, @user3]
62
- end
44
+ it 'should be able to get all the objects' do
45
+ DataMapper.repository(:ldap) do
46
+ User.all(:login.like => "b%").should == [@user1, @user2, @user3]
47
+ end
48
+ end
49
+
50
+ it 'should be able to search with empty result' do
51
+ DataMapper.repository(:ldap) do
52
+ User.all(:name => "blablublo").should == []
63
53
  end
54
+ end
64
55
 
65
- it 'should be able to search for objects with equal value' do
66
- DataMapper.repository(adapter) do
67
- User.all(:name => "Brown").should == [@user2]
68
- User.all(:age => 25).should == [@user2]
69
- end
56
+ it 'should be able to search for objects with equal value' do
57
+ DataMapper.repository(:ldap) do
58
+ User.all(:name => "Brown").should == [@user2]
59
+ User.all(:age => 25).should == [@user2]
70
60
  end
61
+ end
71
62
 
72
- it 'should be able to search for objects included in an array of values' do
73
- DataMapper.repository(adapter) do
74
- User.all(:age => [ 25, 50, 75, 100 ]).should == [@user2]
75
- end
63
+ it 'should be able to search for objects included in an array of values' do
64
+ DataMapper.repository(:ldap) do
65
+ User.all(:age => [ 25, 50, 75, 100 ]).should == [@user2]
76
66
  end
67
+ end
77
68
 
78
- #it 'should be able to search for objects included in a range of values' do
79
- # User.all(:age => 25..100).should == [@user2]
80
- #end
69
+ #it 'should be able to search for objects included in a range of values' do
70
+ # User.all(:age => 25..100).should == [@user2]
71
+ #end
81
72
 
82
- it 'should be able to search for objects with nil value' do
83
- DataMapper.repository(adapter) do
84
- User.all(:age => nil, :name.like => "B%").should == [@user3]
85
- end
73
+ it 'should be able to search for objects with nil value' do
74
+ DataMapper.repository(:ldap) do
75
+ User.all(:age => nil, :name.like => "B%").should == [@user3]
86
76
  end
77
+ end
87
78
 
88
- if adapter != :default
89
- it 'should be able to search for objects with not equal value' do
90
- DataMapper.repository(adapter) do
91
- User.all(:age.not => 25, :name.like => "B%").should == [@user1, @user3]
92
- end
93
- end
94
-
95
- it 'should be able to search for objects not included in an array of values' do
96
- DataMapper.repository(adapter) do
97
- User.all(:age.not => [ 25, 50, 75, 100 ], :name.like => "B%").should == [@user1, @user3]
98
- end
99
- end
100
- else
101
- puts
102
- puts "NOTE"
103
- puts "=================================================="
104
- puts
105
- puts "sqlite3 handles NULL different from values, i.e."
106
- puts "select * from users where name = 'sd';"
107
- puts "and"
108
- puts "select * from users where name != 'sd';"
109
- puts "gives the same result when all names are NULL !!!"
110
- puts
111
- puts "=================================================="
112
- puts
113
- end
114
-
115
- it 'should be able to search for objects with not equal value' do
116
- DataMapper.repository(adapter) do
117
- User.all(:age.not => nil, :name.like => "B%").should == [@user1, @user2]
118
- end
79
+ it 'should be able to search for objects with not equal value' do
80
+ DataMapper.repository(:ldap) do
81
+ User.all(:age.not => 25, :name.like => "B%").should == [@user1, @user3]
82
+ end
83
+ end
84
+
85
+ it 'should be able to search for objects not included in an array of values' do
86
+ DataMapper.repository(:ldap) do
87
+ User.all(:age.not => [ 25, 50, 75, 100 ], :name.like => "B%").should == [@user1, @user3]
119
88
  end
89
+ end
120
90
 
121
- it 'should search objects with or conditions' do
122
- if adapter == :ldap
123
- DataMapper.repository(adapter) do
124
- User.all(:age.not => nil, :conditions => ["name='Black' or name='Blue'"]).should == [@user1]
125
- User.all(:age.not => nil, :conditions => ["name='Black' or name='Brown'"]).should == [@user1, @user2]
126
- User.all(:age => nil, :conditions => ["name='Black' or name='Brown'"]).should == []
127
- User.all(:age => nil, :conditions => ["name='Black' or name='Brown' or name='Blue'"]).should == [@user3]
128
- User.all(:conditions => ["name='Black' or name='Brown' or name='Blue'"]).should == [@user1, @user2, @user3]
129
- User.all(:conditions => ["name='Black'"]).should == [@user1]
130
- User.all(:conditions => ["name like 'Bl%'"]).should == [@user1, @user3]
131
- User.all(:conditions => ["name like 'B%'"]).should == [@user1, @user2, @user3]
132
- User.all(:conditions => ["name like 'X%X_X'"]).should == []
133
- User.all(:conditions => ["name like 'Bla%' or name like 'Br%'"]).should == [@user1, @user2]
134
- end
135
- end
91
+ it 'should be able to search for objects with not equal value' do
92
+ DataMapper.repository(:ldap) do
93
+ User.all(:age.not => nil, :name.like => "B%").should == [@user1, @user2]
136
94
  end
95
+ end
137
96
 
97
+ it 'should search objects with or conditions' do
98
+ DataMapper.repository(:ldap) do
99
+ User.all(:age.not => nil, :conditions => ["name='Black' or name='Blue'"]).should == [@user1]
100
+ User.all(:age.not => nil, :conditions => ["name='Black' or name='Brown'"]).should == [@user1, @user2]
101
+ User.all(:age => nil, :conditions => ["name='Black' or name='Brown'"]).should == []
102
+ User.all(:age => nil, :conditions => ["name='Black' or name='Brown' or name='Blue'"]).should == [@user3]
103
+ User.all(:conditions => ["name='Black' or name='Brown' or name='Blue'"]).should == [@user1, @user2, @user3]
104
+ User.all(:conditions => ["name='Black'"]).should == [@user1]
105
+ User.all(:conditions => ["name like 'Bl%'"]).should == [@user1, @user3]
106
+ User.all(:conditions => ["name like 'B%'"]).should == [@user1, @user2, @user3]
107
+ User.all(:conditions => ["name like 'X%X_X'"]).should == []
108
+ User.all(:conditions => ["name like 'Bla%' or name like 'Br%'"]).should == [@user1, @user2]
109
+ end
110
+ end
138
111
 
139
- # it 'should be able to search for objects not included in a range of values' do
140
- # User.all(:age.not => 25..100).should == [@user1, @user3]
141
- # end
142
112
 
143
- # it 'should be able to search for objects with not nil value' do
144
- # User.all(:age.not => 25, :name.like => "B%").should == [@user1, @user2]
145
- # end
113
+ # it 'should be able to search for objects not included in a range of values' do
114
+ # User.all(:age.not => 25..100).should == [@user1, @user3]
115
+ # end
146
116
 
147
- it 'should be able to search for objects that match value' do
148
- DataMapper.repository(adapter) do
149
- User.all(:name.like => 'Bl%').should == [@user1, @user3]
150
- end
117
+ # it 'should be able to search for objects with not nil value' do
118
+ # User.all(:age.not => 25, :name.like => "B%").should == [@user1, @user2]
119
+ # end
120
+
121
+ it 'should be able to search for objects that match value' do
122
+ DataMapper.repository(:ldap) do
123
+ User.all(:name.like => 'Bl%').should == [@user1, @user3]
151
124
  end
125
+ end
152
126
 
153
- #it 'should be able to search for objects with value greater than' do
154
- # User.all(:age.gt => 0).should == [@user2]
155
- #end
127
+ #it 'should be able to search for objects with value greater than' do
128
+ # User.all(:age.gt => 0).should == [@user2]
129
+ #end
156
130
 
157
- #it 'should be able to search for objects with value greater than or equal to' do
158
- # User.all(:age.gte => 0).should == [@user1, @user2]
159
- #end
131
+ #it 'should be able to search for objects with value greater than or equal to' do
132
+ # User.all(:age.gte => 0).should == [@user1, @user2]
133
+ #end
160
134
 
161
- #it 'should be able to search for objects with value less than' do
162
- # User.all(:age.lt => 1).should == [@user1]
163
- #end
135
+ #it 'should be able to search for objects with value less than' do
136
+ # User.all(:age.lt => 1).should == [@user1]
137
+ #end
164
138
 
165
- #it 'should be able to search for objects with value less than or equal to' do
166
- # User.all(:age.lte => 0).should == [@user1]
167
- #end
139
+ #it 'should be able to search for objects with value less than or equal to' do
140
+ # User.all(:age.lte => 0).should == [@user1]
141
+ #end
168
142
 
169
- it 'should be able to update an object' do
170
- DataMapper.repository(adapter) do
171
- @user1 = User.get(@user1.id)
172
- @user1.age = 10
173
- @user1.save
174
- User.get(@user1.id).age.should == 10
175
- @user1.age = 70
176
- @user1.save
177
- User.get(@user1.id).age.should == 70
178
- end
143
+ it 'should be able to update an object' do
144
+ DataMapper.repository(:ldap) do
145
+ @user1 = User.get(@user1.id)
146
+ @user1.age = 10
147
+ @user1.save
148
+ User.get(@user1.id).age.should == 10
149
+ @user1.age = 70
150
+ @user1.save
151
+ User.get(@user1.id).age.should == 70
179
152
  end
153
+ end
180
154
 
181
- it 'should be able to update an object with nil' do
182
- DataMapper.repository(adapter) do
155
+ it 'should be able to update an object with nil' do
156
+ DataMapper.repository(:ldap) do
157
+ begin
183
158
  @user1 = User.get(@user1.id)
184
159
  @user1.age = nil
185
160
  @user1.save
@@ -187,59 +162,71 @@ User.all(:conditions => ["name like 'Bla%' or name like 'Br%'"]).should == [@use
187
162
  @user1.age = 70
188
163
  @user1.save
189
164
  User.get(@user1.id).age.should == 70
165
+ rescue => e
166
+ puts e
167
+ puts e.backtrace.join "\n\t"
168
+ raise e
190
169
  end
191
170
  end
171
+ end
192
172
 
193
- it 'should be able to destroy an object' do
194
- DataMapper.repository(adapter) do
195
- size = User.all.size
196
- @user1.destroy
197
- User.all.size.should == size - 1
198
- end
173
+ it 'should be able to destroy an object' do
174
+ DataMapper.repository(:ldap) do
175
+ size = User.all.size
176
+ @user1.destroy
177
+ User.all.size.should == size - 1
199
178
  end
179
+ end
200
180
 
201
- it 'should work with transactions' do
202
- DataMapper.repository(adapter) do
181
+ it 'should work with transactions' do
182
+ DataMapper.repository(:ldap) do
183
+ begin
203
184
  User.transaction do
204
185
  user = User.get(@user3.id)
205
186
  user.name = "B new"
206
187
  user.save
207
188
  User.get(@user3.id).name.should == 'B new'
208
189
  end
190
+ rescue => e
191
+ puts e
192
+ puts e.backtrace.join "\n\t"
193
+ raise e
209
194
  end
210
195
  end
196
+ end
211
197
 
212
- if DataMapper.repository(adapter).adapter.respond_to? :open_ldap_connection
213
-
214
- it 'should use one connection for several actions' do
215
- DataMapper.repository(adapter) do
216
- DataMapper.repository.adapter.open_ldap_connection do
217
- hash = DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash
218
- User.all
219
- DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should == hash
220
- user = User.get(@user3.id)
221
- DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should == hash
222
- user.name = "another name"
223
- user.save
224
- DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should == hash
225
- end
226
- DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should_not == hash
227
- end
228
- end
198
+ if DataMapper.repository(:ldap).adapter.respond_to? :open_ldap_connection
229
199
 
230
- it 'should use new connection for each action' do
231
- DataMapper.repository(adapter) do
200
+ it 'should use one connection for several actions' do
201
+ DataMapper.repository(:ldap) do
202
+ DataMapper.repository.adapter.open_ldap_connection do
232
203
  hash = DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash
233
204
  User.all
234
-
235
- DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should_not == hash
205
+ DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should == hash
236
206
  user = User.get(@user3.id)
237
- DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should_not == hash
238
- user.name = "yet another name"
207
+ DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should == hash
208
+ user.name = "another name"
239
209
  user.save
240
- DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should_not == hash
210
+ DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should == hash
241
211
  end
212
+ DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should_not == hash
213
+ end
214
+ end
215
+
216
+ it 'should use new connection for each action' do
217
+ DataMapper.repository(:ldap) do
218
+ hash = DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash
219
+ User.all
220
+
221
+ DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should_not == hash
222
+ user = User.get(@user3.id)
223
+ DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should_not == hash
224
+ user.name = "yet another name"
225
+ user.save
226
+ DataMapper.repository.adapter.instance_variable_get(:@ldap_connection).current.hash.should_not == hash
242
227
  end
243
228
  end
244
229
  end
245
230
  end
231
+
232
+ \
@@ -6,12 +6,29 @@ class Order
6
6
 
7
7
  property :id, Serial
8
8
 
9
- repository(:ldap) do
10
- belongs_to :user
9
+ belongs_to :user, :required => false, :repository => :ldap
10
+ end
11
+
12
+ class Order2
13
+ include DataMapper::Resource
14
+
15
+ def self.repository_name
16
+ :default
17
+ end
18
+
19
+ property :id, Serial
20
+
21
+ belongs_to :user, :required => false
22
+ end
23
+
24
+ class User
25
+ def self.repository_name
26
+ :ldap
11
27
  end
12
28
  end
13
29
 
14
30
  Order.auto_migrate!(:default)
31
+ Order2.auto_migrate!(:default)
15
32
 
16
33
  describe DataMapper.repository(:ldap).adapter do
17
34
 
@@ -19,12 +36,16 @@ describe DataMapper.repository(:ldap).adapter do
19
36
 
20
37
  before do
21
38
  DataMapper.repository(:ldap) do
39
+ begin
40
+ User.all.destroy!
22
41
  @user = User.new(:login => "beige", :name => 'Beige')
23
42
  @user.password = "asd123"
24
43
  @user.save
44
+ rescue => e
45
+ puts e.backtrace.join("\n\t")
46
+ raise e
47
+ end
25
48
  end
26
-
27
- @order = Order.create
28
49
  end
29
50
 
30
51
  after do
@@ -35,9 +56,24 @@ describe DataMapper.repository(:ldap).adapter do
35
56
  end
36
57
 
37
58
  it 'should create and load the association' do
59
+ @order = Order.create
38
60
  @order.user = @user
39
61
  @order.save
40
- Order.get!(@order.id).user.should == @user
62
+ order = Order.get!(@order.id)
63
+ DataMapper.repository(:ldap) do
64
+ order.user.should == @user
65
+ end
66
+ end
67
+ it 'should create and load the association with fixed repositories' do
68
+ DataMapper.repository(:default) do
69
+ DataMapper.repository(:ldap) do
70
+ @order = Order2.create
71
+ @order.user = @user
72
+ @order.save
73
+ order = Order2.get!(@order.id)
74
+ order.user.should == @user
75
+ end
76
+ end
41
77
  end
42
78
  end
43
79
  end
@@ -1,14 +1,14 @@
1
1
  $LOAD_PATH << File.dirname(__FILE__)
2
2
  require 'spec_helper'
3
3
 
4
- class Contact
4
+ class TestContact
5
5
  include DataMapper::Resource
6
6
 
7
7
  property :id, Serial, :field => "uidnumber"
8
8
  property :login, String, :field => "uid", :unique_index => true
9
- property :hashed_password, String, :field => "userpassword", :access => :private, :lazy => true
9
+ property :hashed_password, String, :field => "userpassword", :lazy => true
10
10
  property :name, String, :field => "cn"
11
- property :mail, LdapArray
11
+ property :mail, ::Ldap::LdapArray
12
12
 
13
13
  dn_prefix { |contact| "uid=#{contact.login}"}
14
14
 
@@ -33,16 +33,15 @@ describe DataMapper.repository(:ldap).adapter.class do
33
33
 
34
34
  before :each do
35
35
  DataMapper.repository(:ldap) do
36
- Contact.all(:login => "beige").destroy!
37
- @contact = Contact.new(:login => "beige", :name => 'Beige')
38
- @contact.password = "asd123"
39
- @contact.save
40
- end
41
- end
42
-
43
- after :each do
44
- DataMapper.repository(:ldap) do
45
- @contact.destroy
36
+ begin
37
+ TestContact.all(:login.like => "b%").destroy!
38
+ @contact = TestContact.new(:login => "beige", :name => 'Beige')
39
+ @contact.password = "asd123"
40
+ @contact.save
41
+ rescue => e
42
+ puts e.backtrace.join("\n\t")
43
+ raise e
44
+ end
46
45
  end
47
46
  end
48
47
 
@@ -50,24 +49,32 @@ describe DataMapper.repository(:ldap).adapter.class do
50
49
  DataMapper.repository(:ldap) do
51
50
  @contact.mail.should == []
52
51
 
53
- @contact.mail << "email1"
52
+ @contact.mail = ["email1"]
54
53
  @contact.save
55
- @contact = Contact.get!(@contact.id)
54
+ end
55
+ DataMapper.repository(:ldap) do
56
+ @contact = TestContact.get!(@contact.id)
56
57
  @contact.mail.should == ["email1"]
57
-
58
58
  @contact.mail << "email2"
59
59
  @contact.save
60
- @contact = Contact.get!(@contact.id)
60
+ end
61
+ DataMapper.repository(:ldap) do
62
+ @contact = TestContact.get!(@contact.id)
61
63
  @contact.mail.should == ["email1", "email2"]
62
-
63
64
  @contact.mail.delete("email1")
64
65
  @contact.save
65
- @contact = Contact.get!(@contact.id)
66
+ end
67
+ DataMapper.repository(:ldap) do
68
+ @contact = TestContact.get!(@contact.id)
66
69
  @contact.mail.should == ["email2"]
67
70
 
68
- @contact.mail.delete("email2")
71
+ mail = @contact.mail.dup
72
+ mail.delete("email2")
73
+ @contact.mail = mail
69
74
  @contact.save
70
- @contact = Contact.get!(@contact.id)
75
+ end
76
+ DataMapper.repository(:ldap) do
77
+ @contact = TestContact.get!(@contact.id)
71
78
  @contact.mail.should == []
72
79
  end
73
80
  end
@@ -76,35 +83,61 @@ describe DataMapper.repository(:ldap).adapter.class do
76
83
  DataMapper.repository(:ldap) do
77
84
  @contact.mail.should == []
78
85
 
79
- @contact.mail << "email1"
86
+ @contact.mail = ["email1"]
80
87
  @contact.save
81
- @contact = Contact.all.detect {|c| c.id = @contact.id}
88
+ end
89
+ DataMapper.repository(:ldap) do
90
+ @contact = TestContact.all.detect {|c| c.id = @contact.id}
82
91
  @contact.mail.should == ["email1"]
83
92
 
84
- @contact.mail << "email2"
93
+ @contact.mail = @contact.mail.dup << "email2"
85
94
  @contact.save
86
- @contact = Contact.all.detect {|c| c.id = @contact.id}
95
+ end
96
+ DataMapper.repository(:ldap) do
97
+ @contact = TestContact.all.detect {|c| c.id = @contact.id}
87
98
  @contact.mail.should == ["email1", "email2"]
88
99
 
89
- @contact.mail.delete("email1")
100
+ mail = @contact.mail.dup
101
+ mail.delete("email1")
102
+ @contact.mail = mail
90
103
  @contact.save
91
- @contact = Contact.all.detect {|c| c.id = @contact.id}
104
+ end
105
+ DataMapper.repository(:ldap) do
106
+ @contact = TestContact.all.detect {|c| c.id = @contact.id}
92
107
  @contact.mail.should == ["email2"]
93
108
 
94
- @contact.mail.delete("email2")
109
+ mail = @contact.mail.dup
110
+ mail.delete("email2")
111
+ @contact.mail = mail
95
112
  @contact.save
96
- @contact = Contact.all.detect {|c| c.id = @contact.id}
113
+ end
114
+ DataMapper.repository(:ldap) do
115
+ @contact = TestContact.all.detect {|c| c.id = @contact.id}
97
116
  @contact.mail.should == []
98
117
  end
99
118
  end
100
119
 
101
120
  it 'should allow to replace the LdapArray' do
102
121
  DataMapper.repository(:ldap) do
103
- @contact = Contact.get(@contact.id)
122
+ @contact = TestContact.get(@contact.id)
104
123
  @contact.mail.should == []
105
124
  @contact.mail = ['foo', 'bar']
106
125
  @contact.save
107
- @contact = Contact.get(@contact.id)
126
+ end
127
+ DataMapper.repository(:ldap) do
128
+ @contact = TestContact.get(@contact.id)
129
+ @contact.mail.should == ['foo', 'bar']
130
+ end
131
+ end
132
+ it 'should create resource with the LdapArray' do
133
+ DataMapper.repository(:ldap) do
134
+ @contact = TestContact.new(:login => "black", :name => 'Black')
135
+ @contact.password = "asd123"
136
+ @contact.mail = ['foo', 'bar']
137
+ @contact.save
138
+ end
139
+ DataMapper.repository(:ldap) do
140
+ @contact = TestContact.get(@contact.id)
108
141
  @contact.mail.should == ['foo', 'bar']
109
142
  end
110
143
  end