aboutsummaryrefslogtreecommitdiffstats
path: root/t/app
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2015-08-13 12:21:20 +0100
committerMatthew Somerville <matthew@mysociety.org>2015-08-13 13:38:14 +0100
commitef3a3a789e8f91b62dc562ff69781dc0daa80871 (patch)
tree6045ce7399229bfcb2eca4090f1707d6fc79830b /t/app
parent864fcb6a81b17ec6324598973ff29dd734a7baf8 (diff)
Remove ms_current_timestamp() override function.
This override is not used anywhere, it dates from a very old long-gone test script, and causes issues with database query planning.
Diffstat (limited to 't/app')
-rw-r--r--t/app/controller/admin.t2
-rw-r--r--t/app/controller/contact.t2
-rw-r--r--t/app/controller/questionnaire.t2
-rw-r--r--t/app/controller/report_updates.t4
-rw-r--r--t/app/model/alert_type.t2
-rw-r--r--t/app/model/problem.t24
-rw-r--r--t/app/model/questionnaire.t4
-rw-r--r--t/app/model/token.t66
8 files changed, 25 insertions, 81 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index 498f1cedc..e2dd5df19 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -88,7 +88,7 @@ subtest 'check summary counts' => sub {
FixMyStreet::App->model('DB::Problem')->search( { bodies_str => 2489 } )->update( { bodies_str => 1 } );
my $q = FixMyStreet::App->model('DB::Questionnaire')->find_or_new( { problem => $report, });
- $q->whensent( \'ms_current_timestamp()' );
+ $q->whensent( \'current_timestamp' );
$q->in_storage ? $q->update : $q->insert;
my $alerts = FixMyStreet::App->model('DB::Alert')->search( { confirmed => { '>' => 0 } } );
diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t
index cf8a3161b..4ac69a9f8 100644
--- a/t/app/controller/contact.t
+++ b/t/app/controller/contact.t
@@ -93,7 +93,7 @@ for my $test (
user => $update_user,
state => 'confirmed',
text => $update_info->{text},
- confirmed => \'ms_current_timestamp()',
+ confirmed => \'current_timestamp',
mark_fixed => 'f',
anonymous => 'f',
}
diff --git a/t/app/controller/questionnaire.t b/t/app/controller/questionnaire.t
index 5938acc79..ecac54372 100644
--- a/t/app/controller/questionnaire.t
+++ b/t/app/controller/questionnaire.t
@@ -96,7 +96,7 @@ foreach my $test (
},
{
desc => 'User goes to questionnaire URL for an already answered questionnaire',
- answered => \'ms_current_timestamp()',
+ answered => \'current_timestamp',
content => 'already answered this questionnaire',
},
) {
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index fa6c44292..3e3e4744a 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -1339,7 +1339,7 @@ foreach my $test (
{
problem_id => $report_id,
ever_reported => 'y',
- whensent => \'ms_current_timestamp()',
+ whensent => \'current_timestamp',
}
);
@@ -1481,7 +1481,7 @@ for my $test (
{
problem_id => $report_id,
ever_reported => 'y',
- whensent => \'ms_current_timestamp()',
+ whensent => \'current_timestamp',
}
);
diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t
index 528c4d354..2620dd68c 100644
--- a/t/app/model/alert_type.t
+++ b/t/app/model/alert_type.t
@@ -87,7 +87,7 @@ my $comment2 = FixMyStreet::App->model('DB::Comment')->find_or_create(
}
);
-$comment->confirmed( \"ms_current_timestamp() - '3 days'::interval" );
+$comment->confirmed( \"current_timestamp - '3 days'::interval" );
$comment->update;
my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create(
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index ad82a62a5..0a5f63b05 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -524,14 +524,14 @@ foreach my $test ( {
{
whensent => undef
}
- )->update( { whensent => \'ms_current_timestamp()' } );
+ )->update( { whensent => \'current_timestamp' } );
$problem->discard_changes;
$problem->update( {
bodies_str => $test->{ body },
state => 'confirmed',
- confirmed => \'ms_current_timestamp()',
- whensent => $test->{ unset_whendef } ? undef : \'ms_current_timestamp()',
+ confirmed => \'current_timestamp',
+ whensent => $test->{ unset_whendef } ? undef : \'current_timestamp',
category => $test->{ category } || 'potholes',
name => $test->{ name },
cobrand => $test->{ cobrand } || 'fixmystreet',
@@ -598,13 +598,13 @@ subtest 'check can set mutiple emails as a single contact' => sub {
{
whensent => undef
}
- )->update( { whensent => \'ms_current_timestamp()' } );
+ )->update( { whensent => \'current_timestamp' } );
$problem->discard_changes;
$problem->update( {
bodies_str => $contact->{ body_id },
state => 'confirmed',
- confirmed => \'ms_current_timestamp()',
+ confirmed => \'current_timestamp',
whensent => undef,
category => 'trees',
name => 'Test User',
@@ -632,13 +632,13 @@ subtest 'check can turn on report sent email alerts' => sub {
{
whensent => undef
}
- )->update( { whensent => \'ms_current_timestamp()' } );
+ )->update( { whensent => \'current_timestamp' } );
$problem->discard_changes;
$problem->update( {
bodies_str => $body_ids{2651},
state => 'confirmed',
- confirmed => \'ms_current_timestamp()',
+ confirmed => \'current_timestamp',
whensent => undef,
category => 'potholes',
name => 'Test User',
@@ -677,14 +677,14 @@ subtest 'check iOS app store test reports not sent' => sub {
{
whensent => undef
}
- )->update( { whensent => \'ms_current_timestamp()' } );
+ )->update( { whensent => \'current_timestamp' } );
$problem->discard_changes;
$problem->update( {
bodies_str => $body_ids{2651},
title => 'App store test',
state => 'confirmed',
- confirmed => \'ms_current_timestamp()',
+ confirmed => \'current_timestamp',
whensent => undef,
category => 'potholes',
send_fail_count => 0,
@@ -706,14 +706,14 @@ subtest 'check reports from abuser not sent' => sub {
{
whensent => undef
}
- )->update( { whensent => \'ms_current_timestamp()' } );
+ )->update( { whensent => \'current_timestamp' } );
$problem->discard_changes;
$problem->update( {
bodies_str => $body_ids{2651},
title => 'Report',
state => 'confirmed',
- confirmed => \'ms_current_timestamp()',
+ confirmed => \'current_timestamp',
whensent => undef,
category => 'potholes',
send_fail_count => 0,
@@ -728,7 +728,7 @@ subtest 'check reports from abuser not sent' => sub {
$problem->update( {
state => 'confirmed',
- confirmed => \'ms_current_timestamp()',
+ confirmed => \'current_timestamp',
whensent => undef,
} );
diff --git a/t/app/model/questionnaire.t b/t/app/model/questionnaire.t
index be5b433c1..240d6d050 100644
--- a/t/app/model/questionnaire.t
+++ b/t/app/model/questionnaire.t
@@ -25,8 +25,8 @@ my $problem = FixMyStreet::App->model('DB::Problem')->create(
service => '',
cobrand => 'default',
cobrand_data => '',
- confirmed => \"ms_current_timestamp() - '5 weeks'::interval",
- whensent => \"ms_current_timestamp() - '5 weeks'::interval",
+ confirmed => \"current_timestamp - '5 weeks'::interval",
+ whensent => \"current_timestamp - '5 weeks'::interval",
user => $user,
anonymous => 0,
}
diff --git a/t/app/model/token.t b/t/app/model/token.t
index 637477fa3..d72574bb1 100644
--- a/t/app/model/token.t
+++ b/t/app/model/token.t
@@ -7,17 +7,6 @@ use Test::More;
use FixMyStreet;
use FixMyStreet::App;
-use mySociety::AuthToken;
-use mySociety::DBHandle 'dbh';
-
-# set things up so that code using mySociety::DBHandle is happy
-FixMyStreet->configure_mysociety_dbhandle();
-
-# NOTE - remember that you need to explicitly dbh()->commit after making
-# database changes with the mySociety::* modules.
-
-# create a token using DBIC and check we can read it using AuthToken, and vice
-# versa
my %tests = (
nested_hash => { foo => 'bar', and => [ 'baz', 'bundy' ] },
@@ -27,76 +16,31 @@ my %tests = (
my $token_rs = FixMyStreet::App->model('DB::Token');
-# create using DBIC
foreach my $test_data_name ( sort keys %tests ) {
my $test_data = $tests{$test_data_name};
- pass "--- testing DBIC create using '$test_data_name'";
+ pass "--- testing token creation using '$test_data_name'";
my $dbic_token =
$token_rs->create( { scope => 'testing', data => $test_data } );
my $token = $dbic_token->token;
ok $token, "stored token '$token'";
- is_deeply $dbic_token->data, $test_data, "data stored correctly using DBIC";
+ is_deeply $dbic_token->data, $test_data, "data stored correctly";
- # read back using DBIC
+ # read back from database
is_deeply $token_rs->find( { token => $token, scope => 'testing' } )->data,
$test_data,
- "data read back correctly with DBIC";
-
- # read back using mySociety::AuthToken
- is_deeply mySociety::AuthToken::retrieve( 'testing', $token ),
- $test_data, "data read back correctly with m::AT";
+ "data read back correctly";
# delete token
ok $dbic_token->delete, "delete token";
is $token_rs->find( { token => $token, scope => 'testing' } ),
undef,
- "token gone for DBIC";
-
- # read back using mySociety::AuthToken
- is mySociety::AuthToken::retrieve( 'testing', $token ),
- undef, "token gone with m::AT";
-
-}
-
-# create using m::AT
-foreach my $test_data_name ( sort keys %tests ) {
- my $test_data = $tests{$test_data_name};
-
- pass "--- testing m::AT create using '$test_data_name'";
-
- my $token = mySociety::AuthToken::store( 'testing', $test_data );
- dbh->commit();
- ok $token, "stored token '$token'";
-
- # read back using DBIC
- is_deeply $token_rs->find( { token => $token, scope => 'testing' } )->data,
- $test_data,
- "data read back correctly with DBIC";
-
- # read back using mySociety::AuthToken
- is_deeply mySociety::AuthToken::retrieve( 'testing', $token ),
- $test_data, "data read back correctly with m::AT";
-
- # delete token
- ok mySociety::AuthToken::destroy( 'testing', $token ), "destroy token";
- dbh->commit();
-
- is $token_rs->find( { token => $token, scope => 'testing' } ),
- undef,
- "token gone for DBIC";
-
- # read back using mySociety::AuthToken
- is mySociety::AuthToken::retrieve( 'testing', $token ),
- undef, "token gone with m::AT";
-
+ "token gone";
}
-
-
# Test that the inflation and deflation works as expected
{
my $token =