Commit e467a3b4 authored by Dan Jensen's avatar Dan Jensen

Only set User#commit_email with user input

Previously the User profile form automatically set a value for
User#commit_email. This would become the database value when the
user submitted the form, whether the user was aware of this or not.
That behavior was unnecessary, because the User model already
assumes the commit_email is the primary email when not set. Further,
this behavior complicated validation when the primary email is
being changed. As a simple solution, this change introduces a blank
option to the select dropdown, which is used by default. Now the
database value will only change if the user changes it.

Changelog: fixed
parent 6351643b
......@@ -6,6 +6,7 @@ module ProfilesHelper
verified_emails = user.verified_emails - [private_email]
[
[s_('Use primary email (%{email})') % { email: user.email }, ''],
[s_("Profiles|Use a private email - %{email}").html_safe % { email: private_email }, Gitlab::PrivateCommitEmail::TOKEN],
*verified_emails
]
......
......@@ -219,6 +219,7 @@ To set your time zone:
A commit email is an email address displayed in every Git-related action carried out through the GitLab interface.
Any of your own verified email addresses can be used as the commit email.
Your primary email is used by default.
To change your commit email:
......
......@@ -13,7 +13,8 @@ RSpec.describe ProfilesHelper do
private_email = user.private_commit_email
emails = [
["Use a private email - #{private_email}", Gitlab::PrivateCommitEmail::TOKEN],
[s_('Use primary email (%{email})') % { email: user.email }, ''],
[s_("Profiles|Use a private email - %{email}").html_safe % { email: private_email }, Gitlab::PrivateCommitEmail::TOKEN],
user.email,
confirmed_email1.email,
confirmed_email2.email
......
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