Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
grid5000
g5k-api
Commits
17b90cbe
Commit
17b90cbe
authored
Jul 07, 2020
by
Samir Noir
🧀
Browse files
Return 404 when an ui template cannot be found
parent
41b35608
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/controllers/ui_controller.rb
View file @
17b90cbe
...
...
@@ -13,28 +13,31 @@
# limitations under the License.
class
UiController
<
ApplicationController
rescue_from
ActionView
::
MissingTemplate
do
@title
=
'Page not found'
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
app/views/ui/404.html.haml
0 → 100644
View file @
17b90cbe
-
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
spec/controllers/ui_controller_spec.rb
0 → 100644
View file @
17b90cbe
# 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment