-
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.
Merge branch 'uiux' into adding-unittests
- Loading branch information
Showing
8 changed files
with
97 additions
and
38 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 |
---|---|---|
|
@@ -21,12 +21,14 @@ $ENV{GADS_NO_FORK} = 1; # Prevent forking during import process | |
$sheet->create_records; | ||
|
||
my $user1 = $schema->resultset('User')->create({ | ||
username => 'test', | ||
email => '[email protected]', | ||
username => '[email protected]', | ||
password => 'test', | ||
}); | ||
|
||
my $user2 = $schema->resultset('User')->create({ | ||
username => 'test2', | ||
email => '[email protected]', | ||
username => '[email protected]', | ||
password => 'test2', | ||
}); | ||
|
||
|
@@ -177,7 +179,8 @@ foreach my $test (@tests) | |
$sheet->create_records; | ||
|
||
my $user = $schema->resultset('User')->create({ | ||
username => 'test', | ||
email => '[email protected]', | ||
username => '[email protected]', | ||
password => 'test', | ||
}); | ||
|
||
|
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, username => $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"); | ||
|
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 |
---|---|---|
|
@@ -261,9 +261,11 @@ sub create_user | |
my $instance_id = $options{instance_id} || $self->instance_id; | ||
my $user_id = $options{user_id}; | ||
|
||
# messy - username and email are madatory when creating user object | ||
my $temp = '[email protected]'; | ||
my $user = $user_id | ||
? $self->schema->resultset('User')->find_or_create({ id => $user_id }) | ||
: $self->schema->resultset('User')->create({}); | ||
? $self->schema->resultset('User')->find_or_create({ id => $user_id, username => $temp, email => $temp }) | ||
: $self->schema->resultset('User')->create({ username => $temp, email => $temp }); | ||
$user_id ||= $user->id; | ||
$user->update({ | ||
username => "user$user_id\@example.com", | ||
|
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