FIX: allows an admin to access users preferences (#19559)

This commit is contained in:
Joffrey JAFFEUX 2022-12-21 17:52:53 +01:00 committed by GitHub
parent 335893ae91
commit b4b14c4d95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 2 deletions

View File

@ -1,4 +1,4 @@
{{#if this.model.can_chat}}
{{#if (or this.model.can_chat this.model.admin)}}
<LinkTo @route="preferences.chat">
{{i18n "chat.title_capitalized"}}
</LinkTo>

View File

@ -8,7 +8,7 @@ export default class PreferencesChatRoute extends RestrictedUserRoute {
showFooter = true;
setupController(controller, user) {
if (!user?.can_chat) {
if (!user?.can_chat && !user.admin) {
return this.transitionTo(`discovery.${defaultHomepage()}`);
}
controller.set("model", user);

View File

@ -31,4 +31,18 @@ RSpec.describe "User chat preferences", type: :system, js: true do
expect(page).to have_css("#user_chat_sounds .select-kit-header[data-value='bell']")
end
context "as an admin on another user's preferences" do
fab!(:current_user) { Fabricate(:admin) }
fab!(:user_1) { Fabricate(:admin) }
before { sign_in(current_user) }
it "allows to change settings" do
visit("/u/#{user_1.username}/preferences")
find(".preferences-chat-link").click
expect(page).to have_current_path("/u/#{user_1.username}/preferences/chat")
end
end
end