Move current_node? helper method to the GeoNode model

parent 71e26d3a
......@@ -35,6 +35,10 @@ class GeoNode < ActiveRecord::Base
mode: :per_attribute_iv,
encode: true
def current?
Gitlab::Geo.current_node == self
end
def secondary?
!primary
end
......
......@@ -20,7 +20,7 @@
.node-block
= node_status_icon(node)
%strong= node.url
- if current_node?(node)
- if node.current?
.node-badge.current-node Current node
- if node.primary?
.node-badge.primary-node Primary
......@@ -51,7 +51,7 @@
%p
.js-health
- if current_node?(node) == node.primary?
- if node.current? && node.primary?
.node-actions
- if Gitlab::Geo.license_allows?
- if node.missing_oauth_application?
......
......@@ -111,6 +111,22 @@ describe GeoNode, type: :model do
end
end
describe '#current?' do
subject { described_class.new }
it 'returns true when node is the current node' do
allow(Gitlab::Geo).to receive(:current_node) { subject }
expect(subject.current?).to eq true
end
it 'returns false when node is not the current node' do
allow(Gitlab::Geo).to receive(:current_node) { double }
expect(subject.current?).to eq false
end
end
describe '#uri' do
context 'when all fields are filled' do
it 'returns an URI object' do
......
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