aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/model
diff options
context:
space:
mode:
Diffstat (limited to 't/app/model')
-rw-r--r--t/app/model/defecttype.t15
-rw-r--r--t/app/model/problem.t5
-rw-r--r--t/app/model/responsepriority.t15
-rw-r--r--t/app/model/responsetemplate.t2
-rw-r--r--t/app/model/user.t2
5 files changed, 18 insertions, 21 deletions
diff --git a/t/app/model/defecttype.t b/t/app/model/defecttype.t
index e924129e2..ec40f6dbc 100644
--- a/t/app/model/defecttype.t
+++ b/t/app/model/defecttype.t
@@ -1,4 +1,3 @@
-use FixMyStreet::App;
use FixMyStreet::TestMech;
use JSON::MaybeXS;
@@ -11,7 +10,7 @@ my $potholes_contact = $mech->create_contact_ok( body_id => $oxfordshire->id, ca
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(
+my $potholes_defect_type = FixMyStreet::DB->resultset('DefectType')->find_or_create(
{
body_id => $oxfordshire->id,
name => 'Potholes and Pavements',
@@ -27,7 +26,7 @@ $potholes_defect_type->contact_defect_types->find_or_create({
});
$potholes_defect_type->update();
-my $general_defect_type = FixMyStreet::App->model('DB::DefectType')->find_or_create(
+my $general_defect_type = FixMyStreet::DB->resultset('DefectType')->find_or_create(
{
body_id => $oxfordshire->id,
name => 'All categories',
@@ -37,14 +36,14 @@ my $general_defect_type = FixMyStreet::App->model('DB::DefectType')->find_or_cre
subtest 'for_bodies returns correct results' => sub {
- my $defect_types = FixMyStreet::App->model('DB::DefectType')->for_bodies(
+ my $defect_types = FixMyStreet::DB->resultset('DefectType')->for_bodies(
[ $oxfordshire->id ],
'Potholes'
);
is $defect_types->count, 2, 'Both defect types are included for Potholes category';
- $defect_types = FixMyStreet::App->model('DB::DefectType')->for_bodies(
+ $defect_types = FixMyStreet::DB->resultset('DefectType')->for_bodies(
[ $oxfordshire->id ],
'Traffic lights'
);
@@ -67,7 +66,7 @@ subtest 'Problem->defect_types behaves correctly' => sub {
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 $defect_types = FixMyStreet::DB->resultset('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});
@@ -80,7 +79,7 @@ subtest 'by_categories returns all defect types grouped by category' => sub {
};
subtest 'by_categories returns defect types for an area with multiple bodies' => sub {
- FixMyStreet::App->model('DB::DefectType')->find_or_create(
+ FixMyStreet::DB->resultset('DefectType')->find_or_create(
{
body_id => $other_body->id,
name => 'All categories',
@@ -89,7 +88,7 @@ subtest 'by_categories returns defect types for an area with multiple bodies' =>
);
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 $defect_types = FixMyStreet::DB->resultset('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});
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index 18557f44a..661a8827f 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -1,6 +1,5 @@
use FixMyStreet::TestMech;
use FixMyStreet;
-use FixMyStreet::App;
use FixMyStreet::DB;
use FixMyStreet::Script::Reports;
use Sub::Override;
@@ -785,7 +784,7 @@ subtest 'generates a tokenised url for a user' => sub {
like $url, qr/\/M\//, 'problem generates tokenised url';
- my $token_obj = FixMyStreet::App->model('DB::Token')->find( {
+ my $token_obj = FixMyStreet::DB->resultset('Token')->find( {
scope => 'email_sign_in', token => $token
} );
is $token, $token_obj->token, 'token is generated in database with correct scope';
@@ -797,7 +796,7 @@ subtest 'stores params in a token' => sub {
my $url = $problem->tokenised_url($user, { foo => 'bar', baz => 'boo'});
(my $token = $url) =~ s/\/M\///g;
- my $token_obj = FixMyStreet::App->model('DB::Token')->find( {
+ my $token_obj = FixMyStreet::DB->resultset('Token')->find( {
scope => 'email_sign_in', token => $token
} );
diff --git a/t/app/model/responsepriority.t b/t/app/model/responsepriority.t
index 4e624bf07..c7a4fe210 100644
--- a/t/app/model/responsepriority.t
+++ b/t/app/model/responsepriority.t
@@ -2,7 +2,6 @@ use strict;
use warnings;
use Test::More;
-use FixMyStreet::App;
use FixMyStreet::TestMech;
use JSON::MaybeXS;
@@ -14,7 +13,7 @@ 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(
+my $potholes_response_priority = FixMyStreet::DB->resultset('ResponsePriority')->find_or_create(
{
body_id => $oxfordshire->id,
name => 'Potholes',
@@ -25,7 +24,7 @@ $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(
+my $general_response_priority = FixMyStreet::DB->resultset('ResponsePriority')->find_or_create(
{
body_id => $oxfordshire->id,
name => 'All categories',
@@ -34,14 +33,14 @@ my $general_response_priority = FixMyStreet::App->model('DB::ResponsePriority')-
);
subtest 'for_bodies returns correct results' => sub {
- my $priorities = FixMyStreet::App->model('DB::ResponsePriority')->for_bodies(
+ my $priorities = FixMyStreet::DB->resultset('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(
+ $priorities = FixMyStreet::DB->resultset('ResponsePriority')->for_bodies(
[ $oxfordshire->id ],
'Traffic lights'
);
@@ -52,7 +51,7 @@ subtest 'for_bodies returns correct results' => sub {
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 $priorities = FixMyStreet::DB->resultset('ResponsePriority')->by_categories($area_id, @contacts);
my $potholes = decode_json($priorities->{Potholes});
my $traffic_lights = decode_json($priorities->{'Traffic lights'});
@@ -61,7 +60,7 @@ subtest 'by_categories returns allresponse priorities grouped by category' => su
};
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(
+ my $other_response_priority = FixMyStreet::DB->resultset('ResponsePriority')->find_or_create(
{
body_id => $other_body->id,
name => 'All categories',
@@ -70,7 +69,7 @@ subtest 'by_categories returns all response priorities for an area with multiple
);
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 $priorities = FixMyStreet::DB->resultset('ResponsePriority')->by_categories($area_id, @contacts);
my $potholes = decode_json($priorities->{Potholes});
my $traffic_lights = decode_json($priorities->{'Traffic lights'});
diff --git a/t/app/model/responsetemplate.t b/t/app/model/responsetemplate.t
index fbabc1c12..631af9819 100644
--- a/t/app/model/responsetemplate.t
+++ b/t/app/model/responsetemplate.t
@@ -16,7 +16,7 @@ $t2->add_to_contacts($c2);
my @contacts = FixMyStreet::DB->resultset('Contact')->not_deleted->search( { body_id => [ $body->id ] } )->all;
subtest 'by_categories returns allresponse templates grouped by category' => sub {
- my $templates = FixMyStreet::App->model('DB::ResponseTemplate')->by_categories($area_id, @contacts);
+ my $templates = FixMyStreet::DB->resultset('ResponseTemplate')->by_categories($area_id, @contacts);
my $potholes = decode_json($templates->{Potholes});
my $graffiti = decode_json($templates->{Graffiti});
diff --git a/t/app/model/user.t b/t/app/model/user.t
index c1981c858..929020d4b 100644
--- a/t/app/model/user.t
+++ b/t/app/model/user.t
@@ -105,7 +105,7 @@ done_testing();
sub create_update {
my ($problem, %params) = @_;
my $dt = DateTime->now()->add(days => 1);
- return FixMyStreet::App->model('DB::Comment')->find_or_create({
+ return FixMyStreet::DB->resultset('Comment')->find_or_create({
problem_id => $problem->id,
user_id => $problem->user_id,
name => 'Other User',