From f46d606ec6ef38f1611ab5a45836e832091748f0 Mon Sep 17 00:00:00 2001 From: Emily Stolfo Date: Fri, 9 Oct 2015 13:39:54 -0400 Subject: [PATCH 1/3] RUBY-1051 Check that an Operation Result is created with top-level Result class defined --- spec/mongo/operation/result_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/mongo/operation/result_spec.rb b/spec/mongo/operation/result_spec.rb index 6f33d1925d..56b3d99883 100644 --- a/spec/mongo/operation/result_spec.rb +++ b/spec/mongo/operation/result_spec.rb @@ -272,4 +272,23 @@ end end end + + context 'when there is a top-level Result class defined' do + + before do + class Result + def get_result + Mongo::Client.new([DEFAULT_ADDRESS]).database.command(:ping => 1) + end + end + end + + let(:result) do + Result.new.get_result + end + + it 'uses the Result class of the operation' do + expect(result).to be_a(Mongo::Operation::Result) + end + end end From c1b5bd60a1385702f818cfffbeaa0e1113bb756f Mon Sep 17 00:00:00 2001 From: Emily Stolfo Date: Fri, 9 Oct 2015 13:55:56 -0400 Subject: [PATCH 2/3] RUBY-1051 Change class look-up method in other operation modules --- lib/mongo/operation/write/gle.rb | 4 ++-- lib/mongo/operation/write/write_command_enabled.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mongo/operation/write/gle.rb b/lib/mongo/operation/write/gle.rb index 3b9ce95837..4401f3f63a 100644 --- a/lib/mongo/operation/write/gle.rb +++ b/lib/mongo/operation/write/gle.rb @@ -26,8 +26,8 @@ module GLE def execute_message(context) context.with_connection do |connection| - result_class = defined?(self.class::LegacyResult) ? self.class::LegacyResult : - defined?(self.class::Result) ? self.class::Result : Result + result_class = self.class.const_defined?(:LegacyResult, false) ? self.class::LegacyResult : + self.class.const_defined?(:Result, false) ? self.class::Result : Result result_class.new(connection.dispatch([ message, gle ].compact)).validate! end end diff --git a/lib/mongo/operation/write/write_command_enabled.rb b/lib/mongo/operation/write/write_command_enabled.rb index 50dc3aec19..f6064d0e1e 100644 --- a/lib/mongo/operation/write/write_command_enabled.rb +++ b/lib/mongo/operation/write/write_command_enabled.rb @@ -44,7 +44,7 @@ def execute(context) private def execute_write_command(context) - result_class = defined?(self.class::Result) ? self.class::Result : Result + result_class = self.class.const_defined?(:Result, false) ? self.class::Result : Result result_class.new(write_command_op.execute(context)).validate! end end From 7809f41079ed9f0e2aad8c56c33766bc756f1056 Mon Sep 17 00:00:00 2001 From: Emily Stolfo Date: Fri, 9 Oct 2015 14:51:48 -0400 Subject: [PATCH 3/3] Use test options for test to run with SSL --- spec/mongo/operation/result_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/mongo/operation/result_spec.rb b/spec/mongo/operation/result_spec.rb index 56b3d99883..9c193da627 100644 --- a/spec/mongo/operation/result_spec.rb +++ b/spec/mongo/operation/result_spec.rb @@ -278,7 +278,7 @@ before do class Result def get_result - Mongo::Client.new([DEFAULT_ADDRESS]).database.command(:ping => 1) + Mongo::Client.new([DEFAULT_ADDRESS], TEST_OPTIONS).database.command(:ping => 1) end end end