diff options
Diffstat (limited to 't/app/model')
-rw-r--r-- | t/app/model/alert_type.t | 8 | ||||
-rw-r--r-- | t/app/model/comment.t | 9 | ||||
-rw-r--r-- | t/app/model/db.t | 5 | ||||
-rw-r--r-- | t/app/model/defecttype.t | 80 | ||||
-rw-r--r-- | t/app/model/extra.t | 56 | ||||
-rw-r--r-- | t/app/model/moderation.t | 6 | ||||
-rw-r--r-- | t/app/model/photoset.t | 11 | ||||
-rw-r--r-- | t/app/model/problem.t | 30 | ||||
-rw-r--r-- | t/app/model/questionnaire.t | 7 | ||||
-rw-r--r-- | t/app/model/rabx_column.t | 5 | ||||
-rw-r--r-- | t/app/model/responsepriority.t | 103 | ||||
-rw-r--r-- | t/app/model/state.t | 83 | ||||
-rw-r--r-- | t/app/model/token.t | 5 | ||||
-rw-r--r-- | t/app/model/user.t | 35 | ||||
-rw-r--r-- | t/app/model/user_planned_report.t | 15 |
15 files changed, 345 insertions, 113 deletions
diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t index 5e4fcec0a..c978b5ccf 100644 --- a/t/app/model/alert_type.t +++ b/t/app/model/alert_type.t @@ -1,10 +1,5 @@ -use strict; -use warnings; -use Test::More; use FixMyStreet::TestMech; -mySociety::Locale::gettext_domain( 'FixMyStreet' ); - my $mech = FixMyStreet::TestMech->new(); # this is the easiest way to make sure we're not going @@ -507,8 +502,5 @@ subtest "correct i18n-ed summary for state of closed" => sub { }; END { - $mech->delete_user($user) if $user; - $mech->delete_user($user2) if $user2; - $mech->delete_user($user3) if $user3; done_testing(); } diff --git a/t/app/model/comment.t b/t/app/model/comment.t index e83d795fc..3f30b3a1e 100644 --- a/t/app/model/comment.t +++ b/t/app/model/comment.t @@ -1,10 +1,4 @@ -use strict; -use warnings; - -use Test::More tests => 2; - -use FixMyStreet; -use FixMyStreet::DB; +use FixMyStreet::Test; my $comment_rs = FixMyStreet::DB->resultset('Comment'); @@ -23,3 +17,4 @@ my $comment = $comment_rs->new( is $comment->confirmed, undef, 'inflating null confirmed ok'; is $comment->created, undef, 'inflating null confirmed ok'; +done_testing(); diff --git a/t/app/model/db.t b/t/app/model/db.t index bebd68f0b..191058bbe 100644 --- a/t/app/model/db.t +++ b/t/app/model/db.t @@ -1,7 +1,4 @@ -use strict; -use warnings; - -use Test::More; +use FixMyStreet::Test; use_ok 'FixMyStreet::App::Model::DB'; diff --git a/t/app/model/defecttype.t b/t/app/model/defecttype.t index 0f66ac684..4f380db59 100644 --- a/t/app/model/defecttype.t +++ b/t/app/model/defecttype.t @@ -1,29 +1,35 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::App; use FixMyStreet::TestMech; +use JSON::MaybeXS; + my $mech = FixMyStreet::TestMech->new; +my $area_id = 2237; -my $oxfordshire = $mech->create_body_ok(2237, 'Oxfordshire County Council', id => 2237); +my $oxfordshire = $mech->create_body_ok($area_id, 'Oxfordshire County Council'); +my $other_body = $mech->create_body_ok($area_id, 'Some Other Council'); my $potholes_contact = $mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Potholes', email => 'potholes@example.com' ); my $traffic_lights_contact =$mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Traffic lights', email => 'lights@example.com' ); +my $pavements_contact =$mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Pavements', email => 'pavements@example.com' ); my $potholes_defect_type = FixMyStreet::App->model('DB::DefectType')->find_or_create( { - body_id => 2237, - name => 'Potholes', - description => 'This defect type is to do with potholes' + body_id => $oxfordshire->id, + name => 'Potholes and Pavements', + description => 'This defect type is to do with potholes and Pavements' } ); +$potholes_defect_type->set_extra_metadata('defect_code' => 123); $potholes_defect_type->contact_defect_types->find_or_create({ contact_id => $potholes_contact->id, }); +$potholes_defect_type->contact_defect_types->find_or_create({ + contact_id => $pavements_contact->id, +}); +$potholes_defect_type->update(); my $general_defect_type = FixMyStreet::App->model('DB::DefectType')->find_or_create( { - body_id => 2237, + body_id => $oxfordshire->id, name => 'All categories', description => 'This defect type is for all categories' } @@ -59,9 +65,61 @@ subtest 'Problem->defect_types behaves correctly' => sub { is $problem->defect_types->first->name, $general_defect_type->name, 'Correct defect type is returned for Traffic lights category'; }; +subtest 'by_categories returns all defect types grouped by category' => sub { + my @contacts = FixMyStreet::DB->resultset('Contact')->not_deleted->search( { body_id => [ $oxfordshire->id ] } )->all; + my $defect_types = FixMyStreet::App->model('DB::DefectType')->by_categories($area_id, @contacts); + my $potholes = decode_json($defect_types->{Potholes}); + my $traffic_lights = decode_json($defect_types->{'Traffic lights'}); + my $pavements = decode_json($defect_types->{Pavements}); -END { - $mech->delete_body( $oxfordshire ); + is scalar @$potholes, 2, 'Potholes have 2 defect types'; + is scalar @$traffic_lights, 1, 'Traffic lights have 1 defect type'; + is scalar @$pavements, 2, 'Pavements have 2 defect types'; + + is @$potholes[1]->{extra}->{defect_code}, 123, 'Defect code is present'; +}; + +subtest 'by_categories returns defect types for an area with multiple bodies' => sub { + FixMyStreet::App->model('DB::DefectType')->find_or_create( + { + body_id => $other_body->id, + name => 'All categories', + description => 'This defect type is for all categories' + } + ); + + my @contacts = FixMyStreet::DB->resultset('Contact')->not_deleted->search( { body_id => [ $oxfordshire->id ] } )->all; + my $defect_types = FixMyStreet::App->model('DB::DefectType')->by_categories($area_id, @contacts); + my $potholes = decode_json($defect_types->{Potholes}); + my $traffic_lights = decode_json($defect_types->{'Traffic lights'}); + my $pavements = decode_json($defect_types->{Pavements}); + is scalar @$potholes, 3, 'Potholes have 3 defect types'; + is scalar @$traffic_lights, 2, 'Traffic lights have 2 defect type'; + is scalar @$pavements, 3, 'Pavements have 3 defect types'; +}; + +subtest 'by_categories encodes HTML entities' => sub { + my $apostrophe_defect_type = FixMyStreet::App->model('DB::DefectType')->find_or_create( + { + body_id => $oxfordshire->id, + name => 'This defect type\'s name has an apostrophe', + description => 'This defect type is for all categories' + } + ); + $apostrophe_defect_type->set_extra_metadata('defect_code' => 'Here\'s an apostrophe'); + $apostrophe_defect_type->update(); + + my @contacts = FixMyStreet::DB->resultset('Contact')->not_deleted->search( { body_id => [ $oxfordshire->id ] } )->all; + my $defect_types = FixMyStreet::App->model('DB::DefectType')->by_categories($area_id, @contacts); + my $traffic_lights = decode_json($defect_types->{'Traffic lights'}); + my $defect_type = @$traffic_lights[2]; + is $defect_type->{name}, 'This defect type's name has an apostrophe'; + is $defect_type->{extra}->{defect_code}, 'Here's an apostrophe'; + +}; + + +END { done_testing(); } diff --git a/t/app/model/extra.t b/t/app/model/extra.t index 3b46ce128..a5e3e3574 100644 --- a/t/app/model/extra.t +++ b/t/app/model/extra.t @@ -1,14 +1,8 @@ -use strict; -use warnings; -use Test::More; -use utf8; +use FixMyStreet::Test; -use FixMyStreet::DB; -use Data::Dumper; use DateTime; -my $db = FixMyStreet::DB->connect; -$db->txn_begin; +my $db = FixMyStreet::DB->schema; my $body = $db->resultset('Body')->create({ name => 'ExtraTestingBody' }); @@ -19,8 +13,7 @@ sub get_test_contact { category => "Testing ${serial}", body => $body, email => 'test@example.com', - confirmed => 1, - deleted => 0, + state => 'confirmed', editor => 'test script', note => 'test script', whenedited => DateTime->now(), @@ -105,5 +98,46 @@ subtest 'Default hash layout' => sub { }; }; -$db->txn_rollback; +subtest 'Get named field values' => sub { + my $user = $db->resultset('User')->create({ + email => 'test-moderation@example.com', + name => 'Test User' + }); + my $report = $db->resultset('Problem')->create( + { + postcode => 'BR1 3SB', + bodies_str => "", + areas => "", + category => 'Other', + title => 'Good bad good', + detail => 'Good bad bad bad good bad', + used_map => 't', + name => 'Test User 2', + anonymous => 'f', + state => 'confirmed', + lang => 'en-gb', + service => '', + cobrand => 'default', + latitude => '51.4129', + longitude => '0.007831', + user_id => $user->id, + }); + + $report->push_extra_fields( + { + name => "field1", + description => "This is a test field", + value => "value 1", + }, + { + name => "field 2", + description => "Another test", + value => "this is a test value", + } + ); + + is $report->get_extra_field_value("field1"), "value 1", "field1 has correct value"; + is $report->get_extra_field_value("field 2"), "this is a test value", "field 2 has correct value"; +}; + done_testing(); diff --git a/t/app/model/moderation.t b/t/app/model/moderation.t index 8fa333db4..973b9a70a 100644 --- a/t/app/model/moderation.t +++ b/t/app/model/moderation.t @@ -1,11 +1,7 @@ -use strict; -use warnings; -use Test::More; +use FixMyStreet::Test; use Test::Exception; -use utf8; use FixMyStreet::DB; -use Data::Dumper; use DateTime; my $dt = DateTime->now; diff --git a/t/app/model/photoset.t b/t/app/model/photoset.t index 54530adfb..4aa5c8992 100644 --- a/t/app/model/photoset.t +++ b/t/app/model/photoset.t @@ -1,8 +1,5 @@ -use strict; -use warnings; -use Test::More; +use FixMyStreet::Test; use Test::Exception; -use utf8; use FixMyStreet::DB; use DateTime; @@ -13,7 +10,7 @@ my $dt = DateTime->now; my $UPLOAD_DIR = tempdir( CLEANUP => 1 ); -my $db = FixMyStreet::DB->storage->schema; +my $db = FixMyStreet::DB->schema; my $user = $db->resultset('User')->find_or_create({ name => 'Bob', email => 'bob@example.com', @@ -23,8 +20,6 @@ FixMyStreet::override_config { UPLOAD_DIR => $UPLOAD_DIR, }, sub { -$db->txn_begin; - my $image_path = path('t/app/controller/sample.jpg'); sub make_report { @@ -74,8 +69,6 @@ subtest 'Photoset with 3 referenced photo' => sub { is $photoset->num_images, 3, 'Found 3 images'; }; -$db->txn_rollback; - }; done_testing(); diff --git a/t/app/model/problem.t b/t/app/model/problem.t index 6b1be0a76..efc9057da 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -1,17 +1,9 @@ -use strict; -use warnings; - -use Test::More; - use FixMyStreet::TestMech; use FixMyStreet; use FixMyStreet::App; use FixMyStreet::DB; -use mySociety::Locale; use Sub::Override; -mySociety::Locale::gettext_domain('FixMyStreet'); - my $problem_rs = FixMyStreet::DB->resultset('Problem'); my $problem = $problem_rs->new( @@ -122,15 +114,6 @@ for my $test ( } }, { - desc => 'bad category', - changed => { - category => '-- Pick a property type --', - }, - errors => { - category => 'Please choose a property type', - } - }, - { desc => 'correct category', changed => { category => 'Horse!', @@ -430,7 +413,7 @@ for my $contact ( { category => 'Graffiti', email => 'highways@example.net', }, { - confirmed => 0, + state => 'unconfirmed', body_id => $body_ids{2636}, # Isle of Wight category => 'potholes', email => '2636@example.com', @@ -531,7 +514,6 @@ foreach my $test ( { my $override = { ALLOWED_COBRANDS => [ 'fixmystreet' ], BASE_URL => 'http://www.fixmystreet.com', - MAPIT_URL => 'http://mapit.mysociety.org/', }; if ( $test->{cobrand} && $test->{cobrand} =~ /hart/ ) { $override->{ALLOWED_COBRANDS} = [ 'hart' ]; @@ -607,8 +589,6 @@ foreach my $test ( { subtest 'check can set mutiple emails as a single contact' => sub { my $override = { ALLOWED_COBRANDS => [ 'fixmystreet' ], - BASE_URL => 'http://www.fixmystreet.com', - MAPIT_URL => 'http://mapit.mysociety.org/', }; my $contact = { @@ -793,6 +773,8 @@ subtest 'check duplicate reports' => sub { $problem1->set_extra_metadata(duplicate_of => $problem2->id); $problem1->state('duplicate'); $problem1->update; + $problem2->set_extra_metadata(duplicates => [ $problem1->id ]); + $problem2->update; is $problem1->duplicate_of->title, $problem2->title, 'problem1 returns correct problem from duplicate_of'; is scalar @{ $problem2->duplicates }, 1, 'problem2 has correct number of duplicates'; @@ -883,11 +865,5 @@ subtest 'return how many days ago a problem was reported' => sub { }; END { - $problem->comments->delete if $problem; - $problem->delete if $problem; - $mech->delete_user( $user ) if $user; - - $mech->delete_body($_) for @bodies; - done_testing(); } diff --git a/t/app/model/questionnaire.t b/t/app/model/questionnaire.t index 945a64633..169895f95 100644 --- a/t/app/model/questionnaire.t +++ b/t/app/model/questionnaire.t @@ -1,8 +1,3 @@ -use strict; -use warnings; - -use Test::More; - use FixMyStreet; use FixMyStreet::TestMech; @@ -113,6 +108,4 @@ for my $test ( } } -$mech->delete_user( $user ); - done_testing(); diff --git a/t/app/model/rabx_column.t b/t/app/model/rabx_column.t index 607d578ce..9232a92f0 100644 --- a/t/app/model/rabx_column.t +++ b/t/app/model/rabx_column.t @@ -1,7 +1,4 @@ -use strict; -use warnings; - -use Test::More; +use FixMyStreet::Test; use_ok "FixMyStreet::DB::RABXColumn"; diff --git a/t/app/model/responsepriority.t b/t/app/model/responsepriority.t new file mode 100644 index 000000000..03c5bccae --- /dev/null +++ b/t/app/model/responsepriority.t @@ -0,0 +1,103 @@ +use strict; +use warnings; +use Test::More; + +use FixMyStreet::App; +use FixMyStreet::TestMech; +use JSON::MaybeXS; + +my $mech = FixMyStreet::TestMech->new; +my $area_id = 2237; + +my $oxfordshire = $mech->create_body_ok($area_id, 'Oxfordshire County Council'); +my $other_body = $mech->create_body_ok($area_id, 'Some Other Council'); +my $potholes_contact = $mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Potholes', email => 'potholes@example.com' ); +my $traffic_lights_contact =$mech->create_contact_ok( body_id => $oxfordshire->id, category => 'Traffic lights', email => 'lights@example.com' ); + +my $potholes_response_priority = FixMyStreet::App->model('DB::ResponsePriority')->find_or_create( + { + body_id => $oxfordshire->id, + name => 'Potholes', + description => 'This priority is to do with potholes' + } +); +$potholes_response_priority->contact_response_priorities->find_or_create({ + contact_id => $potholes_contact->id, +}); + +my $general_response_priority = FixMyStreet::App->model('DB::ResponsePriority')->find_or_create( + { + body_id => $oxfordshire->id, + name => 'All categories', + description => 'This priority is for all categories' + } +); + +subtest 'for_bodies returns correct results' => sub { + my $priorities = FixMyStreet::App->model('DB::ResponsePriority')->for_bodies( + [ $oxfordshire->id ], + 'Potholes' + ); + + is $priorities->count, 2, 'Both priorities are included for Potholes category'; + + $priorities = FixMyStreet::App->model('DB::ResponsePriority')->for_bodies( + [ $oxfordshire->id ], + 'Traffic lights' + ); + + is $priorities->count, 1, 'Only 1 priority is included for Traffic lights category'; + is $priorities->first->name, $general_response_priority->name, 'Correct priority is returned for Traffic lights category'; +}; + +subtest 'by_categories returns allresponse priorities grouped by category' => sub { + my @contacts = FixMyStreet::DB->resultset('Contact')->not_deleted->search( { body_id => [ $oxfordshire->id ] } )->all; + my $priorities = FixMyStreet::App->model('DB::ResponsePriority')->by_categories($area_id, @contacts); + my $potholes = decode_json($priorities->{Potholes}); + my $traffic_lights = decode_json($priorities->{'Traffic lights'}); + + is scalar @$potholes, 2, 'Potholes have 2 defect types'; + is scalar @$traffic_lights, 1, 'Traffic lights have 1 defect type'; +}; + +subtest 'by_categories returns all response priorities for an area with multiple bodies' => sub { + my $other_response_priority = FixMyStreet::App->model('DB::ResponsePriority')->find_or_create( + { + body_id => $other_body->id, + name => 'All categories', + description => 'This priority is for all categories' + } + ); + + my @contacts = FixMyStreet::DB->resultset('Contact')->not_deleted->search( { body_id => [ $oxfordshire->id ] } )->all; + my $priorities = FixMyStreet::App->model('DB::ResponsePriority')->by_categories($area_id, @contacts); + my $potholes = decode_json($priorities->{Potholes}); + my $traffic_lights = decode_json($priorities->{'Traffic lights'}); + + is scalar @$potholes, 3, 'Potholes have 3 defect types'; + is scalar @$traffic_lights, 2, 'Traffic lights have 2 defect types'; +}; + +subtest 'by_categories encodes HTML entities' => sub { + FixMyStreet::App->model('DB::ResponsePriority')->find_or_create( + { + body_id => $other_body->id, + name => 'This priority\'s name has an apostrophe', + description => 'This priority is for all categories' + } + ); + + my @contacts = FixMyStreet::DB->resultset('Contact')->not_deleted->search( { body_id => [ $oxfordshire->id ] } )->all; + my $priorities = FixMyStreet::App->model('DB::ResponsePriority')->by_categories($area_id, @contacts); + + my $traffic_lights = decode_json($priorities->{'Traffic lights'}); + use Data::Dumper; + my $priority = @$traffic_lights[2]; + is $priority->{name}, 'This priority's name has an apostrophe'; +}; + +END { + $mech->delete_body( $other_body ); + $mech->delete_body( $oxfordshire ); + done_testing(); +} diff --git a/t/app/model/state.t b/t/app/model/state.t new file mode 100644 index 000000000..35f3d4fb3 --- /dev/null +++ b/t/app/model/state.t @@ -0,0 +1,83 @@ +use FixMyStreet::Test; +use FixMyStreet::Cobrand; + +my $rs = FixMyStreet::DB->resultset('State'); +my $trans_rs = FixMyStreet::DB->resultset('Translation'); + +for ( + { label => 'in progress', lang => 'de' }, + { label => 'investigating', lang => 'fr' }, + { label => 'duplicate', lang => 'de' }, +) { + my $lang = $_->{lang}; + my $obj = $rs->find({ label => $_->{label} }); + $trans_rs->create({ tbl => 'state', col => 'name', object_id => $obj->id, + lang => $lang, msgstr => "$lang $_->{label}" }); +} +$trans_rs->create({ tbl => 'state', col => 'name', object_id => -1, lang => 'en-gb', msgstr => "Open Eng trans" }); + +$rs->clear; + +my $states = $rs->states; +my %states = map { $_->label => $_ } @$states; + +subtest 'Open/closed database data is as expected' => sub { + my $open = $rs->open; + is @$open, 5; + my $closed = $rs->closed; + is @$closed, 5; +}; + +# No language set at this point + +is $rs->display('investigating'), 'Investigating'; +is $rs->display('bad'), 'bad'; +is $rs->display('confirmed'), 'Open'; +is $rs->display('closed'), 'Closed'; +is $rs->display('fixed - council'), 'Fixed - Council'; +is $rs->display('fixed - user'), 'Fixed - User'; +is $rs->display('fixed'), 'Fixed'; + +subtest 'default name is untranslated' => sub { + is $states{'in progress'}->name, 'In progress'; + is $states{'in progress'}->msgstr, 'In progress'; + is $states{'action scheduled'}->name, 'Action scheduled'; + is $states{'action scheduled'}->msgstr, 'Action scheduled'; +}; + +subtest 'msgstr gets translated if available when the language changes' => sub { + FixMyStreet::DB->schema->lang('en-gb'); + is $states{confirmed}->name, 'Open'; + is $states{confirmed}->msgstr, 'Open Eng trans'; + FixMyStreet::DB->schema->lang('de'); + is $states{'in progress'}->name, 'In progress'; + is $states{'in progress'}->msgstr, 'de in progress'; + is $states{'investigating'}->name, 'Investigating'; + is $states{'investigating'}->msgstr, 'Investigating'; + is $states{'unable to fix'}->name, 'No further action'; + is $states{'unable to fix'}->msgstr, 'No further action'; +}; + +is_deeply [ sort FixMyStreet::DB::Result::Problem->open_states ], + ['action scheduled', 'confirmed', 'in progress', 'investigating', 'planned'], 'open states okay'; +is_deeply [ sort FixMyStreet::DB::Result::Problem->closed_states ], + ['closed', 'duplicate', 'internal referral', 'not responsible', 'unable to fix'], 'closed states okay'; +is_deeply [ sort FixMyStreet::DB::Result::Problem->fixed_states ], + ['fixed', 'fixed - council', 'fixed - user'], 'fixed states okay'; + +FixMyStreet::override_config { + LANGUAGES => [ 'en-gb,English,en_GB', 'nb,Norwegian,nb_NO' ], +}, sub { + subtest 'translation of open works both ways (file/db)' => sub { + # Note at this point the states have been cached + my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('default')->new; + my $lang = $cobrand->set_lang_and_domain('nb', 1, FixMyStreet->path_to('locale')->stringify); + is $lang, 'nb'; + is $rs->display('confirmed'), "Ă…pen"; + $lang = $cobrand->set_lang_and_domain('en-gb', 1, FixMyStreet->path_to('locale')->stringify); + is $lang, 'en-gb'; + is $rs->display('confirmed'), "Open Eng trans"; + }; +}; + +done_testing(); diff --git a/t/app/model/token.t b/t/app/model/token.t index e31901187..60b170a26 100644 --- a/t/app/model/token.t +++ b/t/app/model/token.t @@ -1,7 +1,4 @@ -use strict; -use warnings; - -use Test::More; +use FixMyStreet::Test; use FixMyStreet; use FixMyStreet::DB; diff --git a/t/app/model/user.t b/t/app/model/user.t index d4115d586..5a9c898a2 100644 --- a/t/app/model/user.t +++ b/t/app/model/user.t @@ -1,8 +1,3 @@ -use strict; -use warnings; - -use Test::More; - use FixMyStreet::TestMech; use FixMyStreet::DB; @@ -30,6 +25,35 @@ is $problem->user->latest_anonymity, 0, "User's last update was not anonyous"; create_update($problem, anonymous => 't'); is $problem->user->latest_anonymity, 1, "User's last update was anonymous"; +subtest "Sign user up for alerts" => sub { + my $user = $problem->user; + + my $alert_exists = $user->alert_for_problem( $problem->id ); + is !defined( $alert_exists ), 1, "No current alerts exist"; + + my $options = { + cobrand => 'default', + lang => 'en-gb', + }; + $user->create_alert($problem->id, $options); + my $alert = $user->alert_for_problem( $problem->id ); + + is defined( $alert ), 1, "User is signed up for alerts"; + is $alert->confirmed, 1, "Alert is confirmed"; + + $alert->delete(); + + $user->alerts->create({ + alert_type => 'new_updates', + parameter => $problem->id, + }); + + $user->create_alert($problem->id, $options); + + my $new_alert = $user->alert_for_problem( $problem->id ); + is $alert->confirmed, 1, "Already created alert is confirmed"; +}; + FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], MAPIT_URL => 'http://mapit.uk/', @@ -40,7 +64,6 @@ FixMyStreet::override_config { }; END { - $mech->delete_user( $problem->user ) if $problem; done_testing(); } diff --git a/t/app/model/user_planned_report.t b/t/app/model/user_planned_report.t index 95a76615e..e51552e5c 100644 --- a/t/app/model/user_planned_report.t +++ b/t/app/model/user_planned_report.t @@ -1,8 +1,3 @@ -use strict; -use warnings; - -use Test::More; - use FixMyStreet::TestMech; use FixMyStreet::DB; @@ -19,6 +14,7 @@ is $user->planned_reports, 0; $user->add_to_planned_reports($problem); is $user->active_planned_reports, 1; is $user->planned_reports, 1; +is $user->is_planned_report($problem), 1; $user->add_to_planned_reports($problem); is $user->active_planned_reports, 1; @@ -27,10 +23,14 @@ is $user->planned_reports, 1; $user->remove_from_planned_reports($problem); is $user->active_planned_reports, 0; is $user->planned_reports, 1; +$user->discard_changes; +is $user->is_planned_report($problem), 0; $user->add_to_planned_reports($problem); is $user->active_planned_reports, 1; is $user->planned_reports, 2; +$user->discard_changes; +is $user->is_planned_report($problem), 1; $user2->add_to_planned_reports($problem); is $user->active_planned_reports, 0; @@ -45,8 +45,3 @@ is $user2->active_planned_reports, 0; is $user2->planned_reports, 1; done_testing(); - -END { - $mech->delete_user($user); - $mech->delete_user($user2); -} |