Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sailor): returns the correct 404 status for custom pages. #150

Merged
merged 2 commits into from
Jul 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sailor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function sailor.route(page)
if sailor.conf.default_error404 and sailor.conf.default_error404 ~= '' then
page.controller_view_path = nil
_, res = xpcall(function () page:render(sailor.conf.default_error404) end, error_handler)
return res or httpd.OK or page.r.status or 200
return res or httpd.OK or page.r.status or 404
end
page.r.status = 404
return res or page.r.status
Expand Down
4 changes: 2 additions & 2 deletions test/dev-app/tests/functional/category.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ describe("Testing #CategoryController", function()

it("should not get category if id not found", function()
local res = test.request('category/view', {get = {id = 42}})
assert.same(200,res.status)
assert.same(404,res.status)
assert.truthy(res.body:match('Error'))
end)
it("should not get category without id", function()
local res = test.request('category/view')
assert.same(200,res.status)
assert.same(404,res.status)
assert.truthy(res.body:match('Error'))
end)

Expand Down