From 13bd8a07b08cd754c4b9132387e5ece6deecbffc Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sun, 19 Jun 2016 18:21:24 -0400 Subject: [PATCH] Fix default docs behavior when all docs are disabled Fixes #424. --- lib/app.rb | 2 +- test/app_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/app.rb b/lib/app.rb index 707a77b4..f1a57810 100644 --- a/lib/app.rb +++ b/lib/app.rb @@ -119,7 +119,7 @@ class App < Sinatra::Application @docs ||= begin cookie = cookies[:docs] - if cookie.nil? || cookie.empty? + if cookie.nil? settings.default_docs else cookie.split('/') diff --git a/test/app_test.rb b/test/app_test.rb index 03bfe1f7..448f6372 100644 --- a/test/app_test.rb +++ b/test/app_test.rb @@ -132,6 +132,12 @@ class AppTest < MiniTest::Spec assert last_response.ok? 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 set_cookie('docs=html~5') get '/html~5/', {}, 'HTTP_USER_AGENT' => MODERN_BROWSER