forked from hanami/hanami
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,19 @@ class Default | |
def title | ||
response[2].first | ||
end | ||
|
||
def render | ||
status_code = response[0] | ||
templates = Lotus::Application.configuration.templates | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jodosha
|
||
template = "#{Pathname.new(templates).join(status_code.to_s)}.html.erb" | ||
|
||
if File.exists?(template) | ||
scope = Lotus::View::Rendering::Scope.new(self) | ||
Lotus::View::Template.new(template).render scope | ||
else | ||
super | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Custom 404 page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Custom 500 page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require 'test_helper' | ||
require 'rack/test' | ||
require 'fixtures/one_file/application' | ||
|
||
describe 'Error page test' do | ||
include Rack::Test::Methods | ||
|
||
before do | ||
@current_dir = Dir.pwd | ||
Dir.chdir FIXTURES_ROOT.join('one_file') | ||
@app = OneFile::Application.new | ||
end | ||
|
||
after do | ||
Dir.chdir @current_dir | ||
@current_dir = nil | ||
end | ||
|
||
def app | ||
@app | ||
end | ||
|
||
def response | ||
last_response | ||
end | ||
|
||
it 'returns custom error pages' do | ||
get '/four_hundred' | ||
response.status.must_equal 400 | ||
response.body.must_equal <<-EOF | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Four Hundred</title> | ||
</head> | ||
<body> | ||
<h1>Four Hundred</h1> | ||
</body> | ||
</html> | ||
EOF | ||
|
||
get '/error' | ||
response.status.must_equal 500 | ||
response.body.must_equal %(Custom 500 page\n) | ||
|
||
get '/foo' | ||
response.status.must_equal 404 | ||
response.body.must_equal %(Custom 404 page\n) | ||
end | ||
end |
Lotus::Application.configuration
doesn't work here, it returns a default configuration. What's the best way to get the actual configuration.