aboutsummaryrefslogtreecommitdiffstats
path: root/t/map/tilma/original.t
blob: 04c4d578caf64d9509aa8f4353553bcd179fd0d6 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/perl

use strict;
use warnings;
use Test::More;
use FixMyStreet::App;
use FixMyStreet::Map;
use FixMyStreet::TestMech;
use DateTime;
use mySociety::Locale;

my $mech = FixMyStreet::TestMech->new;

mySociety::Locale::gettext_domain('FixMyStreet');

FixMyStreet::Map::set_map_class();
my $r = Catalyst::Request->new( { base => URI->new('/'), uri => URI->new('http://fixmystreet.com/test'), parameters => { bbox => '-7.6,49.7,-7.5,49.8' } } );

my $c = FixMyStreet::App->new( {
    request => $r,
});

$mech->delete_user('test@example.com');
my $user =
  FixMyStreet::App->model('DB::User')
  ->find_or_create( { email => 'test@example.com', name => 'Test User' } );
ok $user, "created test user";

my $dt = DateTime->now();


my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
    {
        postcode           => 'SW1A 1AA',
        council            => '2504',
        areas              => ',105255,11806,11828,2247,2504,',
        category           => 'Other',
        title              => 'Test 2',
        detail             => 'Test 2 Detail',
        used_map           => 't',
        name               => 'Test User',
        anonymous          => 'f',
        state              => 'fixed',
        confirmed          => $dt->ymd . ' ' . $dt->hms,
        lang               => 'en-gb',
        service            => '',
        cobrand            => 'default',
        cobrand_data       => '',
        send_questionnaire => 't',
        latitude           => '49.7668057243776',
        longitude          => '-7.55715980363992',
        user_id            => $user->id,
    }
);

for my $test ( 
    {
        state => 'fixed', 
        colour => 'yellow',
    },
    {
        state => 'fixed - user', 
        colour => 'yellow',
    },
    {
        state => 'fixed - council', 
        colour => 'yellow',
    },
    {
        state => 'confirmed', 
        colour => 'yellow',
    },
    {
        state => 'investigating', 
        colour => 'yellow',
    },
    {
        state => 'planned', 
        colour => 'yellow',
    },
    {
        state => 'in progress', 
        colour => 'yellow',
    },
) {
    subtest "pin colour for state $test->{state}" => sub {
        $report->state($test->{state});
        $report->update;

        my ( $pins, $around_map_list, $nearby, $dist ) =
            FixMyStreet::Map::map_pins( $c, 0, 0, 0, 0 );

        ok $pins;
        ok $around_map_list;
        ok $nearby;
        ok $dist;

        my $id = $report->id;
        my $colour = $test->{colour};

        is $pins->[0][2], $colour, 'pin colour';
    };
}

$mech->delete_user( $user );


done_testing();