Sha256: ca9bdeaadc2ffd044bc3765c950449c27aa0cab7ccf7756c89de93a14853ef6c
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
require 'test_helper' class GroupsControllerTest < ActionController::TestCase setup do I18n.locale = :en end test "on POST create as csv" do post :create, group: {file: fixture_file_upload('groups.csv')} expects = { 'Python' => [{name: 'atsushi', age: 30}, {name: 'taro', age: 10}], 'Perl' => [{name: 'atsushi', age: 30}, {name: 'yoshida', age: 40}] } assert_equal 2, Group.count assert_equal 3, User.count expects.each do |group_name, members| group = Group.find_by_name(group_name) assert_equal group_name, group.name members.each do |member| assert_equal member[:age], group.users.where(name: member[:name]).first.age end end end test "on POST create as csv includes wrong user name" do post :create, group: {file: fixture_file_upload('groups_includes_wrong_user_name.csv')} assert_equal 0, Group.count assert_equal 0, User.count assigns(:groups).last.users.each do |user| assert_equal "Name can't be blank", user.errors.full_messages.first end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csv_rails-0.7.0 | test/dummy/test/functional/groups_controller_test.rb |