Skip to content

Commit

Permalink
Read ui url from settings file for dev environment
Browse files Browse the repository at this point in the history
In dev environments we need the ability to set the UI URL
from config/settings.yml. This is used when constructing the
remote_ui_url
  • Loading branch information
mkanoor committed May 17, 2018
1 parent 1eb6ee1 commit 701650c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/miq_region.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ def remote_ui_hostname
end

def remote_ui_url(contact_with = :hostname)
svr = remote_ui_miq_server
remote_ui_url_override = svr.settings_for_resource.ui.url if svr
return remote_ui_url_override if remote_ui_url_override

hostname = send("remote_ui_#{contact_with}")
hostname && "https://#{hostname}"
end
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,7 @@
:active_task_timeout: 6.hours
:ui:
:mark_translated_strings: false
:url:
:vim_performance_states:
:history:
:purge_window_size: 1000
Expand Down
20 changes: 20 additions & 0 deletions spec/models/miq_region_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,24 @@
expect(region.remote_ws_url).to eq(url)
end
end

describe "#remote_ui_url" do
let(:ip) { "1.1.1.94" }
let(:hostname) { "www.manageiq.org" }
let(:url) { "http://localhost:3000" }
let!(:ui_server) do
FactoryGirl.create(:miq_server, :has_active_userinterface => true,
:hostname => hostname,
:ipaddress => ip)
end

it "fetches the url from server" do
expect(region.remote_ui_url).to eq("https://#{hostname}")
end

it "fetches the url from the setting" do
Vmdb::Settings.save!(ui_server, :ui => {:url => url})
expect(region.remote_ui_url).to eq(url)
end
end
end

0 comments on commit 701650c

Please sign in to comment.