Permalink
Browse files

search should return result set if :return_result is unspecified (nil).

Corrects incorrect behaviour introduced in a4819e5
  • Loading branch information...
1 parent 5344d73 commit 2a74577d5f08b1b2a4ac33b8d9753b3f8d1efba4 @danabr danabr committed Oct 7, 2011
Showing with 12 additions and 4 deletions.
  1. +3 −2 lib/net/ldap.rb
  2. +9 −2 spec/unit/ldap/search_spec.rb
View
@@ -619,7 +619,8 @@ def search(args = {})
end
args[:base] ||= @base
- result_set = args[:return_result] == false ? nil : []
+ return_result_set = args[:return_result] != false
+ result_set = return_result_set ? [] : nil
if @open_connection
@result = @open_connection.search(args) { |entry|
@@ -642,7 +643,7 @@ def search(args = {})
end
end
- if args[:return_result]
+ if return_result_set
@result == 0 ? result_set : nil
else
@result == 0
@@ -13,17 +13,24 @@ def search(args)
@connection.instance_variable_set(:@open_connection, FakeConnection.new)
end
- context "when returning result set" do
+ context "when :return_result => true" do
it "should return nil upon error" do
result_set = @connection.search(:return_result => true)
result_set.should be_nil
end
end
- context "when returning boolean" do
+ context "when :return_result => false" do
it "should return false upon error" do
success = @connection.search(:return_result => false)
success.should == false
end
end
+
+ context "When :return_result is not given" do
+ it "should return nil upon error" do
+ result_set = @connection.search
+ result_set.should be_nil
+ end
+ end
end

0 comments on commit 2a74577

Please sign in to comment.