Commit f406aa7d authored by Patrick Bajao's avatar Patrick Bajao

Merge branch 'djensen-fix-user-commit-email-input' into 'master'

Fix selected for User#commit_email input

See merge request gitlab-org/gitlab!69234
parents a4a657cb bdca30a8
...@@ -12,10 +12,6 @@ module ProfilesHelper ...@@ -12,10 +12,6 @@ module ProfilesHelper
] ]
end end
def selected_commit_email(user)
user.read_attribute(:commit_email) || user.commit_email
end
def attribute_provider_label(attribute) def attribute_provider_label(attribute)
user_synced_attributes_metadata = current_user.user_synced_attributes_metadata user_synced_attributes_metadata = current_user.user_synced_attributes_metadata
if user_synced_attributes_metadata&.synced?(attribute) if user_synced_attributes_metadata&.synced?(attribute)
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
- commit_email_link_url = help_page_path('user/profile/index', anchor: 'change-the-email-displayed-on-your-commits', target: '_blank') - commit_email_link_url = help_page_path('user/profile/index', anchor: 'change-the-email-displayed-on-your-commits', target: '_blank')
- commit_email_link_start = '<a href="%{url}">'.html_safe % { url: commit_email_link_url } - commit_email_link_start = '<a href="%{url}">'.html_safe % { url: commit_email_link_url }
- commit_email_docs_link = s_('Profiles|This email will be used for web based operations, such as edits and merges. %{commit_email_link_start}Learn more%{commit_email_link_end}').html_safe % { commit_email_link_start: commit_email_link_start, commit_email_link_end: '</a>'.html_safe } - commit_email_docs_link = s_('Profiles|This email will be used for web based operations, such as edits and merges. %{commit_email_link_start}Learn more%{commit_email_link_end}').html_safe % { commit_email_link_start: commit_email_link_start, commit_email_link_end: '</a>'.html_safe }
= form.select :commit_email, options_for_select(commit_email_select_options(@user), selected: selected_commit_email(@user)), = form.select :commit_email, options_for_select(commit_email_select_options(@user), selected: @user.read_attribute(:commit_email)),
{ help: commit_email_docs_link }, { help: commit_email_docs_link },
control_class: 'select2 input-lg', disabled: email_change_disabled control_class: 'select2 input-lg', disabled: email_change_disabled
...@@ -53,6 +53,19 @@ RSpec.describe 'User edit profile' do ...@@ -53,6 +53,19 @@ RSpec.describe 'User edit profile' do
expect(page).to have_content('Profile was successfully updated') expect(page).to have_content('Profile was successfully updated')
end end
it 'does not set secondary emails without user input' do
fill_in 'user_organization', with: 'GitLab'
submit_settings
user.reload
expect(page).to have_field('user_commit_email', with: '')
expect(page).to have_field('user_public_email', with: '')
User::SECONDARY_EMAIL_ATTRIBUTES.each do |attribute|
expect(user.read_attribute(attribute)).to be_blank
end
end
it 'shows an error if the full name contains an emoji', :js do it 'shows an error if the full name contains an emoji', :js do
simulate_input('#user_name', 'Martin 😀') simulate_input('#user_name', 'Martin 😀')
submit_settings submit_settings
......
...@@ -24,20 +24,6 @@ RSpec.describe ProfilesHelper do ...@@ -24,20 +24,6 @@ RSpec.describe ProfilesHelper do
end end
end end
describe '#selected_commit_email' do
let(:user) { create(:user) }
it 'returns main email when commit email attribute is nil' do
expect(helper.selected_commit_email(user)).to eq(user.email)
end
it 'returns DB stored commit_email' do
user.update!(commit_email: Gitlab::PrivateCommitEmail::TOKEN)
expect(helper.selected_commit_email(user)).to eq(Gitlab::PrivateCommitEmail::TOKEN)
end
end
describe '#email_provider_label' do describe '#email_provider_label' do
it "returns nil for users without external email" do it "returns nil for users without external email" do
user = create(:user) 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