Fix default docs behavior when all docs are disabled

Fixes #424.
This commit is contained in:
Thibaut Courouble 2016-06-19 18:21:24 -04:00
parent 66f170c01d
commit 13bd8a07b0
2 changed files with 7 additions and 1 deletions

View file

@ -119,7 +119,7 @@ class App < Sinatra::Application
@docs ||= begin @docs ||= begin
cookie = cookies[:docs] cookie = cookies[:docs]
if cookie.nil? || cookie.empty? if cookie.nil?
settings.default_docs settings.default_docs
else else
cookie.split('/') cookie.split('/')

View file

@ -132,6 +132,12 @@ class AppTest < MiniTest::Spec
assert last_response.ok? assert last_response.ok?
end end
it "renders when the doc exists, is a default doc, and all docs are enabled" do
set_cookie('docs=')
get '/css/', {}, 'HTTP_USER_AGENT' => MODERN_BROWSER
assert last_response.ok?
end
it "redirects via JS cookie when the doc exists and is enabled" do it "redirects via JS cookie when the doc exists and is enabled" do
set_cookie('docs=html~5') set_cookie('docs=html~5')
get '/html~5/', {}, 'HTTP_USER_AGENT' => MODERN_BROWSER get '/html~5/', {}, 'HTTP_USER_AGENT' => MODERN_BROWSER