mirror of
https://github.com/discourse/discourse.git
synced 2024-12-05 12:03:39 +08:00
26db3be4dd
Previously, we had an instant redirect back to the homepage, and clicking avatars would do nothing. This made things feel 'broken' for anon when 'hide_user_profiles_from_public' was enabled. This commit does a few things to resolve this: 1. Improve our 'exception' system for routes so that developers can deliberately trigger it without an ajax error 2. Improve 'exception' system so that the browser URL bar is updated correctly, and the 'back' button works as expected 3. Replace the redirect-to-home with an 'access denied' error page, with specific copy for 'You must log in to view user profiles' 4. Update user-card logic to display this new page instead of doing nothing on click
26 lines
1.0 KiB
Ruby
26 lines
1.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
describe "hide_user_profiles_from_public", type: :system do
|
|
let(:user) { Fabricate(:user) }
|
|
before { SiteSetting.hide_user_profiles_from_public = true }
|
|
|
|
it "displays an error when navigating straight to a profile" do
|
|
visit("/u/#{user.username}")
|
|
expect(page).to have_css(".error-page .reason", text: I18n.t("js.errors.reasons.forbidden"))
|
|
expect(page).to have_css(".error-page .desc", text: I18n.t("js.user.login_to_view_profile"))
|
|
end
|
|
|
|
it "displays an error when navigating from an internal link" do
|
|
Fabricate(:post, user: user)
|
|
visit("/latest")
|
|
find("[data-user-card='#{user.username}']").click
|
|
|
|
expect(page).to have_css(".error-page .reason", text: I18n.t("js.errors.reasons.forbidden"))
|
|
expect(page).to have_css(".error-page .desc", text: I18n.t("js.user.login_to_view_profile"))
|
|
expect(page).to have_current_path("/u/#{user.username}")
|
|
|
|
find(".error-page .buttons .btn-primary", text: "Back").click
|
|
expect(page).to have_current_path("/latest")
|
|
end
|
|
end
|