diff options
author | Hakim Cassimally <hakim@mysociety.org> | 2014-08-04 16:12:50 +0000 |
---|---|---|
committer | Hakim Cassimally <hakim@mysociety.org> | 2014-08-14 09:44:30 +0000 |
commit | 963bfbc11643e0499162e33161ab539c6dcb611f (patch) | |
tree | dadb9f97c0d369dfd821d32ddfde7c25fc141219 /t/app/model | |
parent | 382a782c16a998776176de37037dd029fab4e3fe (diff) |
Tests for moderation
Diffstat (limited to 't/app/model')
-rw-r--r-- | t/app/model/moderation.t | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/t/app/model/moderation.t b/t/app/model/moderation.t new file mode 100644 index 000000000..cdc9a91b0 --- /dev/null +++ b/t/app/model/moderation.t @@ -0,0 +1,66 @@ +use strict; +use warnings; +use Test::More; +use Test::Exception; +use utf8; + +use FixMyStreet::App; +use Data::Dumper; +use DateTime; + +my $dt = DateTime->now; +my $user = FixMyStreet::App->model('DB::User')->find_or_create({ + name => 'Bob', email => 'bob@example.com', +}); + +sub get_report_and_original_data { + my $report = FixMyStreet::App->model('DB::Problem')->create( + { + postcode => 'BR1 3SB', + bodies_str => '', + areas => ",,", + category => 'Other', + title => 'test', + detail => 'test', + used_map => 't', + name => 'Anon', + anonymous => 't', + state => 'confirmed', + confirmed => $dt->ymd . ' ' . $dt->hms, + lang => 'en-gb', + service => '', + cobrand => 'default', + cobrand_data => '', + send_questionnaire => 't', + latitude => '51.4129', + longitude => '0.007831', + user => $user, + }); + my $original = $report->create_related( moderation_original_data => { + anonymous => 't', + title => 'test', + detail => 'test', + photo => 'f', + } ); + + return ($report, $original); +} + +subtest 'Explicit Deletion (sanity test)' => sub { + my ($report, $orig) = get_report_and_original_data; + + lives_ok { + $orig->delete; + $report->delete; + }; +}; + +subtest 'Implicit Chained Deletion' => sub { + my ($report, $orig) = get_report_and_original_data; + + lives_ok { + $report->delete; + }; +}; + +done_testing(); |