FIX: Show better error if no bookmarks found from search (#11284)
See https://meta.discourse.org/t/no-results-for-bookmarks-search-confusing-message/169763
This commit is contained in:
parent
333f0af0ec
commit
a6f700d4ef
|
@ -1542,7 +1542,9 @@ class UsersController < ApplicationController
|
|||
if bookmark_list.bookmarks.empty?
|
||||
render json: {
|
||||
bookmarks: [],
|
||||
no_results_help: I18n.t("user_activity.no_bookmarks.self")
|
||||
no_results_help: I18n.t(
|
||||
params[:q].present? ? "user_activity.no_bookmarks.search" : "user_activity.no_bookmarks.self"
|
||||
)
|
||||
}
|
||||
else
|
||||
page = params[:page].to_i + 1
|
||||
|
|
|
@ -954,6 +954,7 @@ en:
|
|||
others: "No activity."
|
||||
no_bookmarks:
|
||||
self: "You have no bookmarked posts; bookmarks allow you to quickly refer to specific posts."
|
||||
search: "No bookmarks found with the provided search query."
|
||||
others: "No bookmarks."
|
||||
no_likes_given:
|
||||
self: "You have not liked any posts."
|
||||
|
|
|
@ -4561,6 +4561,31 @@ describe UsersController do
|
|||
get "/u/#{bookmark3.user.username}/bookmarks.json"
|
||||
expect(response.status).to eq(403)
|
||||
end
|
||||
|
||||
it "shows a helpful message if no bookmarks are found" do
|
||||
bookmark1.destroy
|
||||
bookmark2.destroy
|
||||
bookmark3.destroy
|
||||
sign_in(user)
|
||||
get "/u/#{user.username}/bookmarks.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.parsed_body['bookmarks']).to eq([])
|
||||
expect(response.parsed_body['no_results_help']).to eq(
|
||||
I18n.t('user_activity.no_bookmarks.self')
|
||||
)
|
||||
end
|
||||
|
||||
it "shows a helpful message if no bookmarks are found for the search" do
|
||||
sign_in(user)
|
||||
get "/u/#{user.username}/bookmarks.json", params: {
|
||||
q: 'badsearch'
|
||||
}
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.parsed_body['bookmarks']).to eq([])
|
||||
expect(response.parsed_body['no_results_help']).to eq(
|
||||
I18n.t('user_activity.no_bookmarks.search')
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def create_second_factor_security_key
|
||||
|
|
Loading…
Reference in New Issue