Commit 1558d17f authored by Stan Hu's avatar Stan Hu

Use the current node configuration to populate suggested new URL for Geo node

Users attempting to add a new GeoNode with HTTPS would be suggested
to use an HTTP endpoint, which caused a misconfiguration for one user.

Closes #1416
parent 7a048641
......@@ -5,10 +5,10 @@ class GeoNode < ActiveRecord::Base
belongs_to :oauth_application, class_name: 'Doorkeeper::Application', dependent: :destroy
belongs_to :system_hook, dependent: :destroy
default_values schema: 'http',
default_values schema: lambda { Gitlab.config.gitlab.protocol },
host: lambda { Gitlab.config.gitlab.host },
port: 80,
relative_url_root: '',
port: lambda { Gitlab.config.gitlab.port },
relative_url_root: lambda { Gitlab.config.gitlab.relative_url_root },
primary: false
accepts_nested_attributes_for :geo_node_key, :system_hook
......
---
title: Use the current node configuration to populate suggested new URL for Geo node
merge_request:
author:
......@@ -162,6 +162,15 @@ describe GeoNode, type: :model do
expected_url = 'https://localhost:3000/gitlab'
expect(new_node.url).to eq(expected_url)
end
it 'defaults to existing HTTPS and relative URL if present' do
stub_config_setting(port: 443)
stub_config_setting(protocol: 'https')
stub_config_setting(relative_url_root: '/gitlab')
node = GeoNode.new
expect(node.url).to eq('https://localhost/gitlab')
end
end
describe '#url=' 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