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?
|
if bookmark_list.bookmarks.empty?
|
||||||
render json: {
|
render json: {
|
||||||
bookmarks: [],
|
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
|
else
|
||||||
page = params[:page].to_i + 1
|
page = params[:page].to_i + 1
|
||||||
|
|
|
@ -954,6 +954,7 @@ en:
|
||||||
others: "No activity."
|
others: "No activity."
|
||||||
no_bookmarks:
|
no_bookmarks:
|
||||||
self: "You have no bookmarked posts; bookmarks allow you to quickly refer to specific posts."
|
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."
|
others: "No bookmarks."
|
||||||
no_likes_given:
|
no_likes_given:
|
||||||
self: "You have not liked any posts."
|
self: "You have not liked any posts."
|
||||||
|
|
|
@ -4561,6 +4561,31 @@ describe UsersController do
|
||||||
get "/u/#{bookmark3.user.username}/bookmarks.json"
|
get "/u/#{bookmark3.user.username}/bookmarks.json"
|
||||||
expect(response.status).to eq(403)
|
expect(response.status).to eq(403)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def create_second_factor_security_key
|
def create_second_factor_security_key
|
||||||
|
|
Loading…
Reference in New Issue