mirror of
https://github.com/discourse/discourse.git
synced 2026-08-11 02:59:07 +08:00
This PR makes a bookmark's "Assigned to …" badge reflect only the current, active assignment of the exact item that was bookmarked. In discourse-assign, a topic or an individual post can be assigned to a user or group, and bookmark lists show a badge for it. Previously, `BookmarkQuery.on_preload` loaded every assignment belonging to a bookmarked topic — without filtering on `active`, and keyed by `topic_id` regardless of `target_type`. Bookmarks kept showing "Assigned to …" after an assignment was deactivated (for example by `unassign_on_close`), and when a topic carried both a direct assignment and post-level assignments, whichever row loaded last won, so a bookmark could show an assignee that was never assigned the bookmarked item at all. Post bookmarks had a second problem: the `UserBookmarkBaseSerializer` extension read the topic's assignment for them, so a bookmark on an assigned post never showed that post's own assignee.
63 lines
1.4 KiB
Ruby
Vendored
63 lines
1.4 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Pages
|
|
class UserActivityBookmarks < PageObjects::Pages::Base
|
|
def visit(user, q: nil)
|
|
url = "/u/#{user.username_lower}/activity/bookmarks"
|
|
url += "?q=#{q}" if q
|
|
page.visit(url)
|
|
self
|
|
end
|
|
|
|
def search_for(query)
|
|
fill_in_search(query).submit_button.click
|
|
self
|
|
end
|
|
|
|
def clear_query
|
|
search_for("")
|
|
self
|
|
end
|
|
|
|
def clear_query_with_backspace
|
|
search_element.click
|
|
page.execute_script(
|
|
"arguments[0].selectionStart = arguments[0].selectionEnd = arguments[0].value.length",
|
|
search_element.native,
|
|
)
|
|
search_element.value.length.times { search_element.send_keys(:backspace) }
|
|
self
|
|
end
|
|
|
|
def fill_in_search(query)
|
|
fill_in("bookmark-search", with: query)
|
|
self
|
|
end
|
|
|
|
def search_element
|
|
find_by_id("bookmark-search")
|
|
end
|
|
|
|
def has_empty_search?
|
|
search_element.value == ""
|
|
end
|
|
|
|
def has_topic?(topic)
|
|
has_content?(topic.title)
|
|
end
|
|
|
|
def has_no_topic?(topic)
|
|
has_no_content?(topic.title)
|
|
end
|
|
|
|
def bookmark_list
|
|
PageObjects::Components::BookmarkList.new
|
|
end
|
|
|
|
def submit_button
|
|
page.find(".bookmark-search-form button")
|
|
end
|
|
end
|
|
end
|
|
end
|