aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-12-14 12:11:13 +0000
committerMatthew Somerville <matthew@mysociety.org>2012-12-15 00:11:06 +0000
commitff06783c6dc50321100a54b4d4a624fde2212689 (patch)
tree38d7f914f841a6ba8ea3225bae3cacbabc80dbf9 /t/app/controller
parentbb356c880412db8bad655e081ad6d68f25ae3ff7 (diff)
Make from_body a foreign key.
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/admin.t5
-rw-r--r--t/app/controller/report_display.t5
-rw-r--r--t/app/controller/report_interest_count.t22
-rw-r--r--t/app/controller/report_updates.t12
4 files changed, 24 insertions, 20 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index a43a875c3..d759c1238 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -845,6 +845,8 @@ for my $test (
};
}
+$mech->create_body_ok(2504, 'Westminster City Council');
+
for my $test (
{
desc => 'user is problem owner',
@@ -1082,6 +1084,8 @@ subtest 'show flagged entries' => sub {
$mech->content_contains( $user->email );
};
+$mech->create_body_ok(2509, 'Haringey Borough Council');
+
subtest 'user search' => sub {
$mech->get_ok('/admin/users');
$mech->get_ok('/admin/users?search=' . $user->name);
@@ -1115,7 +1119,6 @@ is $log_entries->count, 0, 'no admin log entries';
$user->flagged( 0 );
$user->update;
-$mech->create_body_ok(2509, 'Haringey Borough Council');
$mech->create_body_ok(2607, 'Southend-on-Sea Borough Council');
for my $test (
diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t
index 4c7b33f73..5ae3bdfb3 100644
--- a/t/app/controller/report_display.t
+++ b/t/app/controller/report_display.t
@@ -345,10 +345,13 @@ for my $test (
};
}
+$mech->create_body_ok(2504, 'Westminster City Council');
+$mech->create_body_ok(2505, 'Camden Borough Council');
+
for my $test (
{
desc => 'no state dropdown if user not from authority',
- from_body => 0,
+ from_body => undef,
no_state => 1,
report_body => '2504',
},
diff --git a/t/app/controller/report_interest_count.t b/t/app/controller/report_interest_count.t
index d0e0054c4..bfd1a8d1f 100644
--- a/t/app/controller/report_interest_count.t
+++ b/t/app/controller/report_interest_count.t
@@ -16,11 +16,6 @@ my $user =
->find_or_create( { email => 'test@example.com', name => 'Test User' } );
ok $user, "created test user";
-my $user2 =
- FixMyStreet::App->model('DB::User')
- ->find_or_create( { email => 'test2@example.com', name => 'Other User' } );
-ok $user2, "created test user";
-
my $dt = DateTime->new(
year => 2011,
month => 04,
@@ -59,10 +54,13 @@ ok $report, "created test report - $report_id";
SKIP: {
skip( "Need 'fixmybarangay' in ALLOWED_COBRANDS config", 29 )
unless FixMyStreet::Cobrand->exists('fixmybarangay');
+
+ $mech->create_body_ok(2504, 'Westminster City Council');
+
for my $test (
{
desc => 'if not from body then no supporter button',
- from_body => 0,
+ from_body => undef,
support_string => 'No supporters',
},
{
@@ -84,9 +82,9 @@ SKIP: {
$user->from_body( $test->{from_body} );
$user->update;
- $report->discard_changes;
- $report->bodies_str( $test->{report_council} );
- $report->update;
+ $report->update( {
+ bodies_str => $test->{report_council}
+ } );
$mech->get_ok("/report/$report_id");
$mech->content_contains( $test->{support_string} );
@@ -106,16 +104,14 @@ SKIP: {
subtest 'check non body user cannot increment support count' => sub {
ok $mech->host('fixmybarangay.com'), 'changed to fixmybarangay';
- $report->discard_changes;
- $report->interest_count(1);
- ok $report->update(), 'updated interest count';
- $report->discard_changes;
+ ok $report->update({ interest_count => 1 }), 'updated interest count';
is $report->interest_count, 1, 'correct interest count';
$mech->get_ok("/report/$report_id");
$mech->content_contains( '1 supporter' );
+ # This doesn't send cookie, so is logged out
$mech->post_ok("/report/support", { id => $report_id } );
is $mech->uri, "http://fixmybarangay.com/report/$report_id", 'add support redirects to report page';
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index fe1c27199..5accb9ce4 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -409,7 +409,7 @@ $report->update;
subtest 'check non authority user cannot change set state' => sub {
$mech->log_in_ok( $user->email );
- $user->from_body( 0 );
+ $user->from_body( undef );
$user->update;
$mech->get_ok("/report/$report_id");
@@ -434,6 +434,8 @@ subtest 'check non authority user cannot change set state' => sub {
is $report->state, 'confirmed', 'state unchanged';
};
+$mech->create_body_ok(2504, 'Westminster City Council');
+
for my $state ( qw/unconfirmed hidden partial/ ) {
subtest "check that update cannot set state to $state" => sub {
$mech->log_in_ok( $user->email );
@@ -547,13 +549,13 @@ for my $test (
state => 'fixed',
},
state => 'fixed - council',
- report_councils => '2504,2505',
+ report_bodies => '2504,2505',
},
) {
subtest $test->{desc} => sub {
$report->comments->delete;
- if ( $test->{ report_councils } ) {
- $report->bodies_str( $test->{ report_councils } );
+ if ( $test->{ report_bodies } ) {
+ $report->bodies_str( $test->{ report_bodies } );
$report->update;
}
@@ -629,7 +631,7 @@ subtest 'check meta correct for comments marked confirmed but not marked open' =
unlike $update_meta->[0], qr/reopened$/, 'update meta does not say reopened';
};
-$user->from_body(0);
+$user->from_body(undef);
$user->update;
$report->state('confirmed');