aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2015-09-25 22:35:39 +0100
committerMatthew Somerville <matthew@mysociety.org>2015-12-02 17:41:35 +0000
commit55412b79394ff1b1cabe368aed67fa8f68680ecc (patch)
tree33657093517818b8ba60f156484ec540f9c4af17 /t
parent0c2a792b154e1b28528db887bbde80b19268b9fe (diff)
Reduce use of FixMyStreet::App.
Command line scripts don't need a full blown app, just database.
Diffstat (limited to 't')
-rw-r--r--t/app/model/alert_type.t54
-rw-r--r--t/app/model/comment.t4
-rw-r--r--t/app/model/extra.t6
-rw-r--r--t/app/model/moderation.t6
-rw-r--r--t/app/model/photoset.t23
-rw-r--r--t/app/model/problem.t32
-rw-r--r--t/app/model/questionnaire.t6
-rw-r--r--t/app/model/token.t4
-rw-r--r--t/app/sendreport/email.t6
-rw-r--r--t/cobrand/bromley.t4
-rw-r--r--t/cobrand/closest.t6
-rw-r--r--t/cobrand/fixamingata.t12
-rw-r--r--t/cobrand/fixmybarangay.t12
-rw-r--r--t/cobrand/get_body_sender.t8
-rw-r--r--t/cobrand/seesomething.t4
-rw-r--r--t/cobrand/zurich.t11
-rw-r--r--t/map/tilma/original.t6
-rw-r--r--t/open311.t14
-rw-r--r--t/open311/endpoint/warwick.t16
-rw-r--r--t/open311/getservicerequestupdates.t18
-rw-r--r--t/open311/getupdates.t7
-rw-r--r--t/open311/populate-service-list.t46
22 files changed, 153 insertions, 152 deletions
diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t
index 2620dd68c..f67b5d1f7 100644
--- a/t/app/model/alert_type.t
+++ b/t/app/model/alert_type.t
@@ -9,21 +9,21 @@ my $mech = FixMyStreet::TestMech->new();
# this is the easiest way to make sure we're not going
# to get any emails sent by data kicking about in the database
-FixMyStreet::App->model('DB::AlertType')->email_alerts();
+FixMyStreet::DB->resultset('AlertType')->email_alerts();
$mech->clear_emails_ok;
my $user =
- FixMyStreet::App->model('DB::User')
+ FixMyStreet::DB->resultset('User')
->find_or_create( { email => 'test@example.com', name => 'Test User' } );
ok $user, "created test user";
my $user2 =
- FixMyStreet::App->model('DB::User')
+ FixMyStreet::DB->resultset('User')
->find_or_create( { email => 'commenter@example.com', name => 'Commenter' } );
ok $user2, "created comment user";
my $user3 =
- FixMyStreet::App->model('DB::User')
+ FixMyStreet::DB->resultset('User')
->find_or_create( { email => 'bystander@example.com', name => 'Bystander' } );
ok $user3, "created bystander";
@@ -36,7 +36,7 @@ my $dt = DateTime->new(
second => 23
);
-my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
+my $report = FixMyStreet::DB->resultset('Problem')->find_or_create(
{
postcode => 'SW1A 1AA',
bodies_str => '2504',
@@ -62,7 +62,7 @@ my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
my $report_id = $report->id;
ok $report, "created test report - $report_id";
-my $comment = FixMyStreet::App->model('DB::Comment')->find_or_create(
+my $comment = FixMyStreet::DB->resultset('Comment')->find_or_create(
{
problem_id => $report_id,
user_id => $user2->id,
@@ -74,7 +74,7 @@ my $comment = FixMyStreet::App->model('DB::Comment')->find_or_create(
anonymous => 'f',
}
);
-my $comment2 = FixMyStreet::App->model('DB::Comment')->find_or_create(
+my $comment2 = FixMyStreet::DB->resultset('Comment')->find_or_create(
{
problem_id => $report_id,
user_id => $user2->id,
@@ -90,7 +90,7 @@ my $comment2 = FixMyStreet::App->model('DB::Comment')->find_or_create(
$comment->confirmed( \"current_timestamp - '3 days'::interval" );
$comment->update;
-my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create(
+my $alert = FixMyStreet::DB->resultset('Alert')->find_or_create(
{
user => $user,
parameter => $report_id,
@@ -101,7 +101,7 @@ my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create(
}
);
-my $alert3 = FixMyStreet::App->model('DB::Alert')->find_or_create(
+my $alert3 = FixMyStreet::DB->resultset('Alert')->find_or_create(
{
user => $user3,
parameter => $report_id,
@@ -129,7 +129,7 @@ for my $test (
subtest "correct summary for state of $test->{state}" => sub {
$mech->clear_emails_ok;
- my $sent = FixMyStreet::App->model('DB::AlertSent')->search(
+ my $sent = FixMyStreet::DB->resultset('AlertSent')->search(
{
alert_id => [ $alert->id, $alert3->id ],
parameter => $comment->id,
@@ -139,7 +139,7 @@ for my $test (
$report->state( $test->{state} );
$report->update;
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::DB->resultset('AlertType')->email_alerts();
$mech->email_count_is( 2 );
my @emails = $mech->get_email;
@@ -167,7 +167,7 @@ my $now = DateTime->now();
$report->confirmed( $now->ymd . ' ' . $now->hms );
$report->update();
-my $council_alert = FixMyStreet::App->model('DB::Alert')->find_or_create(
+my $council_alert = FixMyStreet::DB->resultset('Alert')->find_or_create(
{
user => $user2,
parameter => 2504,
@@ -181,7 +181,7 @@ my $council_alert = FixMyStreet::App->model('DB::Alert')->find_or_create(
subtest "correct text for title after URL" => sub {
$mech->clear_emails_ok;
- my $sent = FixMyStreet::App->model('DB::AlertSent')->search(
+ my $sent = FixMyStreet::DB->resultset('AlertSent')->search(
{
alert_id => $council_alert->id,
parameter => $report->id,
@@ -190,7 +190,7 @@ subtest "correct text for title after URL" => sub {
FixMyStreet::override_config {
MAPIT_URL => 'http://mapit.mysociety.org/',
}, sub {
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::DB->resultset('AlertType')->email_alerts();
};
my $email = $mech->get_email;
@@ -304,7 +304,7 @@ foreach my $test (
subtest "correct Nearest Road text with $test->{desc}" => sub {
$mech->clear_emails_ok;
- my $sent = FixMyStreet::App->model('DB::AlertSent')->search(
+ my $sent = FixMyStreet::DB->resultset('AlertSent')->search(
{
alert_id => $council_alert->id,
parameter => $report->id,
@@ -327,7 +327,7 @@ foreach my $test (
FixMyStreet::override_config {
MAPIT_URL => 'http://mapit.mysociety.org/',
}, sub {
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::DB->resultset('AlertType')->email_alerts();
};
my $email = $mech->get_email;
@@ -341,7 +341,7 @@ foreach my $test (
};
}
-my $ward_alert = FixMyStreet::App->model('DB::Alert')->find_or_create(
+my $ward_alert = FixMyStreet::DB->resultset('Alert')->find_or_create(
{
user => $user,
parameter => 7117,
@@ -352,7 +352,7 @@ my $ward_alert = FixMyStreet::App->model('DB::Alert')->find_or_create(
}
);
-my $report_to_council = FixMyStreet::App->model('DB::Problem')->find_or_create(
+my $report_to_council = FixMyStreet::DB->resultset('Problem')->find_or_create(
{
postcode => 'WS13 6YY',
bodies_str => '2434',
@@ -376,7 +376,7 @@ my $report_to_council = FixMyStreet::App->model('DB::Problem')->find_or_create(
}
);
-my $report_to_county_council = FixMyStreet::App->model('DB::Problem')->find_or_create(
+my $report_to_county_council = FixMyStreet::DB->resultset('Problem')->find_or_create(
{
postcode => 'WS13 6YY',
bodies_str => '2240',
@@ -400,7 +400,7 @@ my $report_to_county_council = FixMyStreet::App->model('DB::Problem')->find_or_c
}
);
-my $report_outside_district = FixMyStreet::App->model('DB::Problem')->find_or_create(
+my $report_outside_district = FixMyStreet::DB->resultset('Problem')->find_or_create(
{
postcode => 'WS13 6YY',
bodies_str => '2221',
@@ -427,7 +427,7 @@ my $report_outside_district = FixMyStreet::App->model('DB::Problem')->find_or_cr
subtest "check alerts from cobrand send main site url for alerts for different council" => sub {
$mech->clear_emails_ok;
- my $sent = FixMyStreet::App->model('DB::AlertSent')->search(
+ my $sent = FixMyStreet::DB->resultset('AlertSent')->search(
{
alert_id => $ward_alert->id,
}
@@ -436,7 +436,7 @@ subtest "check alerts from cobrand send main site url for alerts for different c
FixMyStreet::override_config {
MAPIT_URL => 'http://mapit.mysociety.org/',
}, sub {
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::DB->resultset('AlertType')->email_alerts();
};
my $email = $mech->get_email;
@@ -453,7 +453,7 @@ subtest "check alerts from cobrand send main site url for alerts for different c
};
-my $local_alert = FixMyStreet::App->model('DB::Alert')->find_or_create(
+my $local_alert = FixMyStreet::DB->resultset('Alert')->find_or_create(
{
user => $user,
parameter => -1.731322,
@@ -468,13 +468,13 @@ my $local_alert = FixMyStreet::App->model('DB::Alert')->find_or_create(
subtest "check local alerts from cobrand send main site url for alerts for different council" => sub {
$mech->clear_emails_ok;
- my $sent = FixMyStreet::App->model('DB::AlertSent')->search(
+ my $sent = FixMyStreet::DB->resultset('AlertSent')->search(
{
alert_id => $local_alert->id,
}
)->delete;
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::DB->resultset('AlertType')->email_alerts();
my $email = $mech->get_email;
my $body = $email->body;
@@ -494,7 +494,7 @@ subtest "correct i18n-ed summary for state of closed" => sub {
$report->update( { state => 'closed' } );
$alert->update( { lang => 'nb', cobrand => 'fiksgatami' } );
- FixMyStreet::App->model('DB::AlertSent')->search( {
+ FixMyStreet::DB->resultset('AlertSent')->search( {
alert_id => $alert->id,
parameter => $comment->id,
} )->delete;
@@ -502,7 +502,7 @@ subtest "correct i18n-ed summary for state of closed" => sub {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'fiksgatami' ],
}, sub {
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::DB->resultset('AlertType')->email_alerts();
};
$mech->email_count_is( 1 );
diff --git a/t/app/model/comment.t b/t/app/model/comment.t
index 3141af828..ae93824a7 100644
--- a/t/app/model/comment.t
+++ b/t/app/model/comment.t
@@ -6,9 +6,9 @@ use warnings;
use Test::More tests => 2;
use FixMyStreet;
-use FixMyStreet::App;
+use FixMyStreet::DB;
-my $comment_rs = FixMyStreet::App->model('DB::Comment');
+my $comment_rs = FixMyStreet::DB->resultset('Comment');
my $comment = $comment_rs->new(
{
diff --git a/t/app/model/extra.t b/t/app/model/extra.t
index 21c37336e..52e2d839c 100644
--- a/t/app/model/extra.t
+++ b/t/app/model/extra.t
@@ -3,13 +3,11 @@ use warnings;
use Test::More;
use utf8;
-use FixMyStreet::App;
+use FixMyStreet::DB;
use Data::Dumper;
use DateTime;
-my $c = FixMyStreet::App->new;
-
-my $db = FixMyStreet::App->model('DB')->schema;
+my $db = FixMyStreet::DB->connect;
$db->txn_begin;
my $body = $db->resultset('Body')->create({ name => 'ExtraTestingBody' });
diff --git a/t/app/model/moderation.t b/t/app/model/moderation.t
index cdc9a91b0..8fa333db4 100644
--- a/t/app/model/moderation.t
+++ b/t/app/model/moderation.t
@@ -4,17 +4,17 @@ use Test::More;
use Test::Exception;
use utf8;
-use FixMyStreet::App;
+use FixMyStreet::DB;
use Data::Dumper;
use DateTime;
my $dt = DateTime->now;
-my $user = FixMyStreet::App->model('DB::User')->find_or_create({
+my $user = FixMyStreet::DB->resultset('User')->find_or_create({
name => 'Bob', email => 'bob@example.com',
});
sub get_report_and_original_data {
- my $report = FixMyStreet::App->model('DB::Problem')->create(
+ my $report = FixMyStreet::DB->resultset('Problem')->create(
{
postcode => 'BR1 3SB',
bodies_str => '',
diff --git a/t/app/model/photoset.t b/t/app/model/photoset.t
index 9e566f873..938c77b2a 100644
--- a/t/app/model/photoset.t
+++ b/t/app/model/photoset.t
@@ -4,7 +4,7 @@ use Test::More;
use Test::Exception;
use utf8;
-use FixMyStreet::App;
+use FixMyStreet::DB;
use Data::Dumper;
use DateTime;
use Path::Tiny 'path';
@@ -12,19 +12,22 @@ use File::Temp 'tempdir';
my $dt = DateTime->now;
-my $c = FixMyStreet::App->new;
my $UPLOAD_DIR = tempdir( CLEANUP => 1 );
-local $c->config->{UPLOAD_DIR} = $UPLOAD_DIR;
-my $user = $c->model('DB::User')->find_or_create({
+my $db = FixMyStreet::DB->storage->schema;
+
+my $user = $db->resultset('User')->find_or_create({
name => 'Bob', email => 'bob@example.com',
});
-my $image_path = path('t/app/controller/sample.jpg');
+FixMyStreet::override_config {
+ UPLOAD_DIR => $UPLOAD_DIR,
+}, sub {
-my $db = FixMyStreet::App->model('DB')->schema;
$db->txn_begin;
+my $image_path = path('t/app/controller/sample.jpg');
+
sub make_report {
my $photo_data = shift;
return $db->resultset('Problem')->create({
@@ -54,23 +57,25 @@ sub make_report {
subtest 'Photoset with photo inline in DB' => sub {
my $report = make_report( $image_path->slurp );
- my $photoset = $report->get_photoset($c);
+ my $photoset = $report->get_photoset();
is $photoset->num_images, 1, 'Found just 1 image';
};
$image_path->copy( path( $UPLOAD_DIR, '0123456789012345678901234567890123456789.jpeg' ) );
subtest 'Photoset with 1 referenced photo' => sub {
my $report = make_report( '0123456789012345678901234567890123456789' );
- my $photoset = $report->get_photoset($c);
+ my $photoset = $report->get_photoset();
is $photoset->num_images, 1, 'Found just 1 image';
};
subtest 'Photoset with 1 referenced photo' => sub {
my $report = make_report( '0123456789012345678901234567890123456789,0123456789012345678901234567890123456789,0123456789012345678901234567890123456789' );
- my $photoset = $report->get_photoset($c);
+ my $photoset = $report->get_photoset();
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 82569d72a..6f706a22a 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -7,13 +7,13 @@ 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::App->model('DB::Problem');
+my $problem_rs = FixMyStreet::DB->resultset('Problem');
my $problem = $problem_rs->new(
{
@@ -147,7 +147,7 @@ for my $test (
};
}
-my $user = FixMyStreet::App->model('DB::User')->find_or_create(
+my $user = FixMyStreet::DB->resultset('User')->find_or_create(
{
email => 'system_user@example.com'
}
@@ -161,7 +161,7 @@ $problem->insert;
my $tz_local = DateTime::TimeZone->new( name => 'local' );
-my $body = FixMyStreet::App->model('DB::Body')->new({
+my $body = FixMyStreet::DB->resultset('Body')->new({
name => 'Edinburgh City Council'
});
@@ -521,7 +521,7 @@ foreach my $test ( {
$mech->clear_emails_ok;
- FixMyStreet::App->model('DB::Problem')->search(
+ $problem_rs->search(
{
whensent => undef
}
@@ -541,7 +541,7 @@ foreach my $test ( {
} );
FixMyStreet::override_config $override, sub {
- FixMyStreet::App->model('DB::Problem')->send_reports();
+ $problem_rs->send_reports();
};
$mech->email_count_is( $test->{ email_count } );
@@ -596,7 +596,7 @@ subtest 'check can set mutiple emails as a single contact' => sub {
$mech->clear_emails_ok;
- FixMyStreet::App->model('DB::Problem')->search(
+ $problem_rs->search(
{
whensent => undef
}
@@ -615,7 +615,7 @@ subtest 'check can set mutiple emails as a single contact' => sub {
} );
FixMyStreet::override_config $override, sub {
- FixMyStreet::App->model('DB::Problem')->send_reports();
+ $problem_rs->send_reports();
};
$mech->email_count_is(1);
@@ -630,7 +630,7 @@ subtest 'check can turn on report sent email alerts' => sub {
);
$mech->clear_emails_ok;
- FixMyStreet::App->model('DB::Problem')->search(
+ $problem_rs->search(
{
whensent => undef
}
@@ -648,7 +648,7 @@ subtest 'check can turn on report sent email alerts' => sub {
send_fail_count => 0,
} );
- FixMyStreet::App->model('DB::Problem')->send_reports();
+ $problem_rs->send_reports();
$mech->email_count_is( 2 );
my @emails = $mech->get_email;
@@ -675,7 +675,7 @@ subtest 'check can turn on report sent email alerts' => sub {
subtest 'check iOS app store test reports not sent' => sub {
$mech->clear_emails_ok;
- FixMyStreet::App->model('DB::Problem')->search(
+ $problem_rs->search(
{
whensent => undef
}
@@ -692,7 +692,7 @@ subtest 'check iOS app store test reports not sent' => sub {
send_fail_count => 0,
} );
- FixMyStreet::App->model('DB::Problem')->send_reports();
+ $problem_rs->send_reports();
$mech->email_count_is( 0 );
@@ -704,7 +704,7 @@ subtest 'check iOS app store test reports not sent' => sub {
subtest 'check reports from abuser not sent' => sub {
$mech->clear_emails_ok;
- FixMyStreet::App->model('DB::Problem')->search(
+ $problem_rs->search(
{
whensent => undef
}
@@ -721,7 +721,7 @@ subtest 'check reports from abuser not sent' => sub {
send_fail_count => 0,
} );
- FixMyStreet::App->model('DB::Problem')->send_reports();
+ $problem_rs->send_reports();
$mech->email_count_is( 1 );
@@ -734,10 +734,10 @@ subtest 'check reports from abuser not sent' => sub {
whensent => undef,
} );
- my $abuse = FixMyStreet::App->model('DB::Abuse')->create( { email => $problem->user->email } );
+ my $abuse = FixMyStreet::DB->resultset('Abuse')->create( { email => $problem->user->email } );
$mech->clear_emails_ok;
- FixMyStreet::App->model('DB::Problem')->send_reports();
+ $problem_rs->send_reports();
$mech->email_count_is( 0 );
diff --git a/t/app/model/questionnaire.t b/t/app/model/questionnaire.t
index 240d6d050..f82b071bd 100644
--- a/t/app/model/questionnaire.t
+++ b/t/app/model/questionnaire.t
@@ -8,9 +8,9 @@ use Test::More;
use FixMyStreet;
use FixMyStreet::TestMech;
-my $user = FixMyStreet::App->model('DB::User')->find_or_create( { email => 'test@example.com' } );
+my $user = FixMyStreet::DB->resultset('User')->find_or_create( { email => 'test@example.com' } );
-my $problem = FixMyStreet::App->model('DB::Problem')->create(
+my $problem = FixMyStreet::DB->resultset('Problem')->create(
{
postcode => 'EH99 1SP',
latitude => 1,
@@ -106,7 +106,7 @@ for my $test (
$mech->email_count_is(0);
- FixMyStreet::App->model('DB::Questionnaire')
+ FixMyStreet::DB->resultset('Questionnaire')
->send_questionnaires( { site => 'fixmystreet' } );
$mech->email_count_is( $test->{send_email} );
diff --git a/t/app/model/token.t b/t/app/model/token.t
index d72574bb1..c98cea395 100644
--- a/t/app/model/token.t
+++ b/t/app/model/token.t
@@ -6,7 +6,7 @@ use warnings;
use Test::More;
use FixMyStreet;
-use FixMyStreet::App;
+use FixMyStreet::DB;
my %tests = (
nested_hash => { foo => 'bar', and => [ 'baz', 'bundy' ] },
@@ -14,7 +14,7 @@ my %tests = (
scalar => 123,
);
-my $token_rs = FixMyStreet::App->model('DB::Token');
+my $token_rs = FixMyStreet::DB->resultset('Token');
foreach my $test_data_name ( sort keys %tests ) {
my $test_data = $tests{$test_data_name};
diff --git a/t/app/sendreport/email.t b/t/app/sendreport/email.t
index 65cd7bfa8..eacc6dcf6 100644
--- a/t/app/sendreport/email.t
+++ b/t/app/sendreport/email.t
@@ -6,7 +6,7 @@ use warnings;
use Test::More;
use FixMyStreet;
-use FixMyStreet::App;
+use FixMyStreet::DB;
use FixMyStreet::SendReport::Email;
use FixMyStreet::TestMech;
use mySociety::Locale;
@@ -17,7 +17,7 @@ my $e = FixMyStreet::SendReport::Email->new();
# area id 1000
my $params = { id => 1000, name => 'Council of the Thousand' };
-my $body = FixMyStreet::App->model('DB::Body')->find_or_create($params);
+my $body = FixMyStreet::DB->resultset('Body')->find_or_create($params);
ok $body, "found/created body";
my $contact = $mech->create_contact_ok(
@@ -27,7 +27,7 @@ my $contact = $mech->create_contact_ok(
note => '',
);
-my $row = FixMyStreet::App->model('DB::Problem')->new( {
+my $row = FixMyStreet::DB->resultset('Problem')->new( {
bodies_str => '1000',
category => 'category',
cobrand => '',
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index fdded5606..91b34a289 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -21,7 +21,7 @@ my @reports = $mech->create_problems_for_body( 1, $body->id, 'Test', {
my $report = $reports[0];
for my $update ('in progress', 'unable to fix') {
- FixMyStreet::App->model('DB::Comment')->find_or_create( {
+ FixMyStreet::DB->resultset('Comment')->find_or_create( {
problem_state => $update,
problem_id => $report->id,
user_id => $user->id,
@@ -48,7 +48,7 @@ subtest 'testing special Open311 behaviour', sub {
FixMyStreet::override_config {
SEND_REPORTS_ON_STAGING => 1,
}, sub {
- FixMyStreet::App->model('DB::Problem')->send_reports();
+ FixMyStreet::DB->resultset('Problem')->send_reports();
};
$report->discard_changes;
ok $report->whensent, 'Report marked as sent';
diff --git a/t/cobrand/closest.t b/t/cobrand/closest.t
index d06f7e9a0..43b36f608 100644
--- a/t/cobrand/closest.t
+++ b/t/cobrand/closest.t
@@ -4,7 +4,7 @@ use warnings;
use Test::More;
use mySociety::Locale;
-use FixMyStreet::App;
+use FixMyStreet::DB;
use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
@@ -16,7 +16,7 @@ mySociety::Locale::gettext_domain( 'FixMyStreet' );
my $c = FixMyStreet::Cobrand::UK->new();
my $user =
- FixMyStreet::App->model('DB::User')
+ FixMyStreet::DB->resultset('User')
->find_or_create( { email => 'test@example.com', name => 'Test User' } );
ok $user, "created test user";
@@ -29,7 +29,7 @@ my $dt = DateTime->new(
second => 23
);
-my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
+my $report = FixMyStreet::DB->resultset('Problem')->find_or_create(
{
postcode => 'SW1A 1AA',
bodies_str => '2504',
diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t
index d181d3890..65236e6e1 100644
--- a/t/cobrand/fixamingata.t
+++ b/t/cobrand/fixamingata.t
@@ -43,7 +43,7 @@ $mech->email_count_is(0);
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'fixamingata' ],
}, sub {
- FixMyStreet::App->model('DB::Problem')->send_reports();
+ FixMyStreet::DB->resultset('Problem')->send_reports();
};
my $email = $mech->get_email;
like $email->header('Content-Type'), qr/iso-8859-1/, 'encoding looks okay';
@@ -53,16 +53,16 @@ like $email->body, qr/V=E4nligen,/, 'signature looks correct';
$mech->clear_emails_ok;
my $user =
- FixMyStreet::App->model('DB::User')
+ FixMyStreet::DB->resultset('User')
->find_or_create( { email => 'test@example.com', name => 'Test User' } );
ok $user, "created test user";
my $user2 =
- FixMyStreet::App->model('DB::User')
+ FixMyStreet::DB->resultset('User')
->find_or_create( { email => 'commenter@example.com', name => 'Commenter' } );
ok $user2, "created comment user";
-my $comment = FixMyStreet::App->model('DB::Comment')->find_or_create({
+my $comment = FixMyStreet::DB->resultset('Comment')->find_or_create({
problem_id => $report->id,
user_id => $user2->id,
name => 'Other User',
@@ -74,7 +74,7 @@ my $comment = FixMyStreet::App->model('DB::Comment')->find_or_create({
$comment->confirmed( \"current_timestamp - '3 days'::interval" );
$comment->update;
-my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create({
+my $alert = FixMyStreet::DB->resultset('Alert')->find_or_create({
user => $user,
parameter => $report->id,
alert_type => 'new_updates',
@@ -86,7 +86,7 @@ my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create({
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'fixamingata' ],
}, sub {
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::DB->resultset('AlertType')->email_alerts();
};
$mech->email_count_is(1);
diff --git a/t/cobrand/fixmybarangay.t b/t/cobrand/fixmybarangay.t
index 316739dfa..00e792341 100644
--- a/t/cobrand/fixmybarangay.t
+++ b/t/cobrand/fixmybarangay.t
@@ -30,8 +30,8 @@ $bsn->update( { send_method => 'Email' } );
my $dps = $mech->create_body_ok( 3, 'DPS', id => 3 );
$dps->update( { send_method => 'Open311', endpoint => 'http://dps.endpoint.example.com', jurisdiction => 'FMB', api_key => 'test' } );
-FixMyStreet::App->model('DB::BodyArea')->find_or_create({ area_id => 1, body_id => $dps->id });
-FixMyStreet::App->model('DB::BodyArea')->find_or_create({ area_id => 2, body_id => $dps->id });
+FixMyStreet::DB->resultset('BodyArea')->find_or_create({ area_id => 1, body_id => $dps->id });
+FixMyStreet::DB->resultset('BodyArea')->find_or_create({ area_id => 2, body_id => $dps->id });
# Create contacts for these bodies
# TODO: log in as a Bgy user, and create a report using the front end,
@@ -72,7 +72,7 @@ $mech->email_count_is(0);
FixMyStreet::override_config {
SEND_REPORTS_ON_STAGING => 1,
}, sub {
- FixMyStreet::App->model('DB::Problem')->send_reports('fixmybarangay');
+ FixMyStreet::DB->resultset('Problem')->send_reports('fixmybarangay');
};
# Check BGY one sent by email
@@ -89,10 +89,10 @@ is $dps_report->send_method_used, 'Open311', 'DPS report sent via Open311';
is $dps_report->external_id, 248, 'DPS report has right external ID';
my $fmb_test_email = 'luz_test_user@example.com';
-my $user = FixMyStreet::App->model('DB::User')->find_or_create( { email => $fmb_test_email, from_body => $luz->id, password => 'fmbsecret' } );
+my $user = FixMyStreet::DB->resultset('User')->find_or_create( { email => $fmb_test_email, from_body => $luz->id, password => 'fmbsecret' } );
ok $user, "test user does exist";
-my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create({
+my $alert = FixMyStreet::DB->resultset('Alert')->find_or_create({
user => $user,
parameter => '-0.142497580865087',
parameter2 => '51.5016605453401',
@@ -105,7 +105,7 @@ my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create({
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'fixmybarangay' ],
}, sub {
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::DB->resultset('AlertType')->email_alerts();
};
$mech->email_count_is(1);
diff --git a/t/cobrand/get_body_sender.t b/t/cobrand/get_body_sender.t
index a9ba49479..66cfc02b7 100644
--- a/t/cobrand/get_body_sender.t
+++ b/t/cobrand/get_body_sender.t
@@ -4,7 +4,7 @@ use warnings;
use Test::More;
use mySociety::Locale;
-use FixMyStreet::App;
+use FixMyStreet::DB;
use_ok 'FixMyStreet::Cobrand';
@@ -12,10 +12,10 @@ mySociety::Locale::gettext_domain( 'FixMyStreet' );
my $c = FixMyStreet::Cobrand::FixMyStreet->new();
-FixMyStreet::App->model('DB::BodyArea')->search( { body_id => 1000 } )->delete;
-FixMyStreet::App->model('DB::Body')->search( { name => 'Body of a Thousand' } )->delete;
+FixMyStreet::DB->resultset('BodyArea')->search( { body_id => 1000 } )->delete;
+FixMyStreet::DB->resultset('Body')->search( { name => 'Body of a Thousand' } )->delete;
-my $body = FixMyStreet::App->model('DB::Body')->find_or_create({
+my $body = FixMyStreet::DB->resultset('Body')->find_or_create({
id => 1000,
name => 'Body of a Thousand',
});
diff --git a/t/cobrand/seesomething.t b/t/cobrand/seesomething.t
index 57a8a11ed..09114f6f9 100644
--- a/t/cobrand/seesomething.t
+++ b/t/cobrand/seesomething.t
@@ -10,7 +10,7 @@ use FixMyStreet::TestMech;
my $EMAIL = 'seesomething@example.com';
my $mech = FixMyStreet::TestMech->new;
-my $db = FixMyStreet::App->model('DB')->schema;
+my $db = FixMyStreet::DB->storage->schema;
my $dt_parser = $db->storage->datetime_parser;
$db->txn_begin;
@@ -32,7 +32,7 @@ $user->update({ from_body => $body });
my $date = $dt_parser->format_datetime(DateTime->now);
-my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( {
+my $report = FixMyStreet::DB->resultset('Problem')->find_or_create( {
postcode => 'EH1 1BB',
bodies_str => '2520',
areas => ',2520,',
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 721ee547c..b686f78ae 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -19,9 +19,7 @@ use Path::Tiny;
# commonlib/bin/gettext-makemo FixMyStreet
use FixMyStreet;
-my $c = FixMyStreet::App->new();
-my $cobrand = FixMyStreet::Cobrand::Zurich->new({ c => $c });
-$c->stash->{cobrand} = $cobrand;
+my $cobrand = FixMyStreet::Cobrand::Zurich->new();
my $sample_file = path(__FILE__)->parent->parent->child("app/controller/sample.jpg");
ok $sample_file->exists, "sample file $sample_file exists";
@@ -37,7 +35,7 @@ sub send_reports_for_zurich {
ALLOWED_COBRANDS => ['zurich']
}, sub {
# Actually send the report
- $c->model('DB::Problem')->send_reports('zurich');
+ FixMyStreet::DB->resultset('Problem')->send_reports('zurich');
};
}
sub reset_report_state {
@@ -195,7 +193,7 @@ subtest "changing of categories" => sub {
sub get_moderated_count {
# my %date_params = ( );
- # my $moderated = FixMyStreet::App->model('DB::Problem')->search({
+ # my $moderated = FixMyStreet::DB->resultset('Problem')->search({
# extra => { like => '%moderated_overdue,I1:0%' }, %date_params } )->count;
# return $moderated;
@@ -848,7 +846,7 @@ subtest "test stats" => sub {
subtest "test admin_log" => sub {
diag $report->id;
- my @entries = FixMyStreet::App->model('DB::AdminLog')->search({
+ my @entries = FixMyStreet::DB->resultset('AdminLog')->search({
object_type => 'problem',
object_id => $report->id,
});
@@ -868,7 +866,6 @@ subtest 'email images to external partners' => sub {
my $photo = path(__FILE__)->parent->child('zurich-logo_portal.x.jpg')->slurp_raw;
my $photoset = FixMyStreet::App::Model::PhotoSet->new({
- c => $c,
data_items => [ $photo ],
});
my $fileid = $photoset->data;
diff --git a/t/map/tilma/original.t b/t/map/tilma/original.t
index 9e296686d..4ddeed8e0 100644
--- a/t/map/tilma/original.t
+++ b/t/map/tilma/original.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
use Test::More;
-use FixMyStreet::App;
+use FixMyStreet::DB;
use FixMyStreet::Map;
use FixMyStreet::TestMech;
use DateTime;
@@ -20,14 +20,14 @@ my $c = ctx_request('http://fixmystreet.com/test?bbox=-7.6,49.7,-7.5,49.8');
$mech->delete_user('test@example.com');
my $user =
- FixMyStreet::App->model('DB::User')
+ FixMyStreet::DB->resultset('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(
+my $report = FixMyStreet::DB->resultset('Problem')->find_or_create(
{
postcode => 'SW1A 1AA',
bodies_str => '2504',
diff --git a/t/open311.t b/t/open311.t
index 15bebe2fc..6333355e8 100644
--- a/t/open311.t
+++ b/t/open311.t
@@ -5,7 +5,7 @@ use strict;
use warnings;
use Test::More;
use Test::Warn;
-use FixMyStreet::App;
+use FixMyStreet::DB;
use CGI::Simple;
use HTTP::Response;
use DateTime;
@@ -26,9 +26,9 @@ is $o->_process_error( '503 - service unavailable' ), 'unknown error', 'error te
my $o2 = Open311->new( endpoint => 'http://192.168.50.1/open311/', jurisdiction => 'example.org' );
-my $u = FixMyStreet::App->model('DB::User')->new( { email => 'test@example.org', name => 'A User' } );
+my $u = FixMyStreet::DB->resultset('User')->new( { email => 'test@example.org', name => 'A User' } );
-my $p = FixMyStreet::App->model('DB::Problem')->new( {
+my $p = FixMyStreet::DB->resultset('Problem')->new( {
latitude => 1,
longitude => 1,
title => 'title',
@@ -45,12 +45,12 @@ warning_like {$o2->send_service_request( $p, { url => 'http://example.com/' }, 1
my $dt = DateTime->now();
-my $user = FixMyStreet::App->model('DB::User')->new( {
+my $user = FixMyStreet::DB->resultset('User')->new( {
name => 'Test User',
email => 'test@example.com',
} );
-my $problem = FixMyStreet::App->model('DB::Problem')->new( {
+my $problem = FixMyStreet::DB->resultset('Problem')->new( {
id => 80,
external_id => 81,
state => 'confirmed',
@@ -207,7 +207,7 @@ for my $test (
}
-my $comment = FixMyStreet::App->model('DB::Comment')->new( {
+my $comment = FixMyStreet::DB->resultset('Comment')->new( {
id => 38362,
user => $user,
problem => $problem,
@@ -394,7 +394,7 @@ for my $test (
my $dt2 = $dt->clone;
$dt2->add( 'minutes' => 1 );
-my $comment2 = FixMyStreet::App->model('DB::Comment')->new( {
+my $comment2 = FixMyStreet::DB->resultset('Comment')->new( {
id => 38363,
user => $user,
problem => $problem,
diff --git a/t/open311/endpoint/warwick.t b/t/open311/endpoint/warwick.t
index b51c601f3..5c47cd529 100644
--- a/t/open311/endpoint/warwick.t
+++ b/t/open311/endpoint/warwick.t
@@ -7,7 +7,7 @@ use Test::MockTime ':all';
use Data::Dumper;
use JSON;
-use FixMyStreet::App;
+use FixMyStreet::DB;
use Module::Loaded;
BEGIN { mark_as_loaded('DBD::Oracle') }
@@ -141,16 +141,16 @@ subtest "End to end" => sub {
my $WARWICKSHIRE_MAPIT_ID = 2243;
- my $db = FixMyStreet::App->model('DB')->schema;
+ my $db = FixMyStreet::DB->connect;
$db->txn_begin;
- my $body = FixMyStreet::App->model('DB::Body')->find_or_create( {
+ my $body = FixMyStreet::DB->resultset('Body')->find_or_create( {
id => $WARWICKSHIRE_MAPIT_ID,
name => 'Warwickshire County Council',
});
- my $user = FixMyStreet::App->model('DB::User')
+ my $user = FixMyStreet::DB->resultset('User')
->find_or_create( { email => 'test@example.com', name => 'Test User' } );
$body->update({
@@ -175,7 +175,7 @@ subtest "End to end" => sub {
my $bodies = self_rs($body);
- my $p = Open311::PopulateServiceList->new( bodies => $bodies, verbose => 0 );
+ my $p = Open311::PopulateServiceList->new( bodies => $bodies, verbose => 0, schema => $db );
$p->process_bodies;
is $body->contacts->count, 1, 'Categories imported from Open311';
@@ -183,7 +183,7 @@ subtest "End to end" => sub {
set_fixed_time('2014-07-20T15:05:00Z');
- my $problem = FixMyStreet::App->model('DB::Problem')->create({
+ my $problem = FixMyStreet::DB->resultset('Problem')->create({
postcode => 'WC1 1AA',
bodies_str => $WARWICKSHIRE_MAPIT_ID,
areas => ",$WARWICKSHIRE_MAPIT_ID,",
@@ -219,7 +219,7 @@ subtest "End to end" => sub {
# self_rs($problem)->send_reports;
## instead, as we are in a transaction, we'll just delete everything else.
- my $rs = FixMyStreet::App->model('DB::Problem');
+ my $rs = FixMyStreet::DB->resultset('Problem');
$rs->search({ id => { '!=', $problem->id } })->delete;
$rs->send_reports;
};
@@ -242,7 +242,7 @@ subtest "End to end" => sub {
is $problem->state, 'confirmed', 'sanity check status';
- my $updates = Open311::GetServiceRequestUpdates->new( verbose => 1 );
+ my $updates = Open311::GetServiceRequestUpdates->new( verbose => 1, schema => $db );
$updates->fetch;
$problem->discard_changes;
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t
index 0ab5b232d..46c3feda4 100644
--- a/t/open311/getservicerequestupdates.t
+++ b/t/open311/getservicerequestupdates.t
@@ -10,17 +10,17 @@ use_ok( 'Open311' );
use_ok( 'Open311::GetServiceRequestUpdates' );
use DateTime;
use DateTime::Format::W3CDTF;
-use FixMyStreet::App;
+use FixMyStreet::DB;
-my $user = FixMyStreet::App->model('DB::User')->find_or_create(
+my $user = FixMyStreet::DB->resultset('User')->find_or_create(
{
email => 'system_user@example.com'
}
);
my %bodies = (
- 2482 => FixMyStreet::App->model("DB::Body")->new({ id => 2482 }),
- 2651 => FixMyStreet::App->model("DB::Body")->new({ id => 2651 }),
+ 2482 => FixMyStreet::DB->resultset("Body")->new({ id => 2482 }),
+ 2651 => FixMyStreet::DB->resultset("Body")->new({ id => 2651 }),
);
my $requests_xml = qq{<?xml version="1.0" encoding="utf-8"?>
@@ -104,7 +104,7 @@ subtest 'check extended request parsed correctly' => sub {
};
-my $problem_rs = FixMyStreet::App->model('DB::Problem');
+my $problem_rs = FixMyStreet::DB->resultset('Problem');
my $problem = $problem_rs->new(
{
postcode => 'EH99 1SP',
@@ -353,7 +353,7 @@ for my $test (
is $problem->comments->count, 1, 'comment count';
$problem->discard_changes;
- my $c = FixMyStreet::App->model('DB::Comment')->search( { external_id => $test->{external_id} } )->first;
+ my $c = FixMyStreet::DB->resultset('Comment')->search( { external_id => $test->{external_id} } )->first;
ok $c, 'comment exists';
is $c->text, $test->{description}, 'text correct';
is $c->mark_fixed, $test->{mark_fixed}, 'mark_closed correct';
@@ -527,7 +527,7 @@ subtest 'check that existing comments are not duplicated' => sub {
$problem->comments->delete;
- my $comment = FixMyStreet::App->model('DB::Comment')->new(
+ my $comment = FixMyStreet::DB->resultset('Comment')->new(
{
problem => $problem,
external_id => 638344,
@@ -660,7 +660,7 @@ foreach my $test ( {
$problem->update;
my @alerts = map {
- my $alert = FixMyStreet::App->model('DB::Alert')->create( {
+ my $alert = FixMyStreet::DB->resultset('Alert')->create( {
alert_type => 'new_updates',
parameter => $problem->id,
confirmed => 1,
@@ -680,7 +680,7 @@ foreach my $test ( {
$update->update_comments( $o, $bodies{2482} );
$problem->discard_changes;
- my $alerts_sent = FixMyStreet::App->model('DB::AlertSent')->search(
+ my $alerts_sent = FixMyStreet::DB->resultset('AlertSent')->search(
{
alert_id => [ map $_->id, @alerts ],
parameter => $problem->comments->first->id,
diff --git a/t/open311/getupdates.t b/t/open311/getupdates.t
index 7dc7ff164..fef51e0e1 100644
--- a/t/open311/getupdates.t
+++ b/t/open311/getupdates.t
@@ -5,17 +5,18 @@ use warnings;
use Test::More;
use FixMyStreet;
+use FixMyStreet::DB;
use_ok( 'Open311::GetUpdates' );
use_ok( 'Open311' );
-my $user = FixMyStreet::App->model('DB::User')->find_or_create(
+my $user = FixMyStreet::DB->resultset('User')->find_or_create(
{
email => 'system_user@example.com'
}
);
-my $body = FixMyStreet::App->model('DB::Body')->new( {
+my $body = FixMyStreet::DB->resultset('Body')->new( {
name => 'Test Body',
} );
@@ -42,7 +43,7 @@ UPDATED_DATETIME
</service_requests>
};
-my $problem_rs = FixMyStreet::App->model('DB::Problem');
+my $problem_rs = FixMyStreet::DB->resultset('Problem');
my $problem = $problem_rs->new(
{
postcode => 'EH99 1SP',
diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t
index 1574732fb..f001926d2 100644
--- a/t/open311/populate-service-list.t
+++ b/t/open311/populate-service-list.t
@@ -4,7 +4,7 @@ use strict;
use warnings;
use Test::More;
-use FixMyStreet::App;
+use FixMyStreet::DB;
use_ok( 'Open311::PopulateServiceList' );
use_ok( 'Open311' );
@@ -13,7 +13,7 @@ use_ok( 'Open311' );
my $processor = Open311::PopulateServiceList->new();
ok $processor, 'created object';
-my $body = FixMyStreet::App->model('DB::Body')->find_or_create( {
+my $body = FixMyStreet::DB->resultset('Body')->find_or_create( {
id => 1,
name => 'Body Numero Uno',
} );
@@ -22,7 +22,7 @@ $body->body_areas->find_or_create({
} );
my $BROMLEY = 'Bromley Council';
-my $bromley = FixMyStreet::App->model('DB::Body')->find_or_create( {
+my $bromley = FixMyStreet::DB->resultset('Body')->find_or_create( {
id => 2482,
name => $BROMLEY,
} );
@@ -32,7 +32,7 @@ $bromley->body_areas->find_or_create({
} );
subtest 'check basic functionality' => sub {
- FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->delete();
+ FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->delete();
my $service_list = get_xml_simple_object( get_standard_xml() );
@@ -40,14 +40,14 @@ subtest 'check basic functionality' => sub {
$processor->_current_body( $body );
$processor->process_services( $service_list );
- my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count();
+ my $contact_count = FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->count();
is $contact_count, 3, 'correct number of contacts';
};
subtest 'check non open311 contacts marked as deleted' => sub {
- FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->delete();
+ FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->delete();
- my $contact = FixMyStreet::App->model('DB::Contact')->create(
+ my $contact = FixMyStreet::DB->resultset('Contact')->create(
{
body_id => 1,
email => 'contact@example.com',
@@ -66,17 +66,17 @@ subtest 'check non open311 contacts marked as deleted' => sub {
$processor->_current_body( $body );
$processor->process_services( $service_list );
- my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count();
+ my $contact_count = FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->count();
is $contact_count, 4, 'correct number of contacts';
- $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1, deleted => 1 } )->count();
+ $contact_count = FixMyStreet::DB->resultset('Contact')->search( { body_id => 1, deleted => 1 } )->count();
is $contact_count, 1, 'correct number of deleted contacts';
};
subtest 'check email changed if matching category' => sub {
- FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->delete();
+ FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->delete();
- my $contact = FixMyStreet::App->model('DB::Contact')->create(
+ my $contact = FixMyStreet::DB->resultset('Contact')->create(
{
body_id => 1,
email => '009',
@@ -102,14 +102,14 @@ subtest 'check email changed if matching category' => sub {
is $contact->confirmed, 1, 'contact still confirmed';
is $contact->deleted, 0, 'contact still not deleted';
- my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count();
+ my $contact_count = FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->count();
is $contact_count, 3, 'correct number of contacts';
};
subtest 'check category name changed if updated' => sub {
- FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->delete();
+ FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->delete();
- my $contact = FixMyStreet::App->model('DB::Contact')->create(
+ my $contact = FixMyStreet::DB->resultset('Contact')->create(
{
body_id => 1,
email => '001',
@@ -136,14 +136,14 @@ subtest 'check category name changed if updated' => sub {
is $contact->confirmed, 1, 'contact still confirmed';
is $contact->deleted, 0, 'contact still not deleted';
- my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count();
+ my $contact_count = FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->count();
is $contact_count, 3, 'correct number of contacts';
};
subtest 'check conflicting contacts not changed' => sub {
- FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->delete();
+ FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->delete();
- my $contact = FixMyStreet::App->model('DB::Contact')->create(
+ my $contact = FixMyStreet::DB->resultset('Contact')->create(
{
body_id => 1,
email => 'existing@example.com',
@@ -158,7 +158,7 @@ subtest 'check conflicting contacts not changed' => sub {
ok $contact, 'contact created';
- my $contact2 = FixMyStreet::App->model('DB::Contact')->create(
+ my $contact2 = FixMyStreet::DB->resultset('Contact')->create(
{
body_id => 1,
email => '001',
@@ -191,7 +191,7 @@ subtest 'check conflicting contacts not changed' => sub {
is $contact2->confirmed, 1, 'second contact contact still confirmed';
is $contact2->deleted, 0, 'second contact contact still not deleted';
- my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count();
+ my $contact_count = FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->count();
is $contact_count, 4, 'correct number of contacts';
};
@@ -215,7 +215,7 @@ subtest 'check meta data population' => sub {
</service_definition>
';
- my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create(
+ my $contact = FixMyStreet::DB->resultset('Contact')->find_or_create(
{
body_id => 1,
email => '001',
@@ -395,7 +395,7 @@ for my $test (
$services_xml =~ s/metadata>false/metadata>true/ms;
}
- my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create(
+ my $contact = FixMyStreet::DB->resultset('Contact')->find_or_create(
{
body_id => 1,
email => '100',
@@ -470,7 +470,7 @@ subtest 'check attribute ordering' => sub {
</service_definition>
';
- my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create(
+ my $contact = FixMyStreet::DB->resultset('Contact')->find_or_create(
{
body_id => 1,
email => '001',
@@ -572,7 +572,7 @@ subtest 'check bromely skip code' => sub {
</service_definition>
';
- my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create(
+ my $contact = FixMyStreet::DB->resultset('Contact')->find_or_create(
{
body_id => 1,
email => '001',