Fix #4895: Deleted forum topics visible by default in index.
The bug was that since search parameters normally come from URL request parameters, a string value is expected here.
This commit is contained in:
@@ -17,7 +17,7 @@ class ForumTopicsController < ApplicationController
|
||||
def index
|
||||
if request.format.html?
|
||||
limit = params.fetch(:limit, 40)
|
||||
@forum_topics = authorize ForumTopic.visible(CurrentUser.user).paginated_search(params, limit: limit, defaults: { order: "sticky", is_deleted: false })
|
||||
@forum_topics = authorize ForumTopic.visible(CurrentUser.user).paginated_search(params, limit: limit, defaults: { order: "sticky", is_deleted: "false" })
|
||||
else
|
||||
@forum_topics = authorize ForumTopic.visible(CurrentUser.user).paginated_search(params)
|
||||
end
|
||||
|
||||
@@ -124,6 +124,15 @@ class ForumTopicsControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_equal(ForumTopic.visible(User.anonymous).count, response.parsed_body.css("urlset url loc").size)
|
||||
end
|
||||
|
||||
should "not show deleted topics for HTML responses by default" do
|
||||
as(@user) { create(:forum_topic, is_deleted: true) }
|
||||
get forum_topics_path
|
||||
|
||||
assert_response :success
|
||||
assert_select 'tr[data-is-deleted="true"]', count: 0
|
||||
assert_select 'tr[data-is-deleted="false"]', count: 3
|
||||
end
|
||||
|
||||
context "with private topics" do
|
||||
should "not show private topics to unprivileged users" do
|
||||
as(@user) { @other_topic.update!(min_level: User::Levels::MODERATOR) }
|
||||
|
||||
Reference in New Issue
Block a user