From 9e18b19d6a2f9ca6f340638d394ae2ccf569cfbe Mon Sep 17 00:00:00 2001 From: cmrd Senya Date: Sun, 28 Apr 2019 20:12:49 +0300 Subject: [PATCH] API: render name instead of first_name and last_name in user data --- app/presenters/profile_presenter.rb | 3 +-- spec/integration/api/users_controller_spec.rb | 6 ++---- spec/presenters/person_presenter_spec.rb | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/presenters/profile_presenter.rb b/app/presenters/profile_presenter.rb index 650400daf..41d652c20 100644 --- a/app/presenters/profile_presenter.rb +++ b/app/presenters/profile_presenter.rb @@ -55,8 +55,7 @@ class ProfilePresenter < BasePresenter def base_api_json { - first_name: first_name, - last_name: last_name, + name: [first_name, last_name].join(" ").presence, diaspora_id: diaspora_handle, avatar: AvatarPresenter.new(@presentable).base_hash, tags: tags.pluck(:name) diff --git a/spec/integration/api/users_controller_spec.rb b/spec/integration/api/users_controller_spec.rb index 23a2ae32d..67681f8f5 100644 --- a/spec/integration/api/users_controller_spec.rb +++ b/spec/integration/api/users_controller_spec.rb @@ -229,8 +229,7 @@ describe Api::V1::UsersController do expect(user["birthday"]).to eq(new_birthday.iso8601) expect(user["location"]).to eq(new_location) expect(user["gender"]).to eq(new_gender) - expect(user["first_name"]).to eq(new_first_name) - expect(user["last_name"]).to eq(new_last_name) + expect(user["name"]).to eq("#{new_first_name} #{new_last_name}") expect(user["searchable"]).to eq(new_searchable) expect(user["show_profile_info"]).to eq(new_show_profile_info) expect(user["nsfw"]).to eq(new_nsfw) @@ -547,8 +546,7 @@ describe Api::V1::UsersController do def confirm_common_profile_elements(json) expect(json).to have_key("guid") expect(json).to have_key("diaspora_id") - expect(json).to have_key("first_name") - expect(json).to have_key("last_name") + expect(json).to have_key("name") expect(json).to have_key("avatar") expect(json).to have_key("tags") end diff --git a/spec/presenters/person_presenter_spec.rb b/spec/presenters/person_presenter_spec.rb index 215c18ca6..5a8796661 100644 --- a/spec/presenters/person_presenter_spec.rb +++ b/spec/presenters/person_presenter_spec.rb @@ -214,8 +214,7 @@ describe PersonPresenter do def confirm_common_profile_elements(profile_hash) expect(profile_hash).to have_key(:guid) expect(profile_hash).to have_key(:diaspora_id) - expect(profile_hash).to have_key(:first_name) - expect(profile_hash).to have_key(:last_name) + expect(profile_hash).to have_key(:name) expect(profile_hash).to have_key(:avatar) expect(profile_hash).to have_key(:tags) end