Commit 6b6350ca authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '332405-adding-a-pronouns-box-for-gitlab-profiles' into 'master'

Resolve "Allow users to specify pronouns"

See merge request gitlab-org/gitlab!63221
parents e2eb7c37 5c6be0aa
......@@ -127,6 +127,7 @@ class ProfilesController < Profiles::ApplicationController
:include_private_contributions,
:timezone,
:job_title,
:pronouns,
status: [:emoji, :message, :availability]
)
end
......
......@@ -312,6 +312,7 @@ class User < ApplicationRecord
delegate :other_role, :other_role=, to: :user_detail, allow_nil: true
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
accepts_nested_attributes_for :user_preference, update_only: true
accepts_nested_attributes_for :user_detail, update_only: true
......
......@@ -6,6 +6,7 @@ class UserDetail < ApplicationRecord
belongs_to :user
validates :pronouns, length: { maximum: 50 }
validates :job_title, length: { maximum: 200 }
validates :bio, length: { maximum: 255 }, allow_blank: true
......
......@@ -100,6 +100,7 @@
= render 'profiles/name', form: f, user: @user
= 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")
= 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")
......
......@@ -56,6 +56,9 @@
.user-info
.cover-title{ itemprop: 'name' }
= @user.name
- if @user.pronouns.present?
%span.gl-font-base.gl-text-gray-500.gl-vertical-align-middle
= "(#{@user.pronouns})"
- 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)")
......
# frozen_string_literal: true
class AddPronounsToUserDetails < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
def up
# rubocop:disable Migration/AddLimitToTextColumns
# limit is added in 20210607050531_add_text_limit_to_user_details_pronouns
with_lock_retries do
add_column :user_details, :pronouns, :text, null: true
end
# rubocop:enable Migration/AddLimitToTextColumns
end
def down
with_lock_retries do
remove_column :user_details, :pronouns
end
end
end
# frozen_string_literal: true
class AddTextLimitToUserDetailsPronouns < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
def up
add_text_limit :user_details, :pronouns, 50
end
def down
remove_text_limit :user_details, :pronouns
end
end
5b58dbdcba08f6e56802aa58ba0d23e5353c1818a8d4d653d53dabaac4c0234c
\ No newline at end of file
77f24cb4756dfeef16ba48a189d3bf9352534f858446522bc49495b9295374a8
\ No newline at end of file
......@@ -18551,8 +18551,10 @@ CREATE TABLE user_details (
webauthn_xid text,
other_role text,
provisioned_by_group_id bigint,
pronouns text,
CONSTRAINT check_245664af82 CHECK ((char_length(webauthn_xid) <= 100)),
CONSTRAINT check_b132136b01 CHECK ((char_length(other_role) <= 100))
CONSTRAINT check_b132136b01 CHECK ((char_length(other_role) <= 100)),
CONSTRAINT check_eeeaf8d4f0 CHECK ((char_length(pronouns) <= 50))
);
CREATE SEQUENCE user_details_user_id_seq
......@@ -107,6 +107,20 @@ To show private contributions:
1. In the **Main settings** section, select the **Include private contributions on my profile** checkbox.
1. Select **Update profile settings**.
## Add your gender pronouns
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/332405) in GitLab 14.0.
You can add your gender pronouns to your GitLab account to be displayed next to
your name in your profile.
To specify your pronouns:
1. In the top-right corner, select your avatar.
1. Select **Edit profile**.
1. In the **Pronouns** field, enter your pronouns.
1. Select **Update profile settings**.
## Set your current status
> - Introduced in GitLab 11.2.
......
......@@ -25244,6 +25244,9 @@ msgstr ""
msgid "Profiles|Enter your name, so people you know can recognize you"
msgstr ""
msgid "Profiles|Enter your pronouns to let people know how to refer to you"
msgstr ""
msgid "Profiles|Expired key is not valid."
msgstr ""
......
......@@ -100,6 +100,16 @@ RSpec.describe ProfilesController, :request_store do
expect(user.reload.job_title).to eq(title)
expect(response).to have_gitlab_http_status(:found)
end
it 'allows updating user specified pronouns', :aggregate_failures do
pronouns = 'they/them'
sign_in(user)
put :update, params: { user: { pronouns: pronouns } }
expect(user.reload.pronouns).to eq(pronouns)
expect(response).to have_gitlab_http_status(:found)
end
end
describe 'GET audit_log' do
......
......@@ -4,5 +4,6 @@ FactoryBot.define do
factory :user_detail do
user
job_title { 'VP of Sales' }
pronouns { nil }
end
end
......@@ -220,6 +220,14 @@ RSpec.describe 'User page' do
expect(page).to have_content("Working hard!")
end
it 'shows the pronouns of the user if there was one' do
user.user_detail.update_column(:pronouns, 'they/them')
subject
expect(page).to have_content("(they/them)")
end
context 'signup disabled' do
it 'shows the sign in link' do
stub_application_setting(signup_enabled: false)
......
......@@ -11,6 +11,11 @@ RSpec.describe UserDetail do
it { is_expected.to validate_length_of(:job_title).is_at_most(200) }
end
describe '#pronouns' do
it { is_expected.not_to validate_presence_of(:pronouns) }
it { is_expected.to validate_length_of(:pronouns).is_at_most(50) }
end
describe '#bio' do
it { is_expected.to validate_length_of(:bio).is_at_most(255) }
end
......
......@@ -74,6 +74,9 @@ RSpec.describe User do
it { is_expected.to delegate_method(:job_title).to(:user_detail).allow_nil }
it { is_expected.to delegate_method(:job_title=).to(:user_detail).with_arguments(:args).allow_nil }
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(: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 }
......@@ -136,6 +139,12 @@ RSpec.describe User do
expect(user.bio).to eq(user.user_detail.bio)
end
it 'delegates `pronouns` to `user_detail`' do
user = create(:user, pronouns: 'they/them')
expect(user.pronouns).to eq(user.user_detail.pronouns)
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