diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-07-16 22:05:52 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-08-10 11:30:41 +0100 |
commit | cc3e99fa9878bfb722e61d4a09d94839b152c5b7 (patch) | |
tree | aa273efab59cb60c6c0edc37de9b7665aa49b27d /t | |
parent | fe4153e367bcbb74eebed9c8ac0126d94709506c (diff) |
Set up translatable category columns.
As category is used both for display and as a link between Problem and
Contact tables, add `category_display` for use whenever a category is
displayed.
Diffstat (limited to 't')
-rw-r--r-- | t/app/model/problem.t | 9 | ||||
-rw-r--r-- | t/roles/translatable.t | 39 |
2 files changed, 39 insertions, 9 deletions
diff --git a/t/app/model/problem.t b/t/app/model/problem.t index 76b7c476a..718b980b0 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -117,15 +117,6 @@ for my $test ( } }, { - desc => 'bad category', - changed => { - category => '-- Pick a property type --', - }, - errors => { - category => 'Please choose a property type', - } - }, - { desc => 'correct category', changed => { category => 'Horse!', diff --git a/t/roles/translatable.t b/t/roles/translatable.t index a33b2d9d0..bbe05ce9f 100644 --- a/t/roles/translatable.t +++ b/t/roles/translatable.t @@ -2,6 +2,11 @@ use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; my $body = FixMyStreet::DB->resultset("Body")->create({ name => 'Dunkirk' }); +my $contact = $mech->create_contact_ok( + body => $body, + email => 'potholes@dunkirk', + category => 'Potholes' +); FixMyStreet::DB->resultset("Translation")->create({ lang => "fr", @@ -11,12 +16,46 @@ FixMyStreet::DB->resultset("Translation")->create({ msgstr => "Dunkerque", }); +FixMyStreet::DB->resultset("Translation")->create({ + lang => "de", + tbl => "contact", + object_id => $contact->id, + col => "category", + msgstr => "Schlaglöcher", +}); + +FixMyStreet::DB->resultset("Translation")->create({ + lang => "nb", + tbl => "contact", + object_id => $contact->id, + col => "category", + msgstr => "Hull i veien", +}); + +my ($problem) = $mech->create_problems_for_body(1, $body->id, "Title", { + whensent => \'current_timestamp', + category => 'Potholes', +}); + is $body->name, "Dunkirk"; +is $contact->category_display, "Potholes"; +is $problem->category_display, "Potholes"; FixMyStreet::DB->schema->lang("fr"); is $body->name, "Dunkerque"; +is $contact->category_display, "Potholes"; +is $problem->category_display, "Potholes"; FixMyStreet::DB->schema->lang("de"); is $body->name, "Dunkirk"; +is $contact->category_display, "Schlaglöcher"; +is $problem->category_display, "Schlaglöcher"; + +FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'fiksgatami' ], +}, sub { + $mech->get_ok($problem->url); + $mech->content_contains('Hull i veien'); +}; done_testing; |