diff options
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/admin.t | 2 | ||||
-rw-r--r-- | t/app/controller/contact.t | 2 | ||||
-rw-r--r-- | t/app/controller/questionnaire.t | 2 | ||||
-rw-r--r-- | t/app/controller/report_updates.t | 4 | ||||
-rw-r--r-- | t/app/model/alert_type.t | 2 | ||||
-rw-r--r-- | t/app/model/problem.t | 24 | ||||
-rw-r--r-- | t/app/model/questionnaire.t | 4 | ||||
-rw-r--r-- | t/app/model/token.t | 66 | ||||
-rw-r--r-- | t/cobrand/fixamingata.t | 2 | ||||
-rw-r--r-- | t/open311/populate-service-list.t | 18 |
10 files changed, 35 insertions, 91 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 = diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t index 3c818474d..d181d3890 100644 --- a/t/cobrand/fixamingata.t +++ b/t/cobrand/fixamingata.t @@ -71,7 +71,7 @@ my $comment = FixMyStreet::App->model('DB::Comment')->find_or_create({ state => 'confirmed', anonymous => 'f', }); -$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/open311/populate-service-list.t b/t/open311/populate-service-list.t index 99663030a..1574732fb 100644 --- a/t/open311/populate-service-list.t +++ b/t/open311/populate-service-list.t @@ -55,7 +55,7 @@ subtest 'check non open311 contacts marked as deleted' => sub { confirmed => 1, deleted => 0, editor => $0, - whenedited => \'ms_current_timestamp()', + whenedited => \'current_timestamp', note => 'test contact', } ); @@ -84,7 +84,7 @@ subtest 'check email changed if matching category' => sub { confirmed => 1, deleted => 0, editor => $0, - whenedited => \'ms_current_timestamp()', + whenedited => \'current_timestamp', note => 'test contact', } ); @@ -117,7 +117,7 @@ subtest 'check category name changed if updated' => sub { confirmed => 1, deleted => 0, editor => $0, - whenedited => \'ms_current_timestamp()', + whenedited => \'current_timestamp', note => 'test contact', } ); @@ -151,7 +151,7 @@ subtest 'check conflicting contacts not changed' => sub { confirmed => 1, deleted => 0, editor => $0, - whenedited => \'ms_current_timestamp()', + whenedited => \'current_timestamp', note => 'test contact', } ); @@ -166,7 +166,7 @@ subtest 'check conflicting contacts not changed' => sub { confirmed => 1, deleted => 0, editor => $0, - whenedited => \'ms_current_timestamp()', + whenedited => \'current_timestamp', note => 'test contact', } ); @@ -223,7 +223,7 @@ subtest 'check meta data population' => sub { confirmed => 1, deleted => 0, editor => $0, - whenedited => \'ms_current_timestamp()', + whenedited => \'current_timestamp', note => 'test contact', } ); @@ -403,7 +403,7 @@ for my $test ( confirmed => 1, deleted => 0, editor => $0, - whenedited => \'ms_current_timestamp()', + whenedited => \'current_timestamp', note => 'test contact', } ); @@ -478,7 +478,7 @@ subtest 'check attribute ordering' => sub { confirmed => 1, deleted => 0, editor => $0, - whenedited => \'ms_current_timestamp()', + whenedited => \'current_timestamp', note => 'test contact', } ); @@ -580,7 +580,7 @@ subtest 'check bromely skip code' => sub { confirmed => 1, deleted => 0, editor => $0, - whenedited => \'ms_current_timestamp()', + whenedited => \'current_timestamp', note => 'test contact', } ); |