Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Merge 9767f66 into 803bbcd
Browse files Browse the repository at this point in the history
  • Loading branch information
a-chernykh committed Aug 13, 2015
2 parents 803bbcd + 9767f66 commit f9684f5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/moped/node.rb
Expand Up @@ -187,7 +187,11 @@ def ensure_connected(&block)

begin
connection do |conn|
connect(conn) unless conn.alive?
if conn.alive?
@down_at = nil
else
connect(conn)
end
conn.apply_credentials(@credentials)
stack(:connection) << conn
yield(conn)
Expand Down
15 changes: 15 additions & 0 deletions spec/moped/node_spec.rb
Expand Up @@ -309,6 +309,21 @@
end
end
end

context 'when node was down' do
before { node.down! }

context 'and good connection popped out of the pool' do
before { allow_any_instance_of(Moped::Connection).to receive(:alive?).and_return true }

it 'marks node as not down' do
node.ensure_connected do
node.command("admin", ping: 1)
end
expect(node).not_to be_down
end
end
end
end

describe "#initialize" do
Expand Down

0 comments on commit f9684f5

Please sign in to comment.