You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by gc...@apache.org on 2022/11/08 17:30:08 UTC
[allura] branch gc/8475 updated: fixup! [#8475] updated test and conditional to return a 404
This is an automated email from the ASF dual-hosted git repository.
gcruz pushed a commit to branch gc/8475
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/gc/8475 by this push:
new 6be591ff0 fixup! [#8475] updated test and conditional to return a 404
6be591ff0 is described below
commit 6be591ff0d06bc4dc268a022ec9cc120576c5047
Author: Guillermo Cruz <gu...@slashdotmedia.com>
AuthorDate: Tue Nov 8 10:29:46 2022 -0700
fixup! [#8475] updated test and conditional to return a 404
---
Allura/allura/controllers/discuss.py | 2 +-
.../forgediscussion/tests/functional/test_forum.py | 24 ++++++++++++++--------
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index 8d6787aa9..986fe9151 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -208,7 +208,7 @@ class ThreadController(BaseController, FeedController, metaclass=h.ProxiedAttrMe
M.session.artifact_orm_session._get().skip_mod_date = True
M.session.artifact_orm_session._get().skip_last_updated = True
count = self.thread.query_posts(page=page, limit=int(limit)).count()
- if self.thread.num_replies == 0 or not all(p.status == 'ok' for p in self.thread.posts):
+ if self.thread.num_replies == 0 or all(p.status != 'ok' for p in self.thread.posts):
# return status code 404 but still display the page content
request.environ['tg.status_code_redirect'] = True
response.status_int = 404
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
index 0008302a5..c32510ecd 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -546,12 +546,12 @@ class TestForum(TestController):
params[f.find('textarea')['name']] = 'Post content'
params[f.find('select')['name']] = 'testforum'
params[f.find('input', {'style': 'width: 90%'})['name']] = 'Test Thread'
- thread = self.app.post('/discussion/save_new_topic', params=params, expect_errors=True,
+ thread = self.app.post('/discussion/save_new_topic', params=params,
extra_environ=dict(username='*anonymous'))
# assert post return 404 but content can still be seen and moderated
thread_url = thread.response.headers['Location']
- r = self.app.get(thread.response.headers['Location'], status=404, expect_errors=True,
+ r = self.app.get(thread_url, status=404,
extra_environ=dict(username='*anonymous'))
assert 'Post awaiting moderation' in r
assert 'name="delete"' not in r
@@ -569,14 +569,14 @@ class TestForum(TestController):
if field.has_attr('name'):
params[field['name']] = field.get('value') or ''
params[f.find('textarea')['name']] = 'anon reply to anon post content'
- r = self.app.post(str(rep_url), params=params, expect_errors=True, extra_environ=dict(username='*anonymous'))
- r = self.app.get(thread_url, status=404, expect_errors=True,
+ r = self.app.post(str(rep_url), params=params, extra_environ=dict(username='*anonymous'))
+ r = self.app.get(thread_url, status=404,
extra_environ=dict(username='*anonymous'))
assert 'anon reply to anon post' not in r
assert_equal(spam_checker.check.call_args[0][0], 'anon reply to anon post content')
# assert moderation controls appear for admin
- r = self.app.get(thread_url, expect_errors=True, extra_environ=dict(username='test-admin'))
+ r = self.app.get(thread_url, extra_environ=dict(username='test-admin'), status=404)
assert '<div class="display_post moderate">' in r
assert '<i class="fa fa-reply"></i>' in r
@@ -601,11 +601,19 @@ class TestForum(TestController):
'approve': 'Approve Marked'})
post = FM.ForumPost.query.get(text='Post content')
+ post2 = FM.ForumPost.query.get(text='anon reply to anon post content')
assert 'ok' == post.status
+ assert 'pending' == post2.status
+
+ # assert anon can't edit their original post
+ r = self.app.get(thread_url,
+ extra_environ=dict(username='*anonymous'))
+ assert 'Post content' in r
+ post_container = r.html.find('div', {'id': post.slug})
+
+ btn_edit = post_container.find('a', {'title': 'Edit'})
+ assert not btn_edit
- # assert spam posts return a 404
- r = self.app.get(thread_url, expect_errors=True, status=404)
- assert '404' in r.status
@td.with_tool('test2', 'Discussion', 'discussion')