diff options
author | Matthew Somerville <matthew@mysociety.org> | 2013-02-01 15:28:08 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2013-02-04 06:53:02 +0000 |
commit | 488a8f21a0c1bc2b9501c9d94d69db56cccd80ae (patch) | |
tree | 68becf501e9492466a80015e8ace9a7fb1557cfa /t/app/controller/report_interest_count.t | |
parent | 3e0d12e8584d132b573f536ab5cd01e24241827b (diff) | |
parent | 28aa1dd7fb1c9bc93aa204afae67cf68fe36ee6b (diff) |
Merge remote branch 'origin/zurich'
Conflicts:
bin/open311-populate-service-list
bin/send-comments
bin/update-all-reports
conf/crontab.ugly
db/schema.sql
perllib/FixMyStreet/App/Controller/Admin.pm
perllib/FixMyStreet/App/Controller/Report/New.pm
perllib/FixMyStreet/App/Controller/Reports.pm
perllib/FixMyStreet/Cobrand/Default.pm
perllib/FixMyStreet/Cobrand/LichfieldDC.pm
perllib/FixMyStreet/DB/Result/Open311conf.pm
perllib/FixMyStreet/DB/Result/Problem.pm
perllib/FixMyStreet/DB/ResultSet/Problem.pm
perllib/FixMyStreet/SendReport.pm
perllib/FixMyStreet/SendReport/Email.pm
perllib/FixMyStreet/SendReport/Open311.pm
perllib/Open311/GetServiceRequestUpdates.pm
perllib/Open311/PopulateServiceList.pm
t/app/controller/report_new.t
t/app/controller/rss.t
templates/web/bromley/report/display.html
templates/web/default/admin/council_contacts.html
templates/web/default/common_header_tags.html
templates/web/default/dashboard/index.html
templates/web/default/front/stats.html
templates/web/default/report/_main.html
templates/web/default/report/update-form.html
templates/web/emptyhomes/index.html
templates/web/emptyhomes/report/display.html
templates/web/emptyhomes/report/new/councils_text_all.html
templates/web/emptyhomes/reports/body.html
templates/web/emptyhomes/reports/index.html
templates/web/fixmystreet/report/new/fill_in_details_form.html
templates/web/fixmystreet/report/update-form.html
web/cobrands/fixmystreet/fixmystreet.js
web/js/fixmystreet.js
Diffstat (limited to 't/app/controller/report_interest_count.t')
-rw-r--r-- | t/app/controller/report_interest_count.t | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/t/app/controller/report_interest_count.t b/t/app/controller/report_interest_count.t index dd44a83d4..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, @@ -33,7 +28,7 @@ my $dt = DateTime->new( my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( { postcode => 'SW1A 1AA', - council => '2504', + bodies_str => '2504', areas => ',105255,11806,11828,2247,2504,', category => 'Other', title => 'Test 2', @@ -59,21 +54,24 @@ 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 council then no supporter button', - from_council => 0, + desc => 'if not from body then no supporter button', + from_body => undef, support_string => 'No supporters', }, { - desc => 'from council user can increment supported count', - from_council => 2504, + desc => 'from body user can increment supported count', + from_body => 2504, support_string => 'No supporters', updated_support => '1 supporter' }, { desc => 'correct grammar for more than one supporter', - from_council => 2504, + from_body => 2504, support_string => '1 supporter', updated_support => '2 supporters' }, @@ -81,17 +79,17 @@ SKIP: { subtest $test->{desc} => sub { ok $mech->host('fixmybarangay.com'), 'changed to fixmybarangay'; $mech->log_in_ok( $user->email ); - $user->from_council( $test->{from_council} ); + $user->from_body( $test->{from_body} ); $user->update; - $report->discard_changes; - $report->council( $test->{report_council} ); - $report->update; + $report->update( { + bodies_str => $test->{report_council} + } ); $mech->get_ok("/report/$report_id"); $mech->content_contains( $test->{support_string} ); - if ( $test->{from_council} ) { + if ( $test->{from_body} ) { $mech->content_contains('Add support'); $mech->submit_form_ok( { form_number => 1 } ); @@ -104,18 +102,16 @@ SKIP: { }; } - subtest 'check non council user cannot increment support count' => sub { + 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'; @@ -135,7 +131,7 @@ subtest 'check support details not shown if not enabled in cobrand' => sub { }; $report->discard_changes; -$report->council( 2504 ); +$report->bodies_str( 2504 ); $report->update; # tidy up |