diff options
Diffstat (limited to 'actionpack/test/controller/new_base/content_negotiation_test.rb')
-rw-r--r-- | actionpack/test/controller/new_base/content_negotiation_test.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/actionpack/test/controller/new_base/content_negotiation_test.rb b/actionpack/test/controller/new_base/content_negotiation_test.rb new file mode 100644 index 0000000000..7205e90176 --- /dev/null +++ b/actionpack/test/controller/new_base/content_negotiation_test.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +require "abstract_unit" + +module ContentNegotiation + # This has no layout and it works + class BasicController < ActionController::Base + self.view_paths = [ActionView::FixtureResolver.new( + "content_negotiation/basic/hello.html.erb" => "Hello world <%= request.formats.first.to_s %>!" + )] + + def all + render plain: formats.inspect + end + end + + class TestContentNegotiation < Rack::TestCase + test "A */* Accept header will return HTML" do + get "/content_negotiation/basic/hello", headers: { "HTTP_ACCEPT" => "*/*" } + assert_body "Hello world */*!" + end + + test "Not all mimes are converted to symbol" do + get "/content_negotiation/basic/all", headers: { "HTTP_ACCEPT" => "text/plain, mime/another" } + assert_body '[:text, "mime/another"]' + end + end +end |