Raisl5: Fix Gitlab::Database::LoadBalancing#caught_up? check

Rails 5 returns true/false instead of a string 't' or 'f'.
parent 3cd52365
---
title: 'Raisl 5: Fix Gitlab::Database::LoadBalancing#caught_up? check'
merge_request: 8595
author:
type: fixed
......@@ -159,7 +159,7 @@ module Gitlab
row = query_and_release(query)
row['result'] == 't'
::Gitlab::Utils.to_boolean(row['result'])
rescue *CONNECTION_ERRORS
false
end
......
......@@ -323,6 +323,14 @@ describe Gitlab::Database::LoadBalancing::Host, :postgresql do
expect(host.caught_up?('foo')).to eq(true)
end
# TODO: remove rails5-only tag after removing rails4 tests
it 'returns true when a host has caught up', :rails5 do
allow(host).to receive(:connection).and_return(connection)
expect(connection).to receive(:select_all).and_return([{ 'result' => true }])
expect(host.caught_up?('foo')).to eq(true)
end
it 'returns false when a host has not caught up' do
allow(host).to receive(:connection).and_return(connection)
expect(connection).to receive(:select_all).and_return([{ 'result' => 'f' }])
......@@ -330,6 +338,14 @@ describe Gitlab::Database::LoadBalancing::Host, :postgresql do
expect(host.caught_up?('foo')).to eq(false)
end
# TODO: remove rails5-only tag after removing rails4 tests
it 'returns false when a host has not caught up', :rails5 do
allow(host).to receive(:connection).and_return(connection)
expect(connection).to receive(:select_all).and_return([{ 'result' => false }])
expect(host.caught_up?('foo')).to eq(false)
end
it 'returns false when the connection fails' do
wrapped_error = wrapped_exception(ActionView::Template::Error, StandardError)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment