File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -619,7 +619,7 @@ def search(args = {})
619619 end
620620
621621 args [ :base ] ||= @base
622- result_set = ( args and args [ :return_result ] == false ) ? nil : [ ]
622+ result_set = args [ :return_result ] == false ? nil : [ ]
623623
624624 if @open_connection
625625 @result = @open_connection . search ( args ) { |entry |
@@ -642,7 +642,11 @@ def search(args = {})
642642 end
643643 end
644644
645- result_set || @result == 0
645+ if args [ :return_result ]
646+ @result == 0 ? result_set : nil
647+ else
648+ @result == 0
649+ end
646650 end
647651
648652 # #bind connects to an LDAP server and requests authentication based on
Original file line number Diff line number Diff line change 1+ # -*- ruby encoding: utf-8 -*-
2+
3+ describe Net ::LDAP , "search method" do
4+ class FakeConnection
5+ def search ( args )
6+ error_code = 1
7+ return error_code
8+ end
9+ end
10+
11+ before ( :each ) do
12+ @connection = Net ::LDAP . new
13+ @connection . instance_variable_set ( :@open_connection , FakeConnection . new )
14+ end
15+
16+ context "when returning result set" do
17+ it "should return nil upon error" do
18+ result_set = @connection . search ( :return_result => true )
19+ result_set . should be_nil
20+ end
21+ end
22+
23+ context "when returning boolean" do
24+ it "should return false upon error" do
25+ success = @connection . search ( :return_result => false )
26+ success . should == false
27+ end
28+ end
29+ end
You can’t perform that action at this time.
0 commit comments