Commit 42ea5023 authored by James Lopez's avatar James Lopez

Merge branch 'kassio/fix-user-default-language' into 'master'

Use `User#preferred_language` language as default

See merge request gitlab-org/gitlab!35676
parents ac503dd1 787296d7
......@@ -70,7 +70,10 @@ module PreferencesHelper
end
def language_choices
Gitlab::I18n::AVAILABLE_LANGUAGES.map(&:reverse).sort
options_for_select(
Gitlab::I18n::AVAILABLE_LANGUAGES.map(&:reverse).sort,
current_user.preferred_language
)
end
private
......
---
title: "Use the user's preferred language as default"
merge_request: 35676
author:
type: fixed
......@@ -56,4 +56,17 @@ RSpec.describe 'User edit preferences profile' do
expect(page).to have_content('Failed to save preferences')
end
end
describe 'User language' do
let(:user) { create(:user, preferred_language: :es) }
it 'shows the user preferred language by default' do
expect(page).to have_select(
'user[preferred_language]',
selected: 'Spanish - español',
options: Gitlab::I18n::AVAILABLE_LANGUAGES.values,
visible: :all
)
end
end
end
......@@ -120,13 +120,6 @@ RSpec.describe PreferencesHelper do
end
end
describe '#language_choices' do
it 'returns an array of all available languages' do
expect(helper.language_choices).to be_an(Array)
expect(helper.language_choices.map(&:first)).to eq(Gitlab::I18n::AVAILABLE_LANGUAGES.values.sort)
end
end
def stub_user(messages = {})
if messages.empty?
allow(helper).to receive(:current_user).and_return(nil)
......
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