Sha256: 276ff2a8cb9a8b3b4bf0134cfbf8ee305b048cd08a93961c3855fd8a87669a62

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

# -*- coding: utf-8 -*-
require "sixarm_ruby_ramp_test"

class CSVTest < Minitest::Test

  def test_http_headers
    h=CSV.http_headers
    assert_equal('text/csv',h["Content-Type"])
    assert_equal("attachment; filename=\"data.csv\"",h["Content-Disposition"])
  end

  def test_http_headers_with_filename
    h=CSV.http_headers(:filename=>'foo')
    assert_equal('text/csv',h["Content-Type"])
    assert_equal("attachment; filename=\"foo\"",h["Content-Disposition"])
  end

 def test_http_headers_adjust_for_broken_msie_with_request_as_firefox
   headers = {:request => MockRequest.new('HTTP_USER_AGENT' => 'firefox')}
   headers = CSV.http_headers_adjust_for_broken_msie(headers)
   assert_nil headers[:content_type]
   assert_nil headers[:cache]
 end

 def test_http_headers_adjust_for_broken_msie_with_request_as_msie
   headers = {:request => MockRequest.new('HTTP_USER_AGENT' => 'msie')}
   headers = CSV.http_headers_adjust_for_broken_msie(headers)
   assert_equal('text/plain',headers[:content_type])
   assert_equal(false,headers[:cache])
 end

end

class MockRequest

  def initialize(env)
    @env=env
  end

  def env
    @env
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sixarm_ruby_ramp-5.0.2 test/sixarm_ruby_ramp_test/csv_test.rb
sixarm_ruby_ramp-5.0.1 test/sixarm_ruby_ramp_test/csv_test.rb
sixarm_ruby_ramp-5.0.0 test/sixarm_ruby_ramp_test/csv_test.rb
sixarm_ruby_ramp-4.2.7 test/sixarm_ruby_ramp_test/csv_test.rb