From 7d8a683eb3f53ae995b86103f95a78204953f81a Mon Sep 17 00:00:00 2001 From: Serghei Mihai Date: Thu, 23 Feb 2017 11:09:45 +0100 Subject: [PATCH] manager: fix redirect url after announce edit (#15110) --- corbo/views.py | 2 +- tests/test_manager.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/corbo/views.py b/corbo/views.py index 80c0e37..429203f 100644 --- a/corbo/views.py +++ b/corbo/views.py @@ -87,7 +87,7 @@ class AnnounceEditView(UpdateView): return context def get_success_url(self): - return reverse('view_category', kwargs={'pk': self.object.category.pk}) + return reverse('view_category', kwargs={'slug': self.object.category.slug}) edit_announce = AnnounceEditView.as_view() diff --git a/tests/test_manager.py b/tests/test_manager.py index 9c1d6ba..518bdae 100644 --- a/tests/test_manager.py +++ b/tests/test_manager.py @@ -120,6 +120,34 @@ def test_create_announce(app, admin_user): resp = app.get('http://localhost:80/manage/category/alerts/') assert 'First announce' in resp.content +def test_edit_announce(app, admin_user): + app = login(app) + resp = app.get('/manage/') + assert 'New category' in resp.content + category_page = resp.click('New category') + category_form = category_page.forms[0] + category_form['name'] = 'Alerts' + resp = category_form.submit() + assert resp.status_int == 302 + assert resp.location == 'http://localhost:80/manage/' + resp = app.get(resp.location) + resp = resp.click('Alerts') + assert 'New announce' in resp.content + announce_page = resp.click('New announce') + announce_form = announce_page.forms[0] + announce_form['title'] = 'First announce' + announce_form['text'] = 'announce content' + resp = announce_form.submit() + assert resp.status_int == 302 + assert resp.location == 'http://localhost:80/manage/category/alerts/' + resp = app.get(resp.location) + assert 'First announce' in resp.content + announce_edit_page = resp.click('First announce') + edit_form = announce_edit_page.forms[0] + edit_form['publication_time'] = '2017-03-03 09:00:00' + resp = edit_form.submit() + assert resp.status_int == 302 + assert resp.location == 'http://localhost:80/manage/category/alerts/' def test_delete_announce(app, admin_user): app = login(app) -- 2.11.0