Sha256: 1ed598c83cccac7316a26480868f7f6bc80913bf4953fd0b07d4075a3c326be8

Contents?: true

Size: 796 Bytes

Versions: 2

Compression:

Stored size: 796 Bytes

Contents

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 :text => self.formats.inspect
    end
  end

  class TestContentNegotiation < Rack::TestCase
    test "A */* Accept header will return HTML" do
      get "/content_negotiation/basic/hello", {}, "HTTP_ACCEPT" => "*/*"
      assert_body "Hello world */*!"
    end

    test "Not all mimes are converted to symbol" do
      get "/content_negotiation/basic/all", {}, "HTTP_ACCEPT" => "text/plain, mime/another"
      assert_body '[:text, "mime/another"]'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activejob-lock-0.0.2 rails/actionpack/test/controller/new_base/content_negotiation_test.rb
activejob-lock-0.0.1 rails/actionpack/test/controller/new_base/content_negotiation_test.rb