Repository: ckan/ckan

Issue:
`search` legacy route missing
### CKAN Version if known (or site URL)
2.8+ (master)

### Please describe the expected behaviour
There is a shortcut for the `search` legacy route in CKAN 2.8+, I guess it's missing in [LEGACY_ROUTE_NAMES](https://github.com/ckan/ckan/blob/df35eec2f5229bc60176cf96dc83ca1fcc259d1e/ckan/lib/helpers.py#L68-L71).

### Please describe the actual behaviour
On master `search` is not available as route, basically the same as described in #4066

### What steps can be taken to reproduce the issue? 

```python
h.build_nav_main(
          ('home', _('Homepage')),
          ('search', _('Datasets')),
          ('group_index', _('Groups'))
        )
```


Discussion:
@metaodi it was not added as the 'package' controller was not merged in that time, but i think it could be added in the .ini file 
http://docs.ckan.org/en/2.8/maintaining/configuration.html#ckan-legacy-route-mappings

edit: but you are right, we should add it in the helper 
Well yes, but I think all legacy routes should be added there for compatibility reasons. If I provide a CKAN extension, it should work on all CKAN versions. The ini file might be a solution for tests, but I don't want all users of an extension to add `ckan.legacy_route_mappings` to their instances ini file, just because the extension runs on multiple versions of CKAN.
@tino097 Why have you removed `group_index` again? Now my build fails, because this route is still missing.
Here is the link to the build: https://travis-ci.org/opendatazurich/ckanext-stadtzh-theme/jobs/405325390#L1427

I'd propose to add a test for this, calling build_nav_main() with the legacy routes should not raise an exception.
@metaodi 
in the [review](https://github.com/ckan/ckan/pull/4348#discussion_r203759217) was pointed out that those routes should be handled in the helper
ping @amercader 
@tino097 @amercader just let me know if you want help. Happy to provide a PR with the test and/or the updated legacy routes.
@metaodi why just not update the nav menu in the template in your extension? As the migration to Flask will be finishing, those routes would be deprecated 
@tino097 because the extension runs on multiple versions of CKAN, older version do not support the new flask-based names obviously, so the new CKAN version should support the old names to be backwards compatible.
I was mistaken in the way `build_nav_main` works (a truly terrible way btw), I assumed it was calling `url_for` directly (which is where the support for old Pylons routes exists) but apparently is doing some other voodoo first, which means that yes, we need to add it to `LEGACY_ROUTE_NAMES`.

@tino097 just to be clear the `group_index` item only affects master so it doesn't need to go to 2.8.1
@metaodi a PR readding the route would be great thanks.

Resolving patch:
diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py
--- a/ckan/lib/helpers.py
+++ b/ckan/lib/helpers.py
@@ -69,6 +69,7 @@
     'home': 'home.index',
     'about': 'home.about',
     'search': 'dataset.search',
+    'group_index': 'group.index',
     'organizations_index': 'organization.index'
 }
 


Test patch:
diff --git a/ckan/tests/lib/test_helpers.py b/ckan/tests/lib/test_helpers.py
--- a/ckan/tests/lib/test_helpers.py
+++ b/ckan/tests/lib/test_helpers.py
@@ -532,6 +532,38 @@ def test_non_string(self):
             u'2018-01-05 10:48:23.463511')
 
 
+class TestBuildNavMain(object):
+    def test_flask_routes(self):
+        menu = (
+            ('home.index', 'Home'),
+            ('dataset.search', 'Datasets'),
+            ('organization.index', 'Organizations'),
+            ('group.index', 'Groups'),
+            ('home.about', 'About')
+        )
+        eq_(h.build_nav_main(*menu), (
+            '<li><a href="/">Home</a></li>'
+            '<li><a href="/dataset/">Datasets</a></li>'
+            '<li><a href="/organization/">Organizations</a></li>'
+            '<li><a href="/group/">Groups</a></li>'
+            '<li><a href="/about">About</a></li>'))
+
+    def test_legacy_pylon_routes(self):
+        menu = (
+            ('home', 'Home'),
+            ('search', 'Datasets'),
+            ('organizations_index', 'Organizations'),
+            ('group_index', 'Groups'),
+            ('about', 'About')
+        )
+        eq_(h.build_nav_main(*menu), (
+            '<li><a href="/">Home</a></li>'
+            '<li><a href="/dataset/">Datasets</a></li>'
+            '<li><a href="/organization/">Organizations</a></li>'
+            '<li><a href="/group/">Groups</a></li>'
+            '<li><a href="/about">About</a></li>'))
+
+
 class TestHelperException(helpers.FunctionalTestBase):
 
     @raises(ckan.exceptions.HelperError)