FEATURE: Site setting to display user avatars in user menu (#24514)

This commit is contained in:
Mark VanLandingham
2023-12-07 11:30:44 -06:00
committed by GitHub
parent e4c373194d
commit ee05f57e2d
26 changed files with 314 additions and 15 deletions

View File

@ -32,7 +32,10 @@ RSpec.describe NotificationsController do
context "when logged in" do
context "as normal user" do
fab!(:user) { sign_in(Fabricate(:user)) }
fab!(:notification) { Fabricate(:notification, user: user) }
fab!(:acting_user) { Fabricate(:user) }
fab!(:notification) do
Fabricate(:notification, user: user, data: { username: acting_user.username }.to_json)
end
describe "#index" do
it "should succeed for recent" do
@ -424,6 +427,20 @@ RSpec.describe NotificationsController do
end
end
end
context "with `show_user_menu_avatars` setting enabled" do
before { SiteSetting.show_user_menu_avatars = true }
it "serializes acting_user_avatar_template into notifications" do
get "/notifications.json"
notifications = response.parsed_body["notifications"]
expect(notifications).not_to be_empty
notifications.each do |notification|
expect(notification["acting_user_avatar_template"]).to be_present
end
end
end
end
it "should succeed" do

View File

@ -7051,6 +7051,18 @@ RSpec.describe UsersController do
expect(notifications.size).to eq(1)
expect(notifications.first["data"]["bookmark_id"]).to eq(bookmark_with_reminder.id)
end
context "with `show_user_menu_avatars` setting enabled" do
before { SiteSetting.show_user_menu_avatars = true }
it "serializes acting_user_avatar into notifications" do
get "/u/#{user.username}/user-menu-bookmarks"
expect(response.status).to eq(200)
first_notification = response.parsed_body["notifications"].first
expect(first_notification["acting_user_avatar_template"]).to be_present
end
end
end
end