diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-09-12 21:59:04 -0400 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2018-09-12 22:03:09 -0400 |
commit | 7b5054eedfdbd8f7dd5f348b0a02678b64fdd9de (patch) | |
tree | 889fb20d933aaf76781f379693106468cc301132 | |
parent | fdcd03a3c5a1c51d1f96fc97f9dfa1a9deac0c77 (diff) | |
download | rack-7b5054eedfdbd8f7dd5f348b0a02678b64fdd9de.tar.gz |
Merge pull request #1296 from tomelm/fix-prefers-plaintext
Call the correct accepts_html? method for prefer_plaintext
-rw-r--r-- | lib/rack/showexceptions.rb | 2 | ||||
-rw-r--r-- | test/spec_showexceptions.rb | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/rack/showexceptions.rb b/lib/rack/showexceptions.rb index 60999e64..44ee5678 100644 --- a/lib/rack/showexceptions.rb +++ b/lib/rack/showexceptions.rb @@ -47,7 +47,7 @@ module Rack end def prefers_plaintext?(env) - !accepts_html(env) + !accepts_html?(env) end def accepts_html?(env) diff --git a/test/spec_showexceptions.rb b/test/spec_showexceptions.rb index 7d50c59f..a4ccef91 100644 --- a/test/spec_showexceptions.rb +++ b/test/spec_showexceptions.rb @@ -82,4 +82,17 @@ describe Rack::ShowExceptions do res.should =~ /ShowExceptions/ res.should =~ /unknown location/ end + + it "knows to prefer plaintext for non-html" do + # We don't need an app for this + exc = Rack::ShowExceptions.new(nil) + + [ + [{ "HTTP_ACCEPT" => "text/plain" }, true], + [{ "HTTP_ACCEPT" => "text/foo" }, true], + [{ "HTTP_ACCEPT" => "text/html" }, false] + ].each do |env, expected| + assert_equal(expected, exc.prefers_plaintext?(env)) + end + end end |