Merge pull request #24 from danabr/default_search_behaviour
search should return result set if :return_result is unspecified (nil).
This commit is contained in:
commit
6bb9fa6ae6
2 changed files with 12 additions and 4 deletions
|
@ -619,7 +619,8 @@ class Net::LDAP
|
||||||
end
|
end
|
||||||
|
|
||||||
args[:base] ||= @base
|
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
|
if @open_connection
|
||||||
@result = @open_connection.search(args) { |entry|
|
@result = @open_connection.search(args) { |entry|
|
||||||
|
@ -642,7 +643,7 @@ class Net::LDAP
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if args[:return_result]
|
if return_result_set
|
||||||
@result == 0 ? result_set : nil
|
@result == 0 ? result_set : nil
|
||||||
else
|
else
|
||||||
@result == 0
|
@result == 0
|
||||||
|
|
|
@ -13,17 +13,24 @@ describe Net::LDAP, "search method" do
|
||||||
@connection.instance_variable_set(:@open_connection, FakeConnection.new)
|
@connection.instance_variable_set(:@open_connection, FakeConnection.new)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when returning result set" do
|
context "when :return_result => true" do
|
||||||
it "should return nil upon error" do
|
it "should return nil upon error" do
|
||||||
result_set = @connection.search(:return_result => true)
|
result_set = @connection.search(:return_result => true)
|
||||||
result_set.should be_nil
|
result_set.should be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when returning boolean" do
|
context "when :return_result => false" do
|
||||||
it "should return false upon error" do
|
it "should return false upon error" do
|
||||||
success = @connection.search(:return_result => false)
|
success = @connection.search(:return_result => false)
|
||||||
success.should == false
|
success.should == false
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue