From a9344fbf4c0db53f11034c8827abae4373e8602d Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Sat, 9 Jan 2021 01:43:17 +0530 Subject: [PATCH] fix: Add missing switch_locale on DashboardController (#1631) --- app/controllers/dashboard_controller.rb | 4 ++++ spec/controllers/dashboard_controller_spec.rb | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 52f392add..ddf8382f8 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,5 +1,9 @@ class DashboardController < ActionController::Base + include SwitchLocale + before_action :set_global_config + around_action :switch_locale + layout 'vueapp' def index; end diff --git a/spec/controllers/dashboard_controller_spec.rb b/spec/controllers/dashboard_controller_spec.rb index 63f703738..7ada22702 100644 --- a/spec/controllers/dashboard_controller_spec.rb +++ b/spec/controllers/dashboard_controller_spec.rb @@ -1,10 +1,20 @@ require 'rails_helper' -describe '/app', type: :request do - describe 'GET /app' do +describe '/app/login', type: :request do + context 'without DEFAULT_LOCALE' do it 'renders the dashboard' do - get '/app' + get '/app/login' expect(response).to have_http_status(:success) end end + + context 'with DEFAULT_LOCALE' do + it 'renders the dashboard' do + ENV['DEFAULT_LOCALE'] = 'pt_BR' + get '/app/login' + expect(response).to have_http_status(:success) + expect(response.body).to include "selectedLocale: 'pt_BR'" + ENV['DEFAULT_LOCALE'] = 'en' + end + end end