mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Merge pull request #92 from sschneid/redirect_/_to_/dashboard
Redirect / to /dashboard
This commit is contained in:
commit
10c5c6e287
3 changed files with 29 additions and 5 deletions
|
|
@ -17,11 +17,19 @@ module Vmpooler
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/' do
|
get '/' do
|
||||||
erb :dashboard, locals: {
|
redirect to('/dashboard/')
|
||||||
site_name: $config[:config]['site_name'] || '<b>vmpooler</b>'
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Load dashboard components
|
||||||
|
begin
|
||||||
|
require "dashboard"
|
||||||
|
rescue LoadError
|
||||||
|
require File.expand_path(File.join(File.dirname(__FILE__), 'dashboard'))
|
||||||
|
end
|
||||||
|
|
||||||
|
use Vmpooler::Dashboard
|
||||||
|
|
||||||
|
# Load API components
|
||||||
%w( dashboard reroute v1 ).each do |lib|
|
%w( dashboard reroute v1 ).each do |lib|
|
||||||
begin
|
begin
|
||||||
require "api/#{lib}"
|
require "api/#{lib}"
|
||||||
|
|
|
||||||
9
lib/vmpooler/dashboard.rb
Normal file
9
lib/vmpooler/dashboard.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
module Vmpooler
|
||||||
|
class Dashboard < Sinatra::Base
|
||||||
|
get '/dashboard/?' do
|
||||||
|
erb :dashboard, locals: {
|
||||||
|
site_name: $config[:config]['site_name'] || '<b>vmpooler</b>'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -11,13 +11,20 @@ describe Vmpooler::API do
|
||||||
describe 'Dashboard' do
|
describe 'Dashboard' do
|
||||||
|
|
||||||
context '/' do
|
context '/' do
|
||||||
|
before { get '/' }
|
||||||
|
|
||||||
|
it { expect(last_response.status).to eq(302) }
|
||||||
|
it { expect(last_response.location).to eq('http://example.org/dashboard/') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context '/dashboard/' do
|
||||||
let(:config) { {
|
let(:config) { {
|
||||||
config: {'site_name' => 'test pooler'}
|
config: {'site_name' => 'test pooler'}
|
||||||
} }
|
} }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
$config = config
|
$config = config
|
||||||
get '/'
|
get '/dashboard/'
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(last_response).to be_ok }
|
it { expect(last_response).to be_ok }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue