-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tidy up username creation/deletion and add tests
This commit removes username as a parameter for creating and editing users, using just email instead for consistency. It also moves validation checks to the validate() function which is always called, in case the result is updated directly. Tests also added.
- Loading branch information
Showing
5 changed files
with
34 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ my %template = ( | |
surname => 'Bloggs', | ||
firstname => 'Joe', | ||
email => '[email protected]', | ||
username => '[email protected]', | ||
); | ||
|
||
my $user = $schema->resultset('User')->create_user(%template); | ||
|
@@ -29,6 +28,20 @@ my $u = $schema->resultset('User')->find($user_id); | |
|
||
is($u->value, "Bloggs, Joe", "User created successfully"); | ||
|
||
# Check cannot rename to existing user | ||
my $existing = $schema->resultset('User')->next->username; | ||
ok($existing ne $u->username, "Testing username different to that of test"); | ||
try { $u->update({ email => $existing }) }; | ||
like($@, qr/already exists/, "Unable to rename user to existing username"); | ||
|
||
# Check cannot create same username as existing | ||
try { $schema->resultset('User')->create_user(%template, email => $existing) }; | ||
like($@, qr/already exists/, "Unable to create user with existing username"); | ||
|
||
# Same directly in resultset | ||
try { $schema->resultset('User')->create({email => $existing}) }; | ||
like($@, qr/already exists/, "Unable to create user with existing username"); | ||
|
||
$site->update({ register_organisation_mandatory => 1 }); | ||
try { $schema->resultset('User')->create_user(%template, email => '[email protected]') }; | ||
like($@, qr/Please select a Organisation/, "Failed to create user missing org"); | ||
|