From 563716291c73fad3b44e01c4ad260c2103273569 Mon Sep 17 00:00:00 2001 From: eacaps Date: Mon, 1 Aug 2016 10:35:40 -0400 Subject: [PATCH] a few final minor tweaks --- app/helpers/react_on_rails_helper.rb | 11 ++++++----- spec/dummy/config/initializers/react_on_rails.rb | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/helpers/react_on_rails_helper.rb b/app/helpers/react_on_rails_helper.rb index 93d3ed563..776a51a9c 100644 --- a/app/helpers/react_on_rails_helper.rb +++ b/app/helpers/react_on_rails_helper.rb @@ -344,7 +344,12 @@ def initialize_redux_stores # rubocop:disable Metrics/AbcSize def rails_context(server_side:) @rails_context ||= begin - result = { inMailer: controller.present? && controller.is_a?(ActionMailer::Base) } + result = { + inMailer: controller.present? && controller.is_a?(ActionMailer::Base), + # Locale settings + i18nLocale: I18n.locale, + i18nDefaultLocale: I18n.default_locale + } if request.present? # Using Addressable instead of standard URI to better deal with # non-ASCII characters (see https://github.com/shakacode/react_on_rails/pull/405) @@ -360,10 +365,6 @@ def rails_context(server_side:) port: uri.port, pathname: uri.path, # /posts search: uri.query, # id=30&limit=5 - - # Locale settings - i18nLocale: I18n.locale, - i18nDefaultLocale: I18n.default_locale, httpAcceptLanguage: request.env["HTTP_ACCEPT_LANGUAGE"] ) end diff --git a/spec/dummy/config/initializers/react_on_rails.rb b/spec/dummy/config/initializers/react_on_rails.rb index cf08cf653..57d977e11 100644 --- a/spec/dummy/config/initializers/react_on_rails.rb +++ b/spec/dummy/config/initializers/react_on_rails.rb @@ -2,13 +2,13 @@ module RenderingExtension # Return a Hash that contains custom values from the view context that will get passed to # all calls to react_component and redux_store for rendering def self.custom_context(view_context) - result = {} - unless view_context.controller.is_a?(ActionMailer::Base) - result = { + if view_context.controller.is_a?(ActionMailer::Base) + {} + else + { somethingUseful: view_context.session[:something_useful] } end - result end end