mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: show user avatar on User summary page (#6872)
This commit is contained in:
@@ -18,8 +18,12 @@ class UserSummarySerializer < ApplicationSerializer
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class UserWithCountSerializer < BasicUserSerializer
|
class UserWithCountSerializer < ApplicationSerializer
|
||||||
attributes :count, :name
|
attributes :id, :username, :name, :count, :avatar_template
|
||||||
|
|
||||||
|
def avatar_template
|
||||||
|
User.avatar_template(object[:username], object[:uploaded_avatar_id])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class CategoryWithCountsSerializer < ApplicationSerializer
|
class CategoryWithCountsSerializer < ApplicationSerializer
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ describe BasicUserSerializer do
|
|||||||
expect(json[:name]).to be_blank
|
expect(json[:name]).to be_blank
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns the avatar_template" do
|
||||||
|
expect(json[:avatar_template]).to be_present
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
24
spec/serializers/user_summary_serializer_spec.rb
Normal file
24
spec/serializers/user_summary_serializer_spec.rb
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
describe UserSummarySerializer do
|
||||||
|
it "returns expected data" do
|
||||||
|
UserActionCreator.enable
|
||||||
|
user = Fabricate(:user)
|
||||||
|
liked_post = create_post
|
||||||
|
PostAction.act(user, liked_post, PostActionType.types[:like])
|
||||||
|
|
||||||
|
guardian = Guardian.new(user)
|
||||||
|
summary = UserSummary.new(user, guardian)
|
||||||
|
serializer = UserSummarySerializer.new(summary, scope: guardian, root: false)
|
||||||
|
json = serializer.as_json
|
||||||
|
|
||||||
|
expect(json[:likes_given]).to be_present
|
||||||
|
expect(json[:likes_received]).to be_present
|
||||||
|
expect(json[:posts_read_count]).to be_present
|
||||||
|
expect(json[:topic_count]).to be_present
|
||||||
|
expect(json[:time_read]).to be_present
|
||||||
|
expect(json[:most_liked_users][0][:count]).to be_present
|
||||||
|
expect(json[:most_liked_users][0][:username]).to be_present
|
||||||
|
expect(json[:most_liked_users][0][:avatar_template]).to be_present
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user