Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-06-07 21:10:00 +00:00
parent 21e144f387
commit c98df6ecba
25 changed files with 198 additions and 97 deletions

View file

@ -127,6 +127,7 @@ class ProfilesController < Profiles::ApplicationController
:include_private_contributions, :include_private_contributions,
:timezone, :timezone,
:job_title, :job_title,
:pronouns,
status: [:emoji, :message, :availability] status: [:emoji, :message, :availability]
) )
end end

View file

@ -312,6 +312,7 @@ class User < ApplicationRecord
delegate :other_role, :other_role=, to: :user_detail, allow_nil: true delegate :other_role, :other_role=, to: :user_detail, allow_nil: true
delegate :bio, :bio=, :bio_html, 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 :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_preference, update_only: true
accepts_nested_attributes_for :user_detail, update_only: true accepts_nested_attributes_for :user_detail, update_only: true

View file

@ -6,6 +6,7 @@ class UserDetail < ApplicationRecord
belongs_to :user belongs_to :user
validates :pronouns, length: { maximum: 50 }
validates :job_title, length: { maximum: 200 } validates :job_title, length: { maximum: 200 }
validates :bio, length: { maximum: 255 }, allow_blank: true validates :bio, length: { maximum: 255 }, allow_blank: true

View file

@ -100,6 +100,7 @@
= render 'profiles/name', form: f, user: @user = 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 :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 = 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 :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") = f.text_field :linkedin, class: 'input-md gl-form-input', help: s_("Profiles|Your LinkedIn profile name from linkedin.com/in/profilename")

View file

@ -56,6 +56,9 @@
.user-info .user-info
.cover-title{ itemprop: 'name' } .cover-title{ itemprop: 'name' }
= @user.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) - 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)") %span.gl-font-base.gl-text-gray-500.gl-vertical-align-middle= s_("UserProfile|(Busy)")

View file

@ -5,4 +5,4 @@ rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/331006
milestone: '14.0' milestone: '14.0'
type: development type: development
group: group::release group: group::release
default_enabled: false default_enabled: true

View file

@ -0,0 +1,20 @@
# 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

View file

@ -0,0 +1,15 @@
# 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

View file

@ -0,0 +1 @@
5b58dbdcba08f6e56802aa58ba0d23e5353c1818a8d4d653d53dabaac4c0234c

View file

@ -0,0 +1 @@
77f24cb4756dfeef16ba48a189d3bf9352534f858446522bc49495b9295374a8

View file

@ -18551,8 +18551,10 @@ CREATE TABLE user_details (
webauthn_xid text, webauthn_xid text,
other_role text, other_role text,
provisioned_by_group_id bigint, provisioned_by_group_id bigint,
pronouns text,
CONSTRAINT check_245664af82 CHECK ((char_length(webauthn_xid) <= 100)), 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 CREATE SEQUENCE user_details_user_id_seq

View file

@ -9,7 +9,7 @@ type: howto
A branch is an independent line of development in a [project](../user/project/index.md). A branch is an independent line of development in a [project](../user/project/index.md).
When you create a new branch (in your [terminal](start-using-git.md#create-and-work-in-a-branch) or with When you create a branch (in your [terminal](start-using-git.md#create-a-branch) or with
[the web interface](../user/project/repository/web_editor.md#create-a-new-branch)), [the web interface](../user/project/repository/web_editor.md#create-a-new-branch)),
you are creating a snapshot of a certain branch, usually the main branch, you are creating a snapshot of a certain branch, usually the main branch,
at its current state. From there, you can start to make your own changes without at its current state. From there, you can start to make your own changes without

View file

@ -311,35 +311,35 @@ git remote -v
The `-v` flag stands for verbose. The `-v` flag stands for verbose.
## Branching ## Branches
If you want to add code to a project but you're not sure if it works properly, or you're A **branch** is a copy of the files in the repository at the time you create the branch.
collaborating on the project with others, and don't want your work to get mixed up, it's a good idea You can work in your branch without affecting other branches. When
to work on a different **branch**. you're ready to add your changes to the main codebase, you can merge your branch into
the default branch, for example, `main`.
When you create a branch in a Git repository, you make a copy of its files at the time of branching. You're free Use branches when you:
to do whatever you want with the code in your branch without impacting the main branch or other branches. And when
you're ready to add your changes to the main codebase, you can merge your branch into the default branch - Want to add code to a project but you're not sure if it works properly.
used in your project (such as `main`). - Are collaborating on the project with others, and don't want your work to get mixed up.
A new branch is often called **feature branch** to differentiate from the A new branch is often called **feature branch** to differentiate from the
[default branch](../user/project/repository/branches/default.md). [default branch](../user/project/repository/branches/default.md).
### Create and work in a branch ### Create a branch
To create a new feature branch to work with: To create a feature branch:
```shell ```shell
git checkout -b <name-of-branch> git checkout -b <name-of-branch>
``` ```
Note that Git does **not** accept empty spaces and special characters in branch Branch names cannot contain empty spaces and special characters. Use only lowercase letters, numbers,
names, so use only lowercase letters, numbers, hyphens (`-`), and underscores hyphens (`-`), and underscores (`_`).
(`_`). Do not use capital letters, as it may cause duplications.
### Switch to a branch ### Switch to a branch
You are always in a branch when working with Git. All work in Git is done in a branch.
You can switch between branches to see the state of the files and work in that branch. You can switch between branches to see the state of the files and work in that branch.
To switch to an existing branch: To switch to an existing branch:
@ -356,8 +356,8 @@ git checkout main
### View differences ### View differences
To view the differences between your local, unstaged changes and the latest version To view the differences between your local unstaged changes and the latest version
that you cloned or pulled, type: that you cloned or pulled:
```shell ```shell
git diff git diff
@ -365,9 +365,8 @@ git diff
### View the files that have changes ### View the files that have changes
It's important to be aware of what's happening and the status of your changes. When When you add, change, or delete files or folders, Git knows about the changes.
you add, change, or delete files or folders, Git knows about the changes. To check which files have been changed:
To check which files have been changed use:
```shell ```shell
git status git status
@ -375,31 +374,35 @@ git status
### Add and commit local changes ### Add and commit local changes
Locally changed files are shown in red when you type `git status`. These changes may When you type `git status`, locally changed files are shown in red. These changes may
be new, modified, or deleted files/folders. Use `git add` to **stage** (prepare) be new, modified, or deleted files or folders.
a local file/folder for committing. Then use `git commit` to commit (save) the staged files.
1. To stage a file for commit:
```shell ```shell
git add <file-name OR folder-name> git add <file-name OR folder-name>
git commit -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"
``` ```
To add more than one file or folder, repeat `git add` for each file or folder you want included 1. Repeat step 1 for each file or folder you want to add.
in the commit command before using `git commit`. Files that have been added show green when using `git status`. Or, to stage all files in the current directory and subdirectory, type `git add .`.
#### Add all changes to commit 1. Confirm that the files have been added to staging:
To add and commit (save) all local changes quickly: ```shell
git status
```
The files should be displayed in green text.
1. To commit the staged files:
```shell ```shell
git add .
git commit -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT" git commit -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"
``` ```
NOTE: #### Stage and commit all changes
The `.` character means _all file changes in the current directory and all subdirectories_.
To run `git add .` as part of the commit command, use the `-a` option: As a shortcut, you can add all local changes to staging and commit them with one command:
```shell ```shell
git commit -a -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT" git commit -a -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"
@ -407,7 +410,7 @@ git commit -a -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"
### Send changes to GitLab.com ### Send changes to GitLab.com
To push all local commits (saved changes) to the remote repository: To push all local changes to the remote repository:
```shell ```shell
git push <remote> <name-of-branch> git push <remote> <name-of-branch>
@ -419,27 +422,23 @@ For example, to push your local commits to the `main` branch of the `origin` rem
git push origin main git push origin main
``` ```
On certain occasions, Git disallows pushes to your repository, and then Sometimes Git does not allow you to push to a repository. Instead,
you must [force an update](../topics/git/git_rebase.md#force-push). you must [force an update](../topics/git/git_rebase.md#force-push).
NOTE:
To create a merge request from a fork to an upstream repository, see the
[forking workflow](../user/project/repository/forking_workflow.md).
### Delete all changes in the branch ### Delete all changes in the branch
To discard all changes of tracked files, type: To discard all changes to tracked files:
```shell ```shell
git checkout . git checkout .
``` ```
Note that this removes *changes* to files, not the files themselves. This action removes *changes* to files, not the files themselves.
Any untracked (new) files are untouched. Untracked (new) files do not change.
### Unstage all changes that have been added to the staging area ### Unstage all changes that have been added to the staging area
To unstage (remove) all files that have not been committed from being committed, use: To unstage (remove) all files that have not been committed:
```shell ```shell
git reset git reset
@ -447,13 +446,13 @@ git reset
### Undo most recent commit ### Undo most recent commit
To undo the most recent commit, type: To undo the most recent commit:
```shell ```shell
git reset HEAD~1 git reset HEAD~1
``` ```
This leaves the changed files and folders unstaged in your local repository. This action leaves the changed files and folders unstaged in your local repository.
WARNING: WARNING:
A Git commit should not be reversed if you already pushed it A Git commit should not be reversed if you already pushed it
@ -465,16 +464,18 @@ You can learn more about the different ways Git can undo changes in the
### Merge a branch with default branch ### Merge a branch with default branch
When you are ready to make all the changes in a branch a permanent addition to When you are ready to add your changes to
the default branch, you `merge` the two together, changing `<feature-branch>` and the default branch, you `merge` the two together:
`<default-branch>` to your values:
```shell ```shell
git checkout <feature-branch> git checkout <feature-branch>
git merge <default-branch> git merge <default-branch>
``` ```
In GitLab, you typically merge using a [merge request](../user/project/merge_requests/) instead of performing the command locally. In GitLab, you typically use a [merge request](../user/project/merge_requests/) to merge your changes, instead of using the command line.
To create a merge request from a fork to an upstream repository, see the
[forking workflow](../user/project/repository/forking_workflow.md).
## Advanced use of Git through the command line ## Advanced use of Git through the command line
@ -482,14 +483,12 @@ For an introduction of more advanced Git techniques, see [Git rebase, force-push
## Synchronize changes in a forked repository with the upstream ## Synchronize changes in a forked repository with the upstream
[Forking a repository](../user/project/repository/forking_workflow.md) lets you create To create a copy of a repository in your namespace, you [fork it](../user/project/repository/forking_workflow.md).
a copy of a repository in your namespace. Changes made to your copy of the repository Changes made to your copy of the repository are not automatically synchronized with the original.
are not synchronized automatically with the original. To keep the project in sync with the original project, you need to `pull` from the original repository.
Your local fork (copy) only contains changes you have made, so to keep the project
in sync with the original project, you need to `pull` from the original repository.
You must [create a link to the remote repository](#add-a-remote-repository) to pull In this case, you [create a link to the remote repository](#add-a-remote-repository).
changes from the original repository. It is common to call this remote the `upstream`. This remote is commonly called the `upstream`.
You can now use the `upstream` as a [`<remote>` to `pull` new updates](#download-the-latest-changes-in-the-project) You can now use the `upstream` as a [`<remote>` to `pull` new updates](#download-the-latest-changes-in-the-project)
from the original repository, and use the `origin` from the original repository, and use the `origin`

View file

@ -32,7 +32,7 @@ consider pulling it instead (`git pull origin master`). It has a similar
effect without compromising the work of your contributors. effect without compromising the work of your contributors.
It's safer to back up your branch before rebasing to make sure you don't lose It's safer to back up your branch before rebasing to make sure you don't lose
any changes. For example, consider a [feature branch](../../gitlab-basics/start-using-git.md#branching) any changes. For example, consider a [feature branch](../../gitlab-basics/start-using-git.md#branches)
called `my-feature-branch`: called `my-feature-branch`:
1. Open your feature branch in the terminal: 1. Open your feature branch in the terminal:

View file

@ -293,9 +293,9 @@ This output shows the repository history, including:
To undo changes in the remote repository, you can create a new commit with the changes you To undo changes in the remote repository, you can create a new commit with the changes you
want to undo. You should follow this process, which preserves the history and want to undo. You should follow this process, which preserves the history and
provides a clear timeline and development structure. However, you only provides a clear timeline and development structure. However, you
need to follow this procedure if your work was merged into a branch that only need this procedure if your work was merged into a branch that
other developers are using as the base for their work (for example, `main`). other developers use as the base for their work.
![Use revert to keep branch flowing](img/revert.png) ![Use revert to keep branch flowing](img/revert.png)
@ -310,7 +310,7 @@ git revert B
You can undo remote changes and change history. You can undo remote changes and change history.
Even with an updated history, old commits can still be Even with an updated history, old commits can still be
accessed by commit SHA, at least until all the automated cleanup accessed by commit SHA. This is the case at least until all the automated cleanup
of detached commits is performed, or a cleanup is run manually. Even the cleanup might not remove old commits if there are still refs pointing to them. of detached commits is performed, or a cleanup is run manually. Even the cleanup might not remove old commits if there are still refs pointing to them.
![Modifying history causes problems on remote branch](img/rebase_reset.png) ![Modifying history causes problems on remote branch](img/rebase_reset.png)
@ -323,21 +323,21 @@ or a branch that might be used by other developers.
When you contribute to large open source repositories, like [GitLab](https://gitlab.com/gitlab-org/gitlab), When you contribute to large open source repositories, like [GitLab](https://gitlab.com/gitlab-org/gitlab),
you can squash your commits into a single one. you can squash your commits into a single one.
A feature branch of a merge request is a public branch and might be used by To squash commits on a feature branch to a single commit on a target branch
other developers, but project process and rules might allow or require at merge, use `git merge --squash`.
you to use `git rebase` (command that changes history) to reduce number of
displayed commits on target branch after reviews are done (for example
GitLab). There is a `git merge --squash` command which does exactly that
(squashes commits on feature-branch to a single commit on target branch
at merge).
NOTE: NOTE:
Never modify the commit history of your [default branch](../../../user/project/repository/branches/default.md) or shared branch. Never modify the commit history of your [default branch](../../../user/project/repository/branches/default.md) or shared branch.
### How to change history ### How to change history
You can modify history by using `git rebase -i`. This command allows modification, squashing, deletion A feature branch of a merge request is a public branch and might be used by
of commits. other developers. However, the project rules might require
you to use `git rebase` to reduce the number of
displayed commits on target branch after reviews are done.
You can modify history by using `git rebase -i`. Use this command to modify, squash,
and delete commits.
```shell ```shell
# #
@ -360,41 +360,40 @@ of commits.
``` ```
NOTE: NOTE:
If you decide to abort, do not close your editor, because the history If you decide to stop a rebase, do not close your editor.
will change. Instead, remove all uncommented lines and save. Instead, remove all uncommented lines and save.
Use `git rebase` carefully on Use `git rebase` carefully on shared and remote branches.
shared and remote branches, but rest assured: nothing is broken until Experiment locally before you push to the remote repository.
you push back to the remote repository (so you can freely explore the
different outcomes locally).
```shell ```shell
# Modify history from commit-id to HEAD (current commit) # Modify history from commit-id to HEAD (current commit)
git rebase -i commit-id git rebase -i commit-id
``` ```
### Deleting sensitive information from commits ### Delete sensitive information from commits
Git also enables you to delete sensitive information from your past commits and You can use Git to delete sensitive information from your past commits. However,
it does modify history in the progress. That is why we have included it in this history is modified in the process.
section and not as a standalone topic. To do so, you should run the
`git filter-branch`, which enables you to rewrite history with To rewrite history with
[certain filters](https://git-scm.com/docs/git-filter-branch#_options). [certain filters](https://git-scm.com/docs/git-filter-branch#_options),
This command uses rebase to modify history and if you want to remove certain run `git filter-branch`.
file from history altogether use:
To remove a file from the history altogether use:
```shell ```shell
git filter-branch --tree-filter 'rm filename' HEAD git filter-branch --tree-filter 'rm filename' HEAD
``` ```
Because `git filter-branch` command might be slow on big repositories, there are The `git filter-branch` command might be slow on large repositories.
tools that can use some of Git specifics to enable faster execution of common Tools are available to execute Git commands more quickly.
tasks (which is exactly what removing sensitive information file is about).
An alternative is the open source community-maintained tool [BFG](https://rtyley.github.io/bfg-repo-cleaner/). An alternative is the open source community-maintained tool [BFG](https://rtyley.github.io/bfg-repo-cleaner/).
Keep in mind that these tools are faster because they do not provide the same These tools are faster because they do not provide the same
feature set as `git filter-branch` does, but focus on specific use cases. feature set as `git filter-branch` does, but focus on specific use cases.
Refer [Reduce repository size](../../../user/project/repository/reducing_the_repo_size_using_git.md) page to know more about purging files from repository history & GitLab storage. Refer to [Reduce repository size](../../../user/project/repository/reducing_the_repo_size_using_git.md) to
learn more about purging files from repository history and GitLab storage.
<!-- ## Troubleshooting <!-- ## Troubleshooting

View file

@ -107,6 +107,20 @@ To show private contributions:
1. In the **Main settings** section, select the **Include private contributions on my profile** checkbox. 1. In the **Main settings** section, select the **Include private contributions on my profile** checkbox.
1. Select **Update profile settings**. 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 ## Set your current status
> - Introduced in GitLab 11.2. > - Introduced in GitLab 11.2.

View file

@ -112,6 +112,10 @@ contact the SubGit team directly at [support@subgit.com](mailto:support@subgit.c
## Cut over migration with svn2git ## Cut over migration with svn2git
NOTE:
Any issues with svn2git should be directed to the [relevant project and maintainer](https://github.com/nirvdrum/svn2git).
Check for existing issues and history for update frequency.
If you are currently using an SVN repository, you can migrate the repository If you are currently using an SVN repository, you can migrate the repository
to Git and GitLab. We recommend a hard cut over - run the migration command once to Git and GitLab. We recommend a hard cut over - run the migration command once
and then have all developers start using the new GitLab repository immediately. and then have all developers start using the new GitLab repository immediately.

View file

@ -33,7 +33,7 @@ For more information on managing branches using the GitLab UI, see:
- [Branch filter search box](#branch-filter-search-box) - [Branch filter search box](#branch-filter-search-box)
You can also manage branches using the You can also manage branches using the
[command line](../../../../gitlab-basics/start-using-git.md#create-and-work-in-a-branch). [command line](../../../../gitlab-basics/start-using-git.md#create-a-branch).
<i class="fa fa-youtube-play youtube" aria-hidden="true"></i>Watch the video [GitLab Flow](https://www.youtube.com/watch?v=InKNIvky2KE). <i class="fa fa-youtube-play youtube" aria-hidden="true"></i>Watch the video [GitLab Flow](https://www.youtube.com/watch?v=InKNIvky2KE).

View file

@ -1,5 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
# This patch will be included in the next Rails release: https://github.com/rails/rails/pull/42368
raise 'This patch can be removed' if Rails::VERSION::MAJOR > 6
# rubocop:disable Gitlab/ModuleWithInstanceVariables # rubocop:disable Gitlab/ModuleWithInstanceVariables
module Gitlab module Gitlab
module Database module Database

View file

@ -25244,6 +25244,9 @@ msgstr ""
msgid "Profiles|Enter your name, so people you know can recognize you" msgid "Profiles|Enter your name, so people you know can recognize you"
msgstr "" msgstr ""
msgid "Profiles|Enter your pronouns to let people know how to refer to you"
msgstr ""
msgid "Profiles|Expired key is not valid." msgid "Profiles|Expired key is not valid."
msgstr "" msgstr ""

View file

@ -100,6 +100,16 @@ RSpec.describe ProfilesController, :request_store do
expect(user.reload.job_title).to eq(title) expect(user.reload.job_title).to eq(title)
expect(response).to have_gitlab_http_status(:found) expect(response).to have_gitlab_http_status(:found)
end 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 end
describe 'GET audit_log' do describe 'GET audit_log' do

View file

@ -4,5 +4,6 @@ FactoryBot.define do
factory :user_detail do factory :user_detail do
user user
job_title { 'VP of Sales' } job_title { 'VP of Sales' }
pronouns { nil }
end end
end end

View file

@ -220,6 +220,14 @@ RSpec.describe 'User page' do
expect(page).to have_content("Working hard!") expect(page).to have_content("Working hard!")
end 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 context 'signup disabled' do
it 'shows the sign in link' do it 'shows the sign in link' do
stub_application_setting(signup_enabled: false) stub_application_setting(signup_enabled: false)

View file

@ -11,6 +11,11 @@ RSpec.describe UserDetail do
it { is_expected.to validate_length_of(:job_title).is_at_most(200) } it { is_expected.to validate_length_of(:job_title).is_at_most(200) }
end 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 describe '#bio' do
it { is_expected.to validate_length_of(:bio).is_at_most(255) } it { is_expected.to validate_length_of(:bio).is_at_most(255) }
end end

View file

@ -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).allow_nil }
it { is_expected.to delegate_method(:job_title=).to(:user_detail).with_arguments(:args).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).allow_nil }
it { is_expected.to delegate_method(:bio=).to(:user_detail).with_arguments(:args).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 } 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) expect(user.bio).to eq(user.user_detail.bio)
end 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 it 'creates `user_detail` when `bio` is first updated' do
user = create(:user) user = create(:user)