aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand
diff options
context:
space:
mode:
authorEdmund von der Burg <evdb@mysociety.org>2013-09-11 14:59:03 +0100
committerEdmund von der Burg <evdb@mysociety.org>2013-09-11 14:59:03 +0100
commitb97bfa3f95466c008af8236aca0537d224446c0e (patch)
tree03367f880c8d40c5382ea41d7b6f85ce58d63f26 /t/cobrand
parentc40a543905e4224e0a618d86aa9329be24a53f29 (diff)
[Zurich] Add tests for changing categories in the admin interface
Diffstat (limited to 't/cobrand')
-rw-r--r--t/cobrand/zurich.t38
1 files changed, 38 insertions, 0 deletions
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 790a0c3c5..cd826a8d3 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -115,6 +115,44 @@ $mech->content_contains( 'report_edit/' . $report->id );
$mech->content_contains( DateTime->now->strftime("%d.%m.%Y") );
$mech->content_contains( 'Erfasst' );
+
+subtest "changing of categories" => sub {
+ # create a few categories (which are actually contacts)
+ foreach my $name ( qw/Cat1 Cat2/ ) {
+ FixMyStreet::App->model('DB::Contact')->find_or_create({
+ body => $division,
+ category => $name,
+ email => "$name\@example.org",
+ confirmed => 1,
+ deleted => 0,
+ editor => "editor",
+ whenedited => DateTime->now(),
+ note => "note for $name",
+ });
+ }
+
+ # put report into know category
+ my $original_category = $report->category;
+ $report->update({ category => 'Cat1' });
+ is( $report->category, "Cat1", "Category set to Cat1" );
+
+ # get the latest comment
+ my $comments_rs = $report->comments->search({},{ order_by => { -desc => "created" } });
+ my $pre_change_comment = $comments_rs->first;
+
+ # change the category via the web interface
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->submit_form_ok( { with_fields => { category => 'Cat2' } } );
+
+ # check changes correctly saved
+ $report->discard_changes();
+ is( $report->category, "Cat2", "Category changed to Cat2 as expected" );
+
+ # restore report to original state.
+ $report->update({category => $original_category });
+};
+
+
$mech->get_ok( '/admin/report_edit/' . $report->id );
$mech->content_contains( 'Unbest&auml;tigt' ); # Unconfirmed email
$mech->submit_form_ok( { with_fields => { state => 'confirmed' } } );