Skip to content

Commit 82f756c

Browse files
committed
RUBY-231 - support explicitly specified nil timeout option
1 parent 487c242 commit 82f756c

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

lib/cassandra/execution/options.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def initialize(options, trusted_options = nil)
177177
@consistency = consistency || trusted_options.consistency
178178
@page_size = page_size || trusted_options.page_size
179179
@trace = trace.nil? ? trusted_options.trace? : !!trace
180-
@timeout = timeout || trusted_options.timeout
180+
@timeout = options.key?(:timeout) ? timeout : trusted_options.timeout
181181
@serial_consistency = serial_consistency || trusted_options.serial_consistency
182182
@arguments = arguments || trusted_options.arguments
183183
@type_hints = type_hints || trusted_options.type_hints
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# encoding: utf-8
2+
3+
#--
4+
# Copyright 2013-2016 DataStax, Inc.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#++
18+
19+
require 'spec_helper'
20+
21+
module Cassandra
22+
module Execution
23+
describe(Options) do
24+
let(:base_options) { Options.new(timeout: 10, consistency: :one) }
25+
it 'should allow nil timeout to override base non-nil timeout option' do
26+
result = Options.new({timeout: nil}, base_options)
27+
expect(result.timeout).to be_nil
28+
end
29+
30+
it 'should non-nil timeout to override base non-nil timeout option' do
31+
result = Options.new({timeout: 123}, base_options)
32+
expect(result.timeout).to eq(123)
33+
end
34+
35+
it 'should not override base timeout if not specified' do
36+
result = Options.new({}, base_options)
37+
expect(result.timeout).to eq(10)
38+
end
39+
end
40+
end
41+
end

0 commit comments

Comments
 (0)