Skip to content
This repository was archived by the owner on Nov 15, 2018. It is now read-only.

Commit d9d5a67

Browse files
author
koutou
committed
* DN attribute change by mass assignment with :id => ... blocks.
git-svn-id: http://ruby-activeldap.googlecode.com/svn/trunk@1105 fd4f1387-ac19-0410-9179-05984c98faae
1 parent 2937bfd commit d9d5a67

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/active_ldap/attributes.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,20 @@ def remove_attributes_protected_from_mass_assignment(targets)
157157
needless_attributes[to_real_attribute_name(name)] = true
158158
end
159159

160+
_dn_attribute = nil
161+
begin
162+
_dn_attribute = dn_attribute_with_fallback
163+
rescue DistinguishedNameInvalid
164+
end
160165
targets.collect do |key, value|
166+
key = _dn_attribute if ["id", "dn"].include?(key.to_s)
161167
[to_real_attribute_name(key) || key, value]
162168
end.reject do |key, value|
163169
needless_attributes[key]
164170
end
165171
end
166172

167173
def attributes_protected_by_default
168-
_dn_attribute = nil
169174
begin
170175
_dn_attribute = dn_attribute_with_fallback
171176
rescue DistinguishedNameInvalid

test/test_base.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ class TestBase < Test::Unit::TestCase
66
include AlTestUtils
77

88
priority :must
9+
def test_not_rename_by_mass_update
10+
make_temporary_user(:simple => true) do |user,|
11+
original_id = user.id
12+
assert_true(user.update_attributes(:id => "user2"))
13+
assert_equal(original_id, user.id)
14+
end
15+
end
16+
17+
priority :normal
918
def test_attributes
1019
make_temporary_group do |group|
1120
assert_equal({
@@ -17,7 +26,6 @@ def test_attributes
1726
end
1827
end
1928

20-
priority :normal
2129
def test_rename_with_superior
2230
make_ou("sub,ou=users")
2331
make_temporary_user(:simple => true) do |user,|

0 commit comments

Comments
 (0)