1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
use FixMyStreet::TestMech;
use LWP::Protocol::PSGI;
use t::Mock::MapItZurich;
my $mech = FixMyStreet::TestMech->new;
# disable info logs for this test run
FixMyStreet::App->log->disable('info');
END { FixMyStreet::App->log->enable('info'); }
LWP::Protocol::PSGI->register(t::Mock::MapItZurich->to_psgi_app, host => 'mapit.zurich');
subtest "Check signed up for alert when logged in" => sub {
FixMyStreet::override_config {
MAPIT_URL => 'http://mapit.zurich',
MAPIT_TYPES => [ 'O08' ],
}, sub {
$mech->log_in_ok('user@example.org');
$mech->post_ok( '/report/new/mobile', {
service => 'iPhone',
title => 'Title',
detail => 'Problem detail',
lat => 47.381817,
lon => 8.529156,
email => 'user@example.org',
pc => '',
name => 'Name',
});
my $res = $mech->response;
ok $res->header('Content-Type') =~ m{^application/json\b}, 'response should be json';
my $user = FixMyStreet::DB->resultset('User')->search({ email => 'user@example.org' })->first;
my $a = FixMyStreet::DB->resultset('Alert')->search({ user_id => $user->id })->first;
isnt $a, undef, 'User is signed up for alert';
};
};
END {
done_testing();
}
|