1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/test/controller/new_base/content_negotiation_test.rb

29 lines
837 B
Ruby
Raw Normal View History

# 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 %>!"
)]
2010-11-28 16:40:32 -05:00
def all
render plain: formats.inspect
2010-11-28 16:40:32 -05:00
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
2010-11-28 16:40:32 -05:00
test "Not all mimes are converted to symbol" do
get "/content_negotiation/basic/all", headers: { "HTTP_ACCEPT" => "text/plain, mime/another" }
2010-11-28 16:40:32 -05:00
assert_body '[:text, "mime/another"]'
end
end
end