Make header fields in profile preview card dynamic (#14454)

* Make header fields in profile preview card dynamic

* Update comment
This commit is contained in:
Michael Kohl 2021-08-11 09:34:30 +07:00 committed by GitHub
parent 946672ff4a
commit 7e0415c150
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 5 deletions

View file

@ -1,8 +1,6 @@
# TODO: @citizen428 - We shouldn't use education and work directly here, since
# we can't guarantee that these profile fields will exist on all Forems.
json.extract!(
@user.profile,
:summary, :location, :education, :work
:summary, :location
)
json.card_color(
@ -12,3 +10,9 @@ json.card_color(
json.email @user.email if @user.setting.display_email_on_profile
json.created_at utc_iso_timestamp(@user.created_at)
# Dynamically add the information for the header fields (maximum of 3 fields)
header_fields = @user.profile.decorate.ui_attributes_for(area: :header)
header_fields.each do |title, value|
json.set! title, value
end

View file

@ -12,7 +12,8 @@ FactoryBot.define do
employer_name: "DEV",
employer_url: "http://dev.to",
employment_title: "Software Engineer",
skills_languages: "Ruby"
skills_languages: "Ruby",
work: "Forem"
}
end
website_url { "http://example.com" }

View file

@ -1,7 +1,7 @@
require "rails_helper"
RSpec.describe "ProfilePreviewCards", type: :request do
let(:user) { create(:profile).user }
let(:user) { create(:profile, :with_DEV_info).user }
describe "GET /:id" do
context "when signed out" do