forum: fix topics being incorrectly marked as unread (again).

Second attempt at 71690cacc. Fix topics on page 2+ being still marked as
unread after the user has marked all topics as read.
This commit is contained in:
evazion
2020-01-22 18:33:03 -06:00
parent 22cb0ea322
commit cc96f30e47
6 changed files with 69 additions and 90 deletions

View File

@@ -128,6 +128,52 @@ class ForumTopicsControllerTest < ActionDispatch::IntegrationTest
assert_select "a.forum-post-link", count: 0, text: @topic2.title
end
end
context "when listing topics" do
should "always show topics as read for anonymous users" do
get forum_topics_path
assert_select "span.new", count: 0
end
should "show topics as read after viewing them" do
get_auth forum_topics_path, @user
assert_response :success
assert_select "span.new", count: 3
get_auth forum_topic_path(@forum_topic.id), @user
assert_response :success
get_auth forum_topics_path, @user
assert_response :success
assert_select "span.new", count: 2
end
should "show topics as read after marking all as read" do
get_auth forum_topics_path, @user
assert_response :success
assert_select "span.new", count: 3
post_auth mark_all_as_read_forum_topics_path, @user
assert_response 302
get_auth forum_topics_path, @user
assert_response :success
assert_select "span.new", count: 0
end
should "show topics on page 2 as read after marking all as read" do
get_auth forum_topics_path(page: 2, limit: 1), @user
assert_response :success
assert_select "span.new", count: 1
post_auth mark_all_as_read_forum_topics_path, @user
assert_response 302
get_auth forum_topics_path(page: 2, limit: 1), @user
assert_response :success
assert_select "span.new", count: 0
end
end
end
context "edit action" do