From 9b2424cde054805a698d5d38eb20ffa7a3e02173 Mon Sep 17 00:00:00 2001
From: Jesus Federico <jesus@123it.ca>
Date: Wed, 17 Apr 2019 15:33:38 -0400
Subject: [PATCH] GRN2-112: Default language fallback fails with a 500 error
 (#469)

* GRN2-112: Default language fallback fails with a 500 error

* Updates for passing rspec tests

* Added cache for gitlab ci

* Updated cache for gitlab

* Restored Dockerfile

* Fixed glitch in filter for build and deployment
---
 .gitlab-ci.yml                            | 4 ++++
 app/controllers/application_controller.rb | 5 +++--
 config/locales/es.yml                     | 2 +-
 config/locales/es_MX.yml                  | 2 +-
 scripts/image_build.sh                    | 2 +-
 scripts/image_deploy.sh                   | 2 +-
 6 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8d52eead..95b712ad 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,6 +3,10 @@ stages:
   - build
   - deploy
 
+cache:
+  paths:
+    - /cache
+
 before_script:
 
 test:
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 497a9579..71ab4f1f 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -44,11 +44,12 @@ class ApplicationController < ActionController::Base
   end
 
   def update_locale(user)
-    I18n.locale = if user && user.language != 'default'
-      user.language.tr('-', '_')
+    locale = if user && user.language != 'default'
+      user.language
     else
       http_accept_language.language_region_compatible_from(I18n.available_locales)
     end
+    I18n.locale = locale.tr('-', '_') unless locale.nil?
   end
 
   def meeting_name_limit
diff --git a/config/locales/es.yml b/config/locales/es.yml
index a69e7fe8..7e2b333c 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -68,7 +68,7 @@ es:
   go_back: Atrás
   greenlight: Greenlight
   header:
-    create_room: Creat sala
+    create_room: Crear sala
     dropdown:
       help: "¿Necesitas ayuda?"
       home: Sala principal
diff --git a/config/locales/es_MX.yml b/config/locales/es_MX.yml
index 80732fc6..0ab37bb2 100644
--- a/config/locales/es_MX.yml
+++ b/config/locales/es_MX.yml
@@ -68,7 +68,7 @@ es_MX:
   go_back: Atrás
   greenlight: Greenlight
   header:
-    create_room: Creat sala
+    create_room: Crear sala
     dropdown:
       help: "¿Necesitas ayuda?"
       home: Sala principal
diff --git a/scripts/image_build.sh b/scripts/image_build.sh
index 6664df72..3075e92f 100755
--- a/scripts/image_build.sh
+++ b/scripts/image_build.sh
@@ -53,7 +53,7 @@ if [ -z $CD_DOCKER_REPO ]; then
   export CD_DOCKER_REPO=$CD_REF_SLUG
 fi
 
-if [ "$CD_REF_NAME" != "master" ] && [[ "$CD_REF_NAME" != *"release"* ]] && [ -z $CD_BUILD_ALL ];then
+if [ "$CD_REF_NAME" != "master" ] && [[ "$CD_REF_NAME" != *"release"* ]] && ( -z $CD_BUILD_ALL ] || [ "$CD_BUILD_ALL" != "true" ] ); then
   echo "#### Docker image for $CD_REF_SLUG won't be built"
   exit 0
 fi
diff --git a/scripts/image_deploy.sh b/scripts/image_deploy.sh
index 13f8d910..91d83e38 100755
--- a/scripts/image_deploy.sh
+++ b/scripts/image_deploy.sh
@@ -69,7 +69,7 @@ if [ -z $CD_DOCKER_REPO ]; then
   export CD_DOCKER_REPO=$CD_REF_SLUG
 fi
 
-if [ "$CD_REF_NAME" != "master" ] && [[ "$CD_REF_NAME" != *"release"* ]] && [ -z $CD_DEPLOY_ALL ];then
+if [ "$CD_REF_NAME" != "master" ] && [[ "$CD_REF_NAME" != *"release"* ]] && ( [ -z $CD_DEPLOY_ALL ] || [ "$CD_DEPLOY_ALL" != "true" ] ); then
   echo "#### Docker image for $CD_DOCKER_REPO won't be deployed. The conditions for running this build were not met."
   exit 0
 fi
-- 
GitLab