Commit 2ddc9575 authored by George Koltsov's avatar George Koltsov

Fix Profile Applications page i18n

  - No matter which language was selected, Profile Applications
    page was always displaying the page in English. This change
    fixes i18n to make sure page is displayed in user's locale.
parent 91dd672d
...@@ -17,6 +17,8 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController ...@@ -17,6 +17,8 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
before_action :add_gon_variables before_action :add_gon_variables
before_action :load_scopes, only: [:index, :create, :edit, :update] before_action :load_scopes, only: [:index, :create, :edit, :update]
around_action :set_locale
helper_method :can? helper_method :can?
layout 'profile' layout 'profile'
...@@ -70,4 +72,8 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController ...@@ -70,4 +72,8 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
params[:owner] = current_user params[:owner] = current_user
end end
end end
def set_locale(&block)
Gitlab::I18n.with_user_locale(current_user, &block)
end
end end
---
title: Fix Profile Applications page to be shown in correct locale
merge_request: 35661
author:
type: fixed
...@@ -968,4 +968,26 @@ RSpec.describe ApplicationController do ...@@ -968,4 +968,26 @@ RSpec.describe ApplicationController do
end end
end end
end end
describe 'locale' do
let(:user) { create(:user, preferred_language: 'uk') }
controller(described_class) do
def index
:ok
end
end
before do
sign_in(user)
allow(Gitlab::I18n).to receive(:with_locale).and_call_original
end
it "sets user's locale" do
expect(Gitlab::I18n).to receive(:with_locale).with('uk')
get :index
end
end
end end
...@@ -121,6 +121,22 @@ RSpec.describe Oauth::ApplicationsController do ...@@ -121,6 +121,22 @@ RSpec.describe Oauth::ApplicationsController do
end end
end end
describe 'locale' do
let(:user) { create(:user, preferred_language: 'uk') }
before do
sign_in(user)
allow(Gitlab::I18n).to receive(:with_locale).and_call_original
end
it "sets user's locale" do
expect(Gitlab::I18n).to receive(:with_locale).with('uk')
get :new
end
end
def disable_user_oauth def disable_user_oauth
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:user_oauth_applications?).and_return(false) allow(Gitlab::CurrentSettings.current_application_settings).to receive(:user_oauth_applications?).and_return(false)
end end
......
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