Commit 4a736853 authored by Toon Claes's avatar Toon Claes

Show clear message when set-geo-primary-node was successful

Closes gitlab-org/gitlab-ee#2177.
parent 409d5851
---
title: Show clear message when set-geo-primary-node was successful
merge_request: 3768
author:
type: changed
......@@ -5,10 +5,14 @@ module Gitlab
def set_primary_geo_node
node = GeoNode.new(primary: true, url: GeoNode.current_node_url)
$stdout.puts "Saving primary GeoNode with URL #{node.url}".color(:green)
$stdout.puts "Saving primary Geo node with URL #{node.url} ..."
node.save
$stdout.puts "Error saving GeoNode:\n#{node.errors.full_messages.join("\n")}".color(:red) unless node.persisted?
if node.persisted?
$stdout.puts "#{node.url} is now the primary Geo node".color(:green)
else
$stdout.puts "Error saving Geo node:\n#{node.errors.full_messages.join("\n")}".color(:red)
end
end
def refresh_foreign_tables!
......
require 'spec_helper'
describe Gitlab::Geo::GeoTasks do
describe '.set_primary_geo_node' do
before do
allow(GeoNode).to receive(:current_node_url).and_return('https://primary.geo.example.com')
end
it 'sets the primary node' do
expect { subject.set_primary_geo_node }.to output(/https:\/\/primary.geo.example.com\/ is now the primary Geo node/).to_stdout
end
it 'returns error when there is already a Primary node' do
create(:geo_node, :primary)
expect { subject.set_primary_geo_node }.to output(/Error saving Geo node:/).to_stdout
end
end
end
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