FIX: allows an admin to access users preferences (#19559)
This commit is contained in:
parent
335893ae91
commit
b4b14c4d95
|
@ -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>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue