Sha256: e4f42128d4bc6f16587c05dc5bb9f452fc302c9b075137c26001d0b21bd10e11

Contents?: true

Size: 837 Bytes

Versions: 48

Compression:

Stored size: 837 Bytes

Contents

# 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

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
jets-1.9.7 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.9.6 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.9.5 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.9.4 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.9.3 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.9.2 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.9.1 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.9.0 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.8.14 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.8.13 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.8.12 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.8.11 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.8.10 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.8.9 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.8.8 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.8.7 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.8.6 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.8.5 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.8.4 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb
jets-1.8.3 vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb