Files
odoo_source/addons/rating/tests/test_controller.py
T
damr 00892a3edb [FIX] 14.0 rating: submit rating feedback with 'get' method
In rating/controllers/main.py, the method action_submit_rating accepts
only post request. This creates a problem when you're trying to use the
web editor on the template as well as when you just paste the url in
your browser, for those are get request. The current behavior is a crash
with 'method not allowed'. This commit's purpose is to change the method
so it also accept get request. The use case of editing the feedback
rating page is arguable but it schould not crash.

The behavior after this commit is that the web editor is enable for the
page, and relaoding the page does not crash anymore.

task-3047893

closes odoo/odoo#105985

X-original-commit: 1b61faad8281d8b8d2fa1bf526f2ae2c4c8ba07b
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2022-11-17 21:58:53 +01:00

26 lines
1.0 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests import HttpCase, tagged, new_test_user
@tagged('post_install', '-at_install')
class TestControllersRoute(HttpCase):
def setUp(self):
super(TestControllersRoute, self).setUp()
self.user = new_test_user(self.env, "test_user_1", email="test_user_1@nowhere.com", tz="UTC")
self.partner = self.user.partner_id
def test_controller_rating(self):
rating_test = self.env['rating.rating'].with_user(self.user).create({
'res_model_id': self.env['ir.model'].sudo().search([('model', '=', 'res.partner')], limit=1).id,
'res_model': 'res.partner',
'res_id': self.partner.id,
'rating': 3
})
self.authenticate(None, None)
access_token = rating_test.access_token
url = '/rate/%s/submit_feedback' % access_token
req = self.url_open(url)
self.assertEqual(req.status_code, 200, "Response should = OK")