blob: 1d4826111cc4000bf8ed582bbf26a523f6a4b65e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
use Test::More;
use Test::Output;
use_ok 'FixMyStreet::Script::CreateSuperuser';
stderr_like { FixMyStreet::Script::CreateSuperuser::createsuperuser(); }
qr/Specify a single email address/, 'Email error shown';
stderr_is { FixMyStreet::Script::CreateSuperuser::createsuperuser('test@example.org'); }
"Specify a password for this new user.\n", 'Password error shown';
stdout_is { FixMyStreet::Script::CreateSuperuser::createsuperuser('test@example.org', 'password'); }
"test\@example.org is now a superuser.\n", 'Correct message shown';
my $user = FixMyStreet::DB->resultset("User")->find({ email => 'test@example.org' });
ok $user, 'user created';
is $user->is_superuser, 1, 'is a superuser';
$user->update({ is_superuser => 0 });
stdout_is { FixMyStreet::Script::CreateSuperuser::createsuperuser('test@example.org'); }
"test\@example.org is now a superuser.\n", 'Correct message shown';
$user->discard_changes;
is $user->is_superuser, 1, 'is a superuser again';
done_testing;
|