aboutsummaryrefslogtreecommitdiffstats
path: root/t/app
diff options
context:
space:
mode:
Diffstat (limited to 't/app')
-rw-r--r--t/app/controller/report_inspect.t22
-rw-r--r--t/app/controller/rss.t1
-rw-r--r--t/app/sendreport/inspection_required.t32
3 files changed, 53 insertions, 2 deletions
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t
index 4caeef501..831959fff 100644
--- a/t/app/controller/report_inspect.t
+++ b/t/app/controller/report_inspect.t
@@ -6,8 +6,8 @@ use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
-my $brum = $mech->create_body_ok(2514, 'Birmingham City Council');
-my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council');
+my $brum = $mech->create_body_ok(2514, 'Birmingham City Council', id => 2514);
+my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council', id => 2237);
my $contact = $mech->create_contact_ok( body_id => $oxon->id, category => 'Cows', email => 'cows@example.net' );
my $rp = FixMyStreet::DB->resultset("ResponsePriority")->create({
body => $oxon,
@@ -55,11 +55,13 @@ FixMyStreet::override_config {
subtest "test inspect & instruct submission" => sub {
$report->unset_extra_metadata('inspected');
$report->update;
+ my $reputation = $report->user->get_extra_metadata("reputation");
$mech->get_ok("/report/$report_id/inspect");
$mech->submit_form_ok({ button => 'save', with_fields => { public_update => "This is a public update.", save_inspected => "1" } });
$report->discard_changes;
is $report->comments->first->text, "This is a public update.", 'Update was created';
is $report->get_extra_metadata('inspected'), 1, 'report marked as inspected';
+ is $report->user->get_extra_metadata('reputation'), $reputation+1, "User reputation was increased";
};
subtest "test update is required when instructing" => sub {
@@ -107,6 +109,22 @@ FixMyStreet::override_config {
}
};
+FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ ALLOWED_COBRANDS => 'oxfordshire',
+}, sub {
+ subtest "test negative reputation" => sub {
+ my $reputation = $report->user->get_extra_metadata("reputation");
+
+ $mech->get_ok("/report/$report_id");
+ $mech->submit_form( button => 'remove_from_site' );
+
+ $report->discard_changes;
+ is $report->user->get_extra_metadata('reputation'), $reputation-1, "User reputation was decreased";
+ };
+};
+
+
END {
$mech->delete_body($oxon);
$mech->delete_body($brum);
diff --git a/t/app/controller/rss.t b/t/app/controller/rss.t
index 8b39219fa..4f737dda7 100644
--- a/t/app/controller/rss.t
+++ b/t/app/controller/rss.t
@@ -50,6 +50,7 @@ FixMyStreet::override_config {
};
$mech->content_contains( "Testing, 10th October" );
$mech->content_lacks( 'Nearest road to the pin' );
+is $mech->response->header('Access-Control-Allow-Origin'), '*';
$report->geocode(
{
diff --git a/t/app/sendreport/inspection_required.t b/t/app/sendreport/inspection_required.t
index 88a48e991..f9d40d39f 100644
--- a/t/app/sendreport/inspection_required.t
+++ b/t/app/sendreport/inspection_required.t
@@ -69,6 +69,38 @@ subtest 'Uninspected report is sent when made by trusted user' => sub {
$report->discard_changes;
$mech->email_count_is( 1 );
ok $report->whensent, 'Report marked as sent';
+ is $report->get_extra_metadata('inspected'), undef, 'Report not marked as inspected';
+};
+
+subtest 'Uninspected report isn’t sent when user rep is too low' => sub {
+ $mech->clear_emails_ok;
+ $report->whensent( undef );
+ $report->update;
+
+ $user->user_body_permissions->delete;
+ $user->set_extra_metadata(reputation => 15);
+ $user->update;
+
+ $contact->set_extra_metadata(reputation_threshold => 20);
+ $contact->update;
+
+ FixMyStreet::DB->resultset('Problem')->send_reports();
+
+ $report->discard_changes;
+ $mech->email_count_is( 0 );
+ is $report->whensent, undef, 'Report hasn’t been sent';
+};
+
+subtest 'Uninspected report is sent when user rep is high enough' => sub {
+ $user->set_extra_metadata(reputation => 21);
+ $user->update;
+
+ FixMyStreet::DB->resultset('Problem')->send_reports();
+
+ $report->discard_changes;
+ $mech->email_count_is( 1 );
+ ok $report->whensent, 'Report marked as sent';
+ is $report->get_extra_metadata('inspected'), undef, 'Report not marked as inspected';
};
done_testing();