aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/model
diff options
context:
space:
mode:
Diffstat (limited to 't/app/model')
-rw-r--r--t/app/model/alert_type.t61
-rw-r--r--t/app/model/comment.t4
-rw-r--r--t/app/model/problem.t310
-rw-r--r--t/app/model/questionnaire.t18
-rw-r--r--t/app/model/rabx_column.t23
-rw-r--r--t/app/model/token.t46
6 files changed, 374 insertions, 88 deletions
diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t
index c592e9d3f..ae413978f 100644
--- a/t/app/model/alert_type.t
+++ b/t/app/model/alert_type.t
@@ -39,7 +39,7 @@ my $dt = DateTime->new(
my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
{
postcode => 'SW1A 1AA',
- council => '2504',
+ bodies_str => '2504',
areas => ',105255,11806,11828,2247,2504,',
category => 'Other',
title => 'Test 2',
@@ -97,6 +97,7 @@ my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create(
alert_type => 'new_updates',
whensubscribed => $dt->ymd . ' ' . $dt->hms,
confirmed => 1,
+ cobrand => 'default',
}
);
@@ -107,6 +108,7 @@ my $alert3 = FixMyStreet::App->model('DB::Alert')->find_or_create(
alert_type => 'new_updates',
whensubscribed => $dt->ymd . ' ' . $dt->hms,
confirmed => 1,
+ cobrand => 'default',
}
);
@@ -185,7 +187,11 @@ subtest "correct text for title after URL" => sub {
parameter => $report->id,
}
)->delete;
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ };
my $email = $mech->get_email;
(my $title = $report->title) =~ s/ /\\s+/;
@@ -318,7 +324,11 @@ foreach my $test (
$report->geocode( $g );
$report->update();
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ };
my $email = $mech->get_email;
my $body = $email->body;
@@ -345,7 +355,7 @@ my $ward_alert = FixMyStreet::App->model('DB::Alert')->find_or_create(
my $report_to_council = FixMyStreet::App->model('DB::Problem')->find_or_create(
{
postcode => 'WS13 6YY',
- council => '2434',
+ bodies_str => '2434',
areas => ',105255,11806,11828,2247,2504,7117,',
category => 'Other',
title => 'council report',
@@ -369,7 +379,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(
{
postcode => 'WS13 6YY',
- council => '2240',
+ bodies_str => '2240',
areas => ',105255,11806,11828,2247,2504,7117,',
category => 'Other',
title => 'county report',
@@ -393,7 +403,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(
{
postcode => 'WS13 6YY',
- council => '2221',
+ bodies_str => '2221',
areas => ',105255,11806,11828,2247,2504,7117,',
category => 'Other',
title => 'outside district report',
@@ -423,7 +433,11 @@ subtest "check alerts from cobrand send main site url for alerts for different c
}
)->delete;
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ };
my $email = $mech->get_email;
my $body = $email->body;
@@ -473,7 +487,34 @@ subtest "check local alerts from cobrand send main site url for alerts for diffe
like $body, qr#$expected2#, 'cobrand area report point to cobrand url';
};
-$report->comments->delete();
-$report->delete();
-done_testing();
+# Test that email alerts are sent in the right language.
+subtest "correct i18n-ed summary for state of closed" => sub {
+ $mech->clear_emails_ok;
+
+ $report->update( { state => 'closed' } );
+ $alert->update( { lang => 'nb', cobrand => 'fiksgatami' } );
+ FixMyStreet::App->model('DB::AlertSent')->search( {
+ alert_id => $alert->id,
+ parameter => $comment->id,
+ } )->delete;
+
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fiksgatami' ],
+ }, sub {
+ FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ };
+
+ $mech->email_count_is( 1 );
+ my $email = $mech->get_email;
+ my $body = $email->body;
+ my $msg = 'Denne rapporten er for tiden markert som lukket';
+ like $body, qr/$msg/, 'email says problem is closed, in Norwegian';
+};
+
+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 93104c2e5..3141af828 100644
--- a/t/app/model/comment.t
+++ b/t/app/model/comment.t
@@ -23,5 +23,5 @@ my $comment = $comment_rs->new(
}
);
-is $comment->confirmed_local, undef, 'inflating null confirmed ok';
-is $comment->created_local, undef, 'inflating null confirmed ok';
+is $comment->confirmed, undef, 'inflating null confirmed ok';
+is $comment->created, undef, 'inflating null confirmed ok';
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index 63204e05c..24ed959af 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -9,6 +9,7 @@ use FixMyStreet;
use FixMyStreet::App;
use FixMyStreet::TestMech;
use mySociety::Locale;
+use Sub::Override;
mySociety::Locale::gettext_domain('FixMyStreet');
@@ -32,10 +33,10 @@ my $problem = $problem_rs->new(
}
);
-is $problem->confirmed_local, undef, 'inflating null confirmed ok';
-is $problem->whensent_local, undef, 'inflating null confirmed ok';
-is $problem->lastupdate_local, undef, 'inflating null confirmed ok';
-is $problem->created_local, undef, 'inflating null confirmed ok';
+is $problem->confirmed, undef, 'inflating null confirmed ok';
+is $problem->whensent, undef, 'inflating null confirmed ok';
+is $problem->lastupdate, undef, 'inflating null confirmed ok';
+is $problem->created, undef, 'inflating null confirmed ok';
for my $test (
{
@@ -44,7 +45,7 @@ for my $test (
errors => {
title => 'Please enter a subject',
detail => 'Please enter some details',
- council => 'No council selected',
+ bodies => 'No council selected',
name => 'Please enter your name',
}
},
@@ -56,7 +57,7 @@ for my $test (
errors => {
title => 'Please enter a subject',
detail => 'Please enter some details',
- council => 'No council selected',
+ bodies => 'No council selected',
name => 'Please enter your full name, councils need this information – if you do not wish your name to be shown on the site, untick the box below',
}
},
@@ -68,7 +69,7 @@ for my $test (
errors => {
title => 'Please enter a subject',
detail => 'Please enter some details',
- council => 'No council selected',
+ bodies => 'No council selected',
name => 'Please enter your full name, councils need this information – if you do not wish your name to be shown on the site, untick the box below',
}
},
@@ -80,7 +81,7 @@ for my $test (
errors => {
title => 'Please enter a subject',
detail => 'Please enter some details',
- council => 'No council selected',
+ bodies => 'No council selected',
}
},
{
@@ -90,7 +91,7 @@ for my $test (
},
errors => {
detail => 'Please enter some details',
- council => 'No council selected',
+ bodies => 'No council selected',
}
},
{
@@ -99,22 +100,22 @@ for my $test (
detail => 'Some information about the problem',
},
errors => {
- council => 'No council selected',
+ bodies => 'No council selected',
}
},
{
- desc => 'incorrectly formatted council',
+ desc => 'incorrectly formatted body',
changed => {
- council => 'my council',
+ bodies_str => 'my body',
},
errors => {
- council => 'No council selected',
+ bodies => 'No council selected',
}
},
{
- desc => 'correctly formatted council',
+ desc => 'correctly formatted body',
changed => {
- council => '1001',
+ bodies_str => '1001',
},
errors => {
}
@@ -167,6 +168,10 @@ $problem->insert;
my $tz_local = DateTime::TimeZone->new( name => 'local' );
+my $body = FixMyStreet::App->model('DB::Body')->new({
+ name => 'Edinburgh City Council'
+});
+
for my $test (
{
desc => 'request older than problem ignored',
@@ -174,9 +179,6 @@ for my $test (
request => {
updated_datetime => DateTime::Format::W3CDTF->new()->format_datetime( DateTime->now()->set_time_zone( $tz_local )->subtract( days => 2 ) ),
},
- council => {
- name => 'Edinburgh City Council',
- },
created => 0,
},
{
@@ -187,9 +189,6 @@ for my $test (
status => 'open',
status_notes => 'this is an update from the council',
},
- council => {
- name => 'Edinburgh City Council',
- },
created => 1,
state => 'confirmed',
mark_fixed => 0,
@@ -203,9 +202,6 @@ for my $test (
status => 'closed',
status_notes => 'the council have fixed this',
},
- council => {
- name => 'Edinburgh City Council',
- },
created => 1,
state => 'fixed',
mark_fixed => 1,
@@ -219,9 +215,6 @@ for my $test (
status => 'open',
status_notes => 'the council do not think this is fixed',
},
- council => {
- name => 'Edinburgh City Council',
- },
created => 1,
start_state => 'fixed',
state => 'fixed',
@@ -238,7 +231,7 @@ for my $test (
$problem->update;
my $w3c = DateTime::Format::W3CDTF->new();
- my $ret = $problem->update_from_open311_service_request( $test->{request}, $test->{council}, $user );
+ my $ret = $problem->update_from_open311_service_request( $test->{request}, $body, $user );
is $ret, $test->{created}, 'return value';
return unless $test->{created};
@@ -302,6 +295,13 @@ for my $test (
is_closed => 0,
},
{
+ state => 'action scheduled',
+ is_visible => 1,
+ is_fixed => 0,
+ is_open => 1,
+ is_closed => 0,
+ },
+ {
state => 'in progress',
is_visible => 1,
is_fixed => 0,
@@ -309,6 +309,27 @@ for my $test (
is_closed => 0,
},
{
+ state => 'duplicate',
+ is_visible => 1,
+ is_fixed => 0,
+ is_open => 0,
+ is_closed => 1,
+ },
+ {
+ state => 'not responsible',
+ is_visible => 1,
+ is_fixed => 0,
+ is_open => 0,
+ is_closed => 1,
+ },
+ {
+ state => 'unable to fix',
+ is_visible => 1,
+ is_fixed => 0,
+ is_open => 0,
+ is_closed => 1,
+ },
+ {
state => 'fixed',
is_visible => 1,
is_fixed => 1,
@@ -355,42 +376,53 @@ my %contact_params = (
whenedited => \'ms_current_timestamp()',
note => 'Created for test',
);
+
+for my $body (
+ { id => 2651, name => 'City of Edinburgh Council' },
+ { id => 2226, name => 'Gloucestershire County Council' },
+ { id => 2326, name => 'Cheltenham Borough Council' },
+ { id => 2434, name => 'Lichfield District Council' },
+ { id => 2240, name => 'Staffordshire County Council' },
+ { id => 14279, name => 'Ballymoney Borough Council' },
+ { id => 2636, name => 'Isle of Wight Council' },
+ { id => 2649, name => 'Fife Council' },
+) {
+ $mech->create_body_ok($body->{id}, $body->{name});
+}
+
# Let's make some contacts to send things to!
-FixMyStreet::App->model('DB::Contact')->search( {
- email => { 'like', '%example.com' },
-} )->delete;
my @contacts;
for my $contact ( {
- area_id => 2651, # Edinburgh
+ body_id => 2651, # Edinburgh
category => 'potholes',
email => 'test@example.org',
}, {
- area_id => 2226, # Gloucestershire
+ body_id => 2226, # Gloucestershire
category => 'potholes',
email => '2226@example.org',
}, {
- area_id => 2326, # Cheltenham
+ body_id => 2326, # Cheltenham
category => 'potholes',
email => '2326@example.org',
}, {
- area_id => 2434, # Lichfield
+ body_id => 2434, # Lichfield
category => 'potholes',
email => 'trees@example.com',
}, {
- area_id => 2240, # Staffordshire
+ body_id => 2240, # Staffordshire
category => 'potholes',
email => 'highways@example.com',
}, {
- area_id => 14279, # Ballymoney
+ body_id => 14279, # Ballymoney
category => 'Street lighting',
email => 'roads.western@drdni.example.org',
}, {
- area_id => 14279, # Ballymoney
+ body_id => 14279, # Ballymoney
category => 'Graffiti',
email => 'highways@example.com',
}, {
confirmed => 0,
- area_id => 2636, # Isle of Wight
+ body_id => 2636, # Isle of Wight
category => 'potholes',
email => '2636@example.com',
} ) {
@@ -410,21 +442,21 @@ foreach my $test ( {
email_count => 1,
dear => qr'Dear City of Edinburgh Council',
to => qr'City of Edinburgh Council',
- council => 2651,
+ body => 2651,
}, {
%common,
desc => 'no email sent if no unsent problems',
unset_whendef => 0,
email_count => 0,
- council => 2651,
+ body => 2651,
}, {
%common,
desc => 'email to two tier council',
unset_whendef => 1,
email_count => 1,
- to => qr'Gloucestershire County Council.*Cheltenham Borough Council',
- dear => qr'Dear Gloucestershire County Council and Cheltenham Borough',
- council => '2226,2326',
+ to => qr'Cheltenham Borough Council.*Gloucestershire County Council',
+ dear => qr'Dear Cheltenham Borough Council and Gloucestershire County',
+ body => '2226,2326',
multiple => 1,
}, {
%common,
@@ -433,7 +465,7 @@ foreach my $test ( {
email_count => 1,
to => qr'Gloucestershire County Council" <2226@example',
dear => qr'Dear Gloucestershire County Council,',
- council => '2226|2649',
+ body => '2226|2649',
missing => qr'problem might be the responsibility of Fife.*Council'ms,
}, {
%common,
@@ -442,7 +474,7 @@ foreach my $test ( {
email_count => 1,
to => qr'Lichfield District Council',
dear => qr'Dear Lichfield District Council,',
- council => '2434',
+ body => '2434',
cobrand => 'lichfielddc',
url => 'lichfielddc.',
}, {
@@ -452,9 +484,9 @@ foreach my $test ( {
email_count => 1,
to => qr'Staffordshire County Council" <highways@example',
dear => qr'Dear Staffordshire County Council,',
- council => '2240',
+ body => '2240',
cobrand => 'lichfielddc',
- url => '',
+ url => 'www.',
}, {
%common,
desc => 'directs NI correctly, 1',
@@ -462,7 +494,7 @@ foreach my $test ( {
email_count => 1,
dear => qr'Dear Ballymoney Borough Council',
to => qr'Ballymoney Borough Council',
- council => 14279,
+ body => 14279,
category => 'Graffiti',
}, {
%common,
@@ -471,7 +503,7 @@ foreach my $test ( {
email_count => 1,
dear => qr'Dear Roads Service \(Western\)',
to => qr'Roads Service \(Western\)" <roads',
- council => 14279,
+ body => 14279,
category => 'Street lighting',
}, {
%common,
@@ -479,12 +511,17 @@ foreach my $test ( {
unset_whendef => 1,
stays_unsent => 1,
email_count => 0,
- council => 2636,
+ body => 2636,
},
) {
subtest $test->{ desc } => sub {
- if ( $test->{cobrand} && $test->{cobrand} =~ /lichfielddc/ && !FixMyStreet::Cobrand->exists('lichfielddc') ) {
- plan skip_all => 'Skipping Lichfield tests without Lichfield cobrand';
+ my $override = {
+ ALLOWED_COBRANDS => [ 'fixmystreet' ],
+ BASE_URL => 'http://www.fixmystreet.com',
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ };
+ if ( $test->{cobrand} && $test->{cobrand} =~ /lichfielddc/ ) {
+ $override->{ALLOWED_COBRANDS} = [ 'lichfielddc' ];
}
$mech->clear_emails_ok;
@@ -497,7 +534,7 @@ foreach my $test ( {
$problem->discard_changes;
$problem->update( {
- council => $test->{ council },
+ bodies_str => $test->{ body },
state => 'confirmed',
confirmed => \'ms_current_timestamp()',
whensent => $test->{ unset_whendef } ? undef : \'ms_current_timestamp()',
@@ -506,7 +543,9 @@ foreach my $test ( {
cobrand => $test->{ cobrand } || 'fixmystreet',
} );
- FixMyStreet::App->model('DB::Problem')->send_reports();
+ FixMyStreet::override_config $override, sub {
+ FixMyStreet::App->model('DB::Problem')->send_reports();
+ };
$mech->email_count_is( $test->{ email_count } );
if ( $test->{ email_count } ) {
@@ -519,15 +558,14 @@ foreach my $test ( {
like $email->body, $test->{ dear }, 'Salutation looks correct';
if ( $test->{multiple} ) {
- like $email->body, qr/This email has been sent to several councils /, 'multiple council text correct';
+ like $email->body, qr/This email has been sent to several councils /, 'multiple body text correct';
} elsif ( $test->{ missing } ) {
- like $email->body, $test->{ missing }, 'missing council information correct';
+ like $email->body, $test->{ missing }, 'missing body information correct';
}
if ( $test->{url} ) {
- (my $base_url = FixMyStreet->config('BASE_URL')) =~ s{http://}{};
my $id = $problem->id;
- like $email->body, qr[$test->{url}$base_url/report/$id], 'URL present is correct';
+ like $email->body, qr[$test->{url}fixmystreet.com/report/$id], 'URL present is correct';
}
$problem->discard_changes;
@@ -540,10 +578,57 @@ foreach my $test ( {
};
}
-subtest 'check can turn on report sent email alerts' => sub {
- eval 'use Test::MockModule; 1' or
- plan skip_all => 'Skipping tests that rely on Test::MockModule';
+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 = {
+ body_id => 2651, # Edinburgh
+ category => 'trees',
+ email => '2636@example.com,2636-2@example.com',
+ };
+ my $new_contact = FixMyStreet::App->model('DB::Contact')->find_or_create( {
+ %contact_params,
+ %$contact } );
+ ok $new_contact, "created multiple email test contact";
+
+ $mech->clear_emails_ok;
+
+ FixMyStreet::App->model('DB::Problem')->search(
+ {
+ whensent => undef
+ }
+ )->update( { whensent => \'ms_current_timestamp()' } );
+ $problem->discard_changes;
+ $problem->update( {
+ bodies_str => $contact->{ body_id },
+ state => 'confirmed',
+ confirmed => \'ms_current_timestamp()',
+ whensent => undef,
+ category => 'trees',
+ name => 'Test User',
+ cobrand => 'fixmystreet',
+ send_fail_count => 0,
+ } );
+
+ FixMyStreet::override_config $override, sub {
+ FixMyStreet::App->model('DB::Problem')->send_reports();
+ };
+
+ $mech->email_count_is(1);
+ my $email = $mech->get_email;
+ is $email->header('To'), '"City of Edinburgh Council" <2636@example.com>, "City of Edinburgh Council" <2636-2@example.com>', 'To contains two email addresses';
+};
+
+subtest 'check can turn on report sent email alerts' => sub {
+ my $send_confirmation_mail_override = Sub::Override->new(
+ "FixMyStreet::Cobrand::Default::report_sent_confirmation_email",
+ sub { return 1; }
+ );
$mech->clear_emails_ok;
FixMyStreet::App->model('DB::Problem')->search(
@@ -554,18 +639,16 @@ subtest 'check can turn on report sent email alerts' => sub {
$problem->discard_changes;
$problem->update( {
- council => 2651,
+ bodies_str => 2651,
state => 'confirmed',
confirmed => \'ms_current_timestamp()',
whensent => undef,
category => 'potholes',
name => 'Test User',
cobrand => 'fixmystreet',
+ send_fail_count => 0,
} );
- my $m = new Test::MockModule(
- 'FixMyStreet::Cobrand::FixMyStreet' );
- $m->mock( report_sent_confirmation_email => 1 );
FixMyStreet::App->model('DB::Problem')->send_reports();
$mech->email_count_is( 2 );
@@ -585,14 +668,95 @@ subtest 'check can turn on report sent email alerts' => sub {
$email = $emails[1];
like $email->header('Subject'), qr/Problem Report Sent/, 'report sent email title correct';
like $email->body, qr/Your report about/, 'report sent body correct';
+
+ $send_confirmation_mail_override->restore();
};
-$problem->comments->delete;
-$problem->delete;
-$user->delete;
-foreach (@contacts) {
- $_->delete;
-}
+subtest 'check iOS app store test reports not sent' => sub {
+ $mech->clear_emails_ok;
+
+ FixMyStreet::App->model('DB::Problem')->search(
+ {
+ whensent => undef
+ }
+ )->update( { whensent => \'ms_current_timestamp()' } );
+
+ $problem->discard_changes;
+ $problem->update( {
+ bodies_str => 2651,
+ title => 'App store test',
+ state => 'confirmed',
+ confirmed => \'ms_current_timestamp()',
+ whensent => undef,
+ category => 'potholes',
+ send_fail_count => 0,
+ } );
+
+ FixMyStreet::App->model('DB::Problem')->send_reports();
+
+ $mech->email_count_is( 0 );
+
+ $problem->discard_changes();
+ is $problem->state, 'hidden', 'iOS test reports are hidden automatically';
+ is $problem->whensent, undef, 'iOS test reports are not sent';
+};
+
+subtest 'check reports from abuser not sent' => sub {
+ $mech->clear_emails_ok;
+
+ FixMyStreet::App->model('DB::Problem')->search(
+ {
+ whensent => undef
+ }
+ )->update( { whensent => \'ms_current_timestamp()' } );
-done_testing();
+ $problem->discard_changes;
+ $problem->update( {
+ bodies_str => 2651,
+ title => 'Report',
+ state => 'confirmed',
+ confirmed => \'ms_current_timestamp()',
+ whensent => undef,
+ category => 'potholes',
+ send_fail_count => 0,
+ } );
+
+ FixMyStreet::App->model('DB::Problem')->send_reports();
+
+ $mech->email_count_is( 1 );
+
+ $problem->discard_changes();
+ ok $problem->whensent, 'Report has been sent';
+
+ $problem->update( {
+ state => 'confirmed',
+ confirmed => \'ms_current_timestamp()',
+ whensent => undef,
+ } );
+
+ my $abuse = FixMyStreet::App->model('DB::Abuse')->create( { email => $problem->user->email } );
+
+ $mech->clear_emails_ok;
+ FixMyStreet::App->model('DB::Problem')->send_reports();
+
+ $mech->email_count_is( 0 );
+
+ $problem->discard_changes();
+ is $problem->state, 'hidden', 'reports from abuse user are hidden automatically';
+ is $problem->whensent, undef, 'reports from abuse user are not sent';
+
+ ok $abuse->delete(), 'user removed from abuse table';
+};
+
+END {
+ $problem->comments->delete if $problem;
+ $problem->delete if $problem;
+ $mech->delete_user( $user ) if $user;
+
+ foreach (@contacts) {
+ $_->delete;
+ }
+
+ done_testing();
+}
diff --git a/t/app/model/questionnaire.t b/t/app/model/questionnaire.t
index 60b52043a..be5b433c1 100644
--- a/t/app/model/questionnaire.t
+++ b/t/app/model/questionnaire.t
@@ -32,8 +32,6 @@ my $problem = FixMyStreet::App->model('DB::Problem')->create(
}
);
-diag $problem->id;
-
my $mech = FixMyStreet::TestMech->new;
for my $test (
@@ -62,6 +60,10 @@ for my $test (
send_email => 1,
},
{
+ state => 'action scheduled',
+ send_email => 1,
+ },
+ {
state => 'in progress',
send_email => 1,
},
@@ -78,6 +80,18 @@ for my $test (
send_email => 1,
},
{
+ state => 'duplicate',
+ send_email => 1,
+ },
+ {
+ state => 'unable to fix',
+ send_email => 1,
+ },
+ {
+ state => 'not responsible',
+ send_email => 1,
+ },
+ {
state => 'closed',
send_email => 1,
},
diff --git a/t/app/model/rabx_column.t b/t/app/model/rabx_column.t
new file mode 100644
index 000000000..607d578ce
--- /dev/null
+++ b/t/app/model/rabx_column.t
@@ -0,0 +1,23 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+use_ok "FixMyStreet::DB::RABXColumn";
+
+# Test that the class names are correctly normalised
+my @tests = (
+ ["FixMyStreet::DB::Result::Token", "Token"],
+ ["FixMyStreet::App::Model::DB::Token", "Token"],
+);
+
+foreach my $test (@tests) {
+ my ($input, $expected) = @$test;
+ is(
+ FixMyStreet::DB::RABXColumn::_get_class_identifier($input),
+ $expected,
+ "$input -> $expected"
+ );
+}
+
+done_testing();
diff --git a/t/app/model/token.t b/t/app/model/token.t
index 12945975e..637477fa3 100644
--- a/t/app/model/token.t
+++ b/t/app/model/token.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 45;
+use Test::More;
use FixMyStreet;
use FixMyStreet::App;
@@ -94,3 +94,47 @@ foreach my $test_data_name ( sort keys %tests ) {
undef, "token gone with m::AT";
}
+
+
+
+# Test that the inflation and deflation works as expected
+{
+ my $token =
+ $token_rs->create( { scope => 'testing', data => {} } );
+ END { $token->delete() };
+
+ # Add in temporary check to test that the data is updated as expected.
+ is_deeply($token->data, {}, "data is empty");
+
+ # store something in it
+ $token->update({ data => { foo => 'bar' } });
+ $token->discard_changes();
+ is_deeply($token->data, { foo => 'bar' }, "data has content");
+
+ # change the hash stored
+ $token->update({ data => { baz => 'bundy' } });
+ $token->discard_changes();
+ is_deeply($token->data, { baz => 'bundy' }, "data has new content");
+
+ # change the hashref in place
+ {
+ my $data = $token->data;
+ $data->{baz} = 'new';
+ $token->data( $data );
+ $token->update();
+ $token->discard_changes();
+ is_deeply($token->data, { baz => 'new' }, "data has been updated");
+ }
+
+ # change the hashref in place
+ {
+ my $data = $token->data;
+ $data->{baz} = 'new';
+ $token->update({ data => $data });
+ $token->discard_changes();
+ is_deeply($token->data, { baz => 'new' }, "data has been updated");
+ }
+
+}
+
+done_testing();