diff options
author | Matthew Somerville <matthew@mysociety.org> | 2011-07-12 12:10:39 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2011-07-12 12:10:39 +0100 |
commit | 347f9a89f208ee6495b42f217a800e4eeaea5967 (patch) | |
tree | 939c3cfc1810a39b523a2c42acc6ce8748b1861c /t/app | |
parent | 3b340a7c28394aeed0e94eccfeeb14efef54b57a (diff) |
Store cobrand/lang upon an /import. Related to #134, though that was actually already fixed.
Diffstat (limited to 't/app')
-rw-r--r-- | t/app/controller/report_import.t | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/t/app/controller/report_import.t b/t/app/controller/report_import.t index ba73b2555..42b05e2b8 100644 --- a/t/app/controller/report_import.t +++ b/t/app/controller/report_import.t @@ -68,7 +68,6 @@ subtest "Test creating bad partial entries" => sub { }; -# submit an empty report to import - check we get all errors subtest "Submit a correct entry" => sub { $mech->get_ok('/import'); @@ -156,7 +155,6 @@ subtest "Submit a correct entry" => sub { $mech->delete_user($user); }; -# submit an empty report to import - check we get all errors subtest "Submit a correct entry (with location)" => sub { $mech->get_ok('/import'); @@ -235,4 +233,71 @@ subtest "Submit a correct entry (with location)" => sub { $mech->delete_user($user); }; +subtest "Submit a correct entry (with location) to cobrand" => sub { + + skip( "Need 'fiksgatami' in ALLOWED_COBRANDS config", 8 ) + unless FixMyStreet::App->config->{ALLOWED_COBRANDS} =~ m{fiksgatami}; + mySociety::MaPit::configure('http://mapit.nuug.no/'); + ok $mech->host("fiksgatami.no"), 'change host to fiksgatami'; + + $mech->get_ok('/import'); + + $mech->submit_form_ok( # + { + with_fields => { + service => 'test-script', + lat => '59', + lon => '10', + name => 'Test User ll', + email => 'test-ll@example.com', + subject => 'Test report ll', + detail => 'This is a test report ll', + photo => $sample_file, + } + }, + "fill in form" + ); + + is_deeply( $mech->import_errors, [], "got no errors" ); + is $mech->content, 'SUCCESS', "Got success response"; + + # check that we have received the email + $mech->email_count_is(1); + my $email = $mech->get_email; + $mech->clear_emails_ok; + + my ($token_url) = $email->body =~ m{(http://\S+)}; + ok $token_url, "Found a token url $token_url"; + + # go to the token url + $mech->get_ok($token_url); + + # check that we are on '/report/new' + is $mech->uri->path, '/report/new', "sent to /report/new"; + + # check that fields are prefilled for us + is_deeply $mech->visible_form_values, + { + name => 'Test User ll', + title => 'Test report ll', + detail => 'This is a test report ll', + photo => '', + phone => '', + may_show_name => '1', + }, + "check imported fields are shown"; + + my $user = + FixMyStreet::App->model('DB::User') + ->find( { email => 'test-ll@example.com' } ); + ok $user, "Found a user"; + + my $report = $user->problems->first; + is $report->state, 'partial', 'is still partial'; + is $report->title, 'Test report ll', 'title is correct'; + is $report->lang, 'nb', 'language is correct'; + + $mech->delete_user($user); +}; + done_testing(); |