Added output of location on User endpoint, and setting lat/long on user
registration
This commit is contained in:
parent
f1e3756075
commit
202deb9178
6 changed files with 182 additions and 8 deletions
108
t/api/register/location.t
Normal file
108
t/api/register/location.t
Normal file
|
@ -0,0 +1,108 @@
|
|||
use Mojo::Base -strict;
|
||||
|
||||
use FindBin qw/ $Bin /;
|
||||
|
||||
use Test::More;
|
||||
use Mojo::JSON;
|
||||
use Test::Pear::LocalLoop;
|
||||
|
||||
my $framework = Test::Pear::LocalLoop->new(
|
||||
etc_dir => "$Bin/../../etc",
|
||||
);
|
||||
$framework->install_fixtures('full');
|
||||
|
||||
my $t = $framework->framework;
|
||||
my $schema = $t->app->schema;
|
||||
|
||||
$schema->resultset('AccountToken')->populate([
|
||||
{name => 'test1'},
|
||||
{name => 'test2'},
|
||||
{name => 'test3'},
|
||||
]);
|
||||
|
||||
$t->post_ok('/api/register',
|
||||
json => {
|
||||
token => 'test1',
|
||||
usertype => 'customer',
|
||||
full_name => 'New Test User',
|
||||
display_name => 'Testing User New',
|
||||
email => 'newtest@example.com',
|
||||
postcode => 'LA2 0AD',
|
||||
year_of_birth => 2001,
|
||||
password => 'abc123',
|
||||
})
|
||||
->status_is(200)->or($framework->dump_error)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
my $session_key = $framework->login({
|
||||
email => 'newtest@example.com',
|
||||
password => 'abc123',
|
||||
});
|
||||
|
||||
$t->post_ok('/api/user', json => { session_key => $session_key })
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_is('/location', {
|
||||
latitude => 54.02,
|
||||
longitude => -2.80,
|
||||
}
|
||||
);
|
||||
|
||||
$t->post_ok('/api/register',
|
||||
json => {
|
||||
token => 'test2',
|
||||
usertype => 'organisation',
|
||||
email => 'neworg@example.com',
|
||||
password => 'abc123',
|
||||
postcode => 'LA2 0AD',
|
||||
name => 'New Org',
|
||||
street_name => '18 Test Road',
|
||||
town => 'Lancaster',
|
||||
sector => 'A',
|
||||
})
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
$session_key = $framework->login({
|
||||
email => 'neworg@example.com',
|
||||
password => 'abc123',
|
||||
});
|
||||
|
||||
$t->post_ok('/api/user', json => { session_key => $session_key })
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_is('/location', {
|
||||
latitude => 54.02432,
|
||||
longitude => -2.80635,
|
||||
}
|
||||
);
|
||||
|
||||
$t->post_ok('/api/register',
|
||||
json => {
|
||||
token => 'test3',
|
||||
usertype => 'customer',
|
||||
full_name => 'New Test User',
|
||||
display_name => 'Testing User New',
|
||||
email => 'newtest2@example.com',
|
||||
postcode => 'BX1 1AA',
|
||||
year_of_birth => 2001,
|
||||
password => 'abc123',
|
||||
})
|
||||
->status_is(200)->or($framework->dump_error)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
$session_key = $framework->login({
|
||||
email => 'newtest2@example.com',
|
||||
password => 'abc123',
|
||||
});
|
||||
|
||||
$t->post_ok('/api/user', json => { session_key => $session_key })
|
||||
->status_is(200)
|
||||
->json_is('/success', Mojo::JSON->true)
|
||||
->json_is('/location', {
|
||||
latitude => undef,
|
||||
longitude => undef,
|
||||
}
|
||||
);
|
||||
|
||||
done_testing;
|
14
t/api/user.t
14
t/api/user.t
|
@ -40,6 +40,10 @@ $t->post_ok('/api/user', json => { session_key => $session_key })
|
|||
display_name => 'Testing User',
|
||||
email => $email,
|
||||
postcode => 'LA1 1AA',
|
||||
location => {
|
||||
latitude => undef,
|
||||
longitude => undef,
|
||||
},
|
||||
});
|
||||
|
||||
#with wrong password
|
||||
|
@ -80,6 +84,11 @@ $t->post_ok('/api/user', json => { session_key => $session_key })
|
|||
display_name => 'Testing User 2',
|
||||
email => 'test50@example.com',
|
||||
postcode => 'LA1 1AB',
|
||||
location => {
|
||||
latitude => undef,
|
||||
longitude => undef,
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
$t->post_ok('/api/user/account', json => {
|
||||
|
@ -105,6 +114,11 @@ $t->post_ok('/api/user', json => { session_key => $session_key })
|
|||
display_name => 'Testing User 3',
|
||||
email => 'test60@example.com',
|
||||
postcode => 'LA1 1AD',
|
||||
location => {
|
||||
latitude => undef,
|
||||
longitude => undef,
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
$session_key = $framework->login({
|
||||
|
|
Reference in a new issue