Commit 3e653227 authored by Samir Noir's avatar Samir Noir 🧀
Browse files

Return 404 when an ui template cannot be found

parent 09c69e4b
Pipeline #157424 passed with stages
in 20 minutes and 23 seconds
......@@ -13,28 +13,30 @@
# limitations under the License.
class UiController < ApplicationController
rescue_from ActionView::MissingTemplate do
render :template => "ui/404.html.haml", :status => 404
end
def show
params[:page] ||= "dashboard"
@id = params[:page].downcase.gsub(/[^a-z]/,'_').squeeze('_')
@title = params[:page]
respond_to do |format|
format.html {
render params[:page].to_sym
}
end
end
def visualization
def visualization
@id = params[:page].downcase.gsub(/[^a-z]/,'_').squeeze('_')
@title = params[:page]
respond_to do |format|
format.html {
render "ui/visualizations/#{params[:page]}.html.haml"
}
end
end
end
\ No newline at end of file
end
- content_for :before_js do
%script{:src => relative_path_to("/javascripts/vendor/exhibitv2/exhibit/api/exhibit-api.js")+"?autoCreate=false",
:type => "text/javascript"}
%script{:src => relative_path_to("/javascripts/lib/exhibit.js"),
:type => "text/javascript"}
%h2
Page not found
# Copyright (c) 2009-2011 Cyril Rohr, INRIA Rennes - Bretagne Atlantique
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
describe UiController do
render_views
describe "GET /ui/doesnotexist" do
it "should return 404 if the page does not exist" do
get :visualization, format: :html, params: { :page => 'doesnotexist' }
expect(response.status).to eq(404)
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