Commit b17484c8 authored by Michael Kozono's avatar Michael Kozono

Merge branch '25742-add-pronunciation-to-gitlab-profile-page' into 'master'

Resolve "Add pronunciation to GitLab profile page"

See merge request gitlab-org/gitlab!67111
parents 6881e308 5e6b224b
......@@ -128,6 +128,7 @@ class ProfilesController < Profiles::ApplicationController
:timezone,
:job_title,
:pronouns,
:pronunciation,
status: [:emoji, :message, :availability]
)
end
......
......@@ -316,6 +316,7 @@ class User < ApplicationRecord
delegate :bio, :bio=, :bio_html, to: :user_detail, allow_nil: true
delegate :webauthn_xid, :webauthn_xid=, to: :user_detail, allow_nil: true
delegate :pronouns, :pronouns=, to: :user_detail, allow_nil: true
delegate :pronunciation, :pronunciation=, to: :user_detail, allow_nil: true
accepts_nested_attributes_for :user_preference, update_only: true
accepts_nested_attributes_for :user_detail, update_only: true
......
......@@ -7,6 +7,7 @@ class UserDetail < ApplicationRecord
belongs_to :user
validates :pronouns, length: { maximum: 50 }
validates :pronunciation, length: { maximum: 255 }
validates :job_title, length: { maximum: 200 }
validates :bio, length: { maximum: 255 }, allow_blank: true
......
......@@ -98,6 +98,7 @@
= f.text_field :id, class: 'gl-form-input', readonly: true, label: s_('Profiles|User ID'), wrapper: { class: 'col-md-3' }
= f.text_field :pronouns, class: 'input-md gl-form-input', help: s_("Profiles|Enter your pronouns to let people know how to refer to you")
= f.text_field :pronunciation, class: 'input-md gl-form-input', help: s_("Profiles|Enter how your name is pronounced to help people address you correctly")
= render_if_exists 'profiles/email_settings', form: f
= f.text_field :skype, class: 'input-md gl-form-input', placeholder: s_("Profiles|username")
= f.text_field :linkedin, class: 'input-md gl-form-input', help: s_("Profiles|Your LinkedIn profile name from linkedin.com/in/profilename")
......
......@@ -62,6 +62,10 @@
- if @user&.status && user_status_set_to_busy?(@user.status)
%span.gl-font-base.gl-text-gray-500.gl-vertical-align-middle= s_("UserProfile|(Busy)")
- if @user.pronunciation.present?
.gl-align-items-center
%p.gl-mb-4.gl-text-gray-500= s_("UserProfile|Pronounced as: %{pronunciation}") % { pronunciation: @user.pronunciation }
- if show_status_emoji?(@user.status)
.cover-status.gl-display-inline-flex.gl-align-items-center
= emoji_icon(@user.status.emoji, class: 'gl-mr-2')
......
# frozen_string_literal: true
class AddPronunciationToUserDetails < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
def up
# rubocop:disable Migration/AddLimitToTextColumns
# limit is added in 20210729061556_add_text_limit_to_user_details_pronunciation.rb
with_lock_retries do
add_column :user_details, :pronunciation, :text, null: true
end
# rubocop:enable Migration/AddLimitToTextColumns
end
def down
with_lock_retries do
remove_column :user_details, :pronunciation
end
end
end
# frozen_string_literal: true
class AddTextLimitToUserDetailsPronunciation < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
def up
add_text_limit :user_details, :pronunciation, 255
end
def down
remove_text_limit :user_details, :pronunciation
end
end
5c71f4176ecf8f422e948c2c2ecb1e6662494def11e06d7d0071d73f379770f0
\ No newline at end of file
75be4e92b482c9003485658c42ba1e94a2d5c6a5a0653c8a27c5983fafd1d6a7
\ No newline at end of file
......@@ -18842,9 +18842,11 @@ CREATE TABLE user_details (
other_role text,
provisioned_by_group_id bigint,
pronouns text,
pronunciation text,
CONSTRAINT check_245664af82 CHECK ((char_length(webauthn_xid) <= 100)),
CONSTRAINT check_b132136b01 CHECK ((char_length(other_role) <= 100)),
CONSTRAINT check_eeeaf8d4f0 CHECK ((char_length(pronouns) <= 50))
CONSTRAINT check_eeeaf8d4f0 CHECK ((char_length(pronouns) <= 50)),
CONSTRAINT check_f932ed37db CHECK ((char_length(pronunciation) <= 255))
);
CREATE SEQUENCE user_details_user_id_seq
......@@ -129,6 +129,19 @@ To specify your pronouns:
1. In the **Pronouns** field, enter your pronouns.
1. Select **Update profile settings**.
## Add your name pronunciation
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/25742) in GitLab 14.2.
You can add your name pronunciation to your GitLab account. This will be displayed in your profile, below your name.
To add your name pronunciation:
1. In the top-right corner, select your avatar.
1. Select **Edit profile**.
1. In the **Pronunciation** field, enter how your name is pronounced. For example, Sophia: so-FEE-uh
1. Select **Update profile settings**.
## Set your current status
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56649) in GitLab 13.10, users can schedule the clearing of their status.
......
......@@ -25290,6 +25290,9 @@ msgstr ""
msgid "Profiles|Edit Profile"
msgstr ""
msgid "Profiles|Enter how your name is pronounced to help people address you correctly"
msgstr ""
msgid "Profiles|Enter your name, so people you know can recognize you"
msgstr ""
......@@ -36157,6 +36160,9 @@ msgstr ""
msgid "UserProfile|Personal projects"
msgstr ""
msgid "UserProfile|Pronounced as: %{pronunciation}"
msgstr ""
msgid "UserProfile|Report abuse"
msgstr ""
......
......@@ -110,6 +110,17 @@ RSpec.describe ProfilesController, :request_store do
expect(user.reload.pronouns).to eq(pronouns)
expect(response).to have_gitlab_http_status(:found)
end
it 'allows updating user specified pronunciation', :aggregate_failures do
user = create(:user, name: 'Example')
pronunciation = 'uhg-zaam-pl'
sign_in(user)
put :update, params: { user: { pronunciation: pronunciation } }
expect(user.reload.pronunciation).to eq(pronunciation)
expect(response).to have_gitlab_http_status(:found)
end
end
describe 'GET audit_log' do
......
......@@ -5,5 +5,6 @@ FactoryBot.define do
user
job_title { 'VP of Sales' }
pronouns { nil }
pronunciation { nil }
end
end
......@@ -278,6 +278,14 @@ RSpec.describe 'User page' do
expect(page).to have_content("(they/them)")
end
it 'shows the pronunctiation of the user if there was one' do
user.user_detail.update_column(:pronunciation, 'pruh-nuhn-see-ay-shn')
subject
expect(page).to have_content("Pronounced as: pruh-nuhn-see-ay-shn")
end
context 'signup disabled' do
it 'shows the sign in link' do
stub_application_setting(signup_enabled: false)
......
......@@ -16,6 +16,11 @@ RSpec.describe UserDetail do
it { is_expected.to validate_length_of(:pronouns).is_at_most(50) }
end
describe '#pronunciation' do
it { is_expected.not_to validate_presence_of(:pronunciation) }
it { is_expected.to validate_length_of(:pronunciation).is_at_most(255) }
end
describe '#bio' do
it { is_expected.to validate_length_of(:bio).is_at_most(255) }
end
......
......@@ -77,6 +77,9 @@ RSpec.describe User do
it { is_expected.to delegate_method(:pronouns).to(:user_detail).allow_nil }
it { is_expected.to delegate_method(:pronouns=).to(:user_detail).with_arguments(:args).allow_nil }
it { is_expected.to delegate_method(:pronunciation).to(:user_detail).allow_nil }
it { is_expected.to delegate_method(:pronunciation=).to(:user_detail).with_arguments(:args).allow_nil }
it { is_expected.to delegate_method(:bio).to(:user_detail).allow_nil }
it { is_expected.to delegate_method(:bio=).to(:user_detail).with_arguments(:args).allow_nil }
it { is_expected.to delegate_method(:bio_html).to(:user_detail).allow_nil }
......@@ -146,6 +149,12 @@ RSpec.describe User do
expect(user.pronouns).to eq(user.user_detail.pronouns)
end
it 'delegates `pronunciation` to `user_detail`' do
user = create(:user, name: 'Example', pronunciation: 'uhg-zaam-pl')
expect(user.pronunciation).to eq(user.user_detail.pronunciation)
end
it 'creates `user_detail` when `bio` is first updated' do
user = create(:user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment