diff --git a/app/views/profile_preview_cards/show.json.jbuilder b/app/views/profile_preview_cards/show.json.jbuilder index 65ae4763f..1e6f07f5a 100644 --- a/app/views/profile_preview_cards/show.json.jbuilder +++ b/app/views/profile_preview_cards/show.json.jbuilder @@ -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 diff --git a/spec/factories/profiles.rb b/spec/factories/profiles.rb index 9367c7e7e..99353de56 100644 --- a/spec/factories/profiles.rb +++ b/spec/factories/profiles.rb @@ -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" } diff --git a/spec/requests/profile_preview_cards_spec.rb b/spec/requests/profile_preview_cards_spec.rb index 3958781fc..02c5cf5a8 100644 --- a/spec/requests/profile_preview_cards_spec.rb +++ b/spec/requests/profile_preview_cards_spec.rb @@ -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