Sha256: 10db90a43202373eb202627da1805e945b2e3265f6557f5e6a20338c1db8f57c

Contents?: true

Size: 833 Bytes

Versions: 1

Compression:

Stored size: 833 Bytes

Contents

# -*- coding: utf-8 -*-
require 'test_helper'

class UsersControllerTest < ActionController::TestCase
  setup do
    User.create(:name => 'yalab', :age => '4', :secret => 'secret')
    I18n.locale = :ja
    @fields = [:id, :name, :age, :"groups.first.name"]
  end

  test "should get index with csv format" do
    get :index, :format => 'csv'
    assert_equal User.all.to_a.to_csv(fields: @fields, without_header: true), response.body
  end

  test "should get sjis with csv format" do
    get :sjis, :format => 'csv'
    assert_equal User.all.to_a.to_csv(fields: @fields).encode('SJIS'), response.body
  end

  test "should get index with tsv format" do
    get :index, :format => 'tsv'
    assert_equal User.all.to_a.to_tsv(fields: @fields, without_header: true), response.body
  end

  teardown do
    I18n.locale = :en
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
csv_rails-0.7.0 test/dummy/test/functional/users_controller_test.rb