diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-05-24 11:24:02 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-05-28 17:19:27 +0100 |
commit | c34949cf7bc386f057781b8d7b7a97c3aa9db2da (patch) | |
tree | 0a9fe2190cb89aeb11e7b38cd5e50ad9b7a6dbff /t/app/controller | |
parent | 71da3960ab0c80ed5dd7a3532216576a3885ccfa (diff) |
User import allowing roles.
Diffstat (limited to 't/app/controller')
-rw-r--r-- | t/app/controller/admin/users_import.t | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/t/app/controller/admin/users_import.t b/t/app/controller/admin/users_import.t new file mode 100644 index 000000000..df8884797 --- /dev/null +++ b/t/app/controller/admin/users_import.t @@ -0,0 +1,34 @@ +use FixMyStreet::TestMech; + +my $mech = FixMyStreet::TestMech->new; + +my $superuser = $mech->create_user_ok('superuser@example.com', name => 'Super User', is_superuser => 1); +my $body = $mech->create_body_ok(2509, 'Haringey Borough Council'); + +$mech->log_in_ok( $superuser->email ); + +my $body_id = $body->id; +my $csv = <<EOF; +name,email,from_body,permissions,roles +Adrian,adrian\@example.org,$body_id,moderate:user_edit, +Belinda,belinda\@example.org,$body_id,,Customer Service +EOF + +FixMyStreet::DB->resultset("Role")->create({ + body => $body, + name => 'Customer Service', +}); + +subtest 'import CSV file' => sub { + $mech->get_ok('/admin/users/import'); + $mech->submit_form_ok({ with_fields => { + csvfile => [ [ undef, 'foo.csv', Content => $csv ], 1], + }}); + $mech->content_contains('Created 2 new users'); + my $a = FixMyStreet::DB->resultset("User")->find({ email => 'adrian@example.org' }); + is $a->user_body_permissions->count, 2; + my $b = FixMyStreet::DB->resultset("User")->find({ email => 'belinda@example.org' }); + is $b->roles->count, 1; +}; + +done_testing(); |