aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
authorEdmund von der Burg <evdb@mysociety.org>2011-05-19 18:55:44 +0100
committerEdmund von der Burg <evdb@mysociety.org>2011-05-19 18:55:44 +0100
commitb49dac25fb9ec11c09972e3a0b49690ccac3bc68 (patch)
tree80fac638e99a4e183025030941cdbc6e2fc8faff /t/app/controller
parent2918a2b1cb6f3fd09b7e5dbd738e762e554521bf (diff)
parentf0e1ae8ad567b5360577f0e18237fa00056e4073 (diff)
Merge branch 'migrate_to_catalyst' of ssh://evdb@git.mysociety.org/data/git/public/fixmystreet into migrate_to_catalyst
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/report_updates.t77
1 files changed, 51 insertions, 26 deletions
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index e64e2f4d6..182f3a244 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -249,7 +249,8 @@ subtest "submit an update for a non registered user" => sub {
);
ok $token, 'Token found in database';
- my $update_id = $token->data;
+ my $update_id = $token->data->{id};
+ my $add_alerts = $token->data->{add_alert};
my $update = FixMyStreet::App->model( 'DB::Comment' )->find(
{ id => $update_id }
);
@@ -258,39 +259,63 @@ subtest "submit an update for a non registered user" => sub {
is $update->state, 'unconfirmed', 'update unconfirmed';
is $update->user->email, 'unregistered@example.com', 'update email';
is $update->text, 'update from an unregistered user', 'update text';
+ is $add_alerts, 0, 'do not sign up for alerts';
};
-subtest "submit an update for a registered user" => sub {
- # clear out comments for this problem to make
- # checking details easier later
- ok( $_->delete, 'deleted comment ' . $_->id )
- for $report->comments;
+for my $test (
+ {
+ desc => 'submit update for register user',
+ fields => {
+ rznvy => 'test@example.com',
+ update => 'update from a registered user'
+ },
+ alert => 0,
+ },
+ {
+ desc => 'submit update for register user and sign up',
+ fields => {
+ rznvy => 'test@example.com',
+ update => 'update from a registered user',
+ add_alert => 1,
+ },
+ alert => 1,
+ },
+) {
+ subtest $test->{desc} => sub {
+ # clear out comments for this problem to make
+ # checking details easier later
+ ok( $_->delete, 'deleted comment ' . $_->id )
+ for $report->comments;
- $mech->clear_emails_ok();
+ $mech->clear_emails_ok();
- $mech->log_in_ok( $user->email );
- $mech->get_ok("/report/$report_id");
+ $mech->log_in_ok( $user->email );
+ $mech->get_ok("/report/$report_id");
- $mech->submit_form_ok(
- {
- with_fields => {
- rznvy => 'test@example.com',
- update => 'update from a registered user'
- }
- },
- 'submit update'
- );
+ $mech->submit_form_ok(
+ {
+ with_fields => $test->{fields},
+ },
+ 'submit update'
+ );
- is $mech->uri->path, "/report/" . $report_id, "redirected to report page";
+ is $mech->uri->path, "/report/" . $report_id, "redirected to report page";
- $mech->email_count_is(0);
+ $mech->email_count_is(0);
- my $update = $report->comments->first;
- ok $update, 'found update';
- is $update->text, 'update from a registered user', 'update text';
- is $update->user->email, 'test@example.com', 'update user';
- is $update->state, 'confirmed', 'update confirmed';
-};
+ my $update = $report->comments->first;
+ ok $update, 'found update';
+ is $update->text, $test->{fields}->{update}, 'update text';
+ is $update->user->email, 'test@example.com', 'update user';
+ is $update->state, 'confirmed', 'update confirmed';
+
+ my $alert =
+ FixMyStreet::App->model('DB::Alert')
+ ->find( { user => $user, alert_type => 'new_updates' } );
+
+ ok $test->{alert} ? $alert : !$alert, 'not signed up for alerts';
+ };
+}
ok $comment->delete, 'deleted comment';
$mech->delete_user('commenter@example.com');