[FIX] test_website: add test for duplicate sitemap URL fix
See previous commit, it fixes duplicate URLs from sitemap. It appears when there is a custom defined sitemap method on a route defined with multiple endpoints. There will be as many duplicates as there is endpoint. closes odoo/odoo#108670 X-original-commit: 9ca24c3020d98dcd6e9266ae76adb13afbf1bd40 Signed-off-by: Romain Derie (rde) <rde@odoo.com> Signed-off-by: Jérémy Kersten <jke@odoo.com>
This commit is contained in:
@@ -142,3 +142,15 @@ class WebsiteTest(Home):
|
||||
@http.route(['/test_website/test_redirect_view_qs'], type='http', auth="public", website=True, sitemap=False)
|
||||
def test_redirect_view_qs(self, **kw):
|
||||
return request.render('test_website.test_redirect_view_qs')
|
||||
|
||||
# Test Sitemap
|
||||
def sitemap_test(env, rule, qs):
|
||||
if not qs or qs.lower() in '/test_website_sitemap':
|
||||
yield {'loc': '/test_website_sitemap'}
|
||||
|
||||
@http.route([
|
||||
'/test_website_sitemap',
|
||||
'/test_website_sitemap/something/<model("test.model"):rec>',
|
||||
], type='http', auth='public', website=True, sitemap=sitemap_test)
|
||||
def test_sitemap(self, rec=None, **kwargs):
|
||||
return request.make_response('Sitemap Testing Page')
|
||||
|
||||
@@ -35,3 +35,12 @@ class TestWebsiteControllerArgs(odoo.tests.HttpCase):
|
||||
req = self.url_open('/test_website/country/whatever-999999')
|
||||
self.assertEqual(req.status_code, 404,
|
||||
"Model converter record does not exist, return a 404.")
|
||||
|
||||
|
||||
@odoo.tests.common.tagged('post_install', '-at_install')
|
||||
class TestWebsiteControllers(odoo.tests.TransactionCase):
|
||||
|
||||
def test_01_sitemap(self):
|
||||
website = self.env['website'].browse(1)
|
||||
locs = website.with_user(website.user_id)._enumerate_pages(query_string='test_website_sitemap')
|
||||
self.assertEqual(len(list(locs)), 1, "The same URL should only be shown once")
|
||||
|
||||
Reference in New Issue
Block a user