From 0ce23c55b634e15c5afacf6770c79b92c571878d Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Sun, 24 May 2020 20:40:58 -0700 Subject: [PATCH 01/18] Set Current.locale in set_current_locale before action --- app/controllers/application_controller.rb | 6 +++++- app/models/current.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 180776a63..5ef5c9496 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -48,7 +48,11 @@ def authorize def set_current_locale locale = request.subdomain - I18n.locale = locale if I18n.available_locales.include?(locale.to_sym) + + if I18n.available_locales.include?(locale.to_sym) + I18n.locale = locale + Current.locale = locale + end # Force the subdomain to match the locale. # Don’t do this in development, because typically local development diff --git a/app/models/current.rb b/app/models/current.rb index 49d647a38..8908d161b 100644 --- a/app/models/current.rb +++ b/app/models/current.rb @@ -1,3 +1,3 @@ class Current < ActiveSupport::CurrentAttributes - attribute :user, :theme + attribute :user, :locale, :theme end From 50abf66cd625da52af720a98ac65f9b615cbbfc2 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Sun, 24 May 2020 20:50:13 -0700 Subject: [PATCH 02/18] Use Current.locale in app controller before action --- app/controllers/application_controller.rb | 10 ++++++---- .../steal_something_from_work_day_controller.rb | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5ef5c9496..f819f31b1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,6 +5,7 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_action :set_current_locale + before_action :set_current_locale_from_subdomain before_action :set_current_theme before_action :set_site_locale @@ -47,12 +48,13 @@ def authorize end def set_current_locale + Current.locale = I18n.locale + end + + def set_current_locale_from_subdomain locale = request.subdomain - if I18n.available_locales.include?(locale.to_sym) - I18n.locale = locale - Current.locale = locale - end + Current.locale = locale if I18n.available_locales.include?(locale.to_sym) # Force the subdomain to match the locale. # Don’t do this in development, because typically local development diff --git a/app/controllers/steal_something_from_work_day_controller.rb b/app/controllers/steal_something_from_work_day_controller.rb index 7958a1ede..a763adc9f 100644 --- a/app/controllers/steal_something_from_work_day_controller.rb +++ b/app/controllers/steal_something_from_work_day_controller.rb @@ -11,7 +11,7 @@ class StealSomethingFromWorkDayController < ApplicationController def show # Remove current locale from language switcher in the view @locales = STEAL_SOMETHING_FROM_WORK_DAY_LOCALES.dup - @locales.delete I18n.locale + @locales.delete Current.locale @sections = [ 'Introduction', From c11637f4db14237ea0d2eb5a872730ea1d93948e Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Sun, 24 May 2020 20:55:53 -0700 Subject: [PATCH 03/18] Delete unused Locale.current method --- app/models/locale.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/models/locale.rb b/app/models/locale.rb index 3fd964dbd..197264e8b 100644 --- a/app/models/locale.rb +++ b/app/models/locale.rb @@ -13,10 +13,6 @@ class Locale < ApplicationRecord default_scope { order(abbreviation: :asc) } class << self - def current - I18n.locale - end - def english? I18n.locale == :en end From bd6dd1f16f3291847e3fa90a95e8bca629472e87 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 25 May 2020 13:41:42 -0700 Subject: [PATCH 04/18] Split extract redirect_to_locale_subdomain from set_current_locale_from_subdomain --- app/controllers/application_controller.rb | 56 +++++++++++++---------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f819f31b1..b5774bfd6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -7,6 +7,7 @@ class ApplicationController < ActionController::Base before_action :set_current_locale before_action :set_current_locale_from_subdomain before_action :set_current_theme + before_action :redirect_to_locale_subdomain before_action :set_site_locale before_action :check_for_redirection @@ -47,30 +48,6 @@ def authorize redirect_to [:signin], alert: 'You need to sign in to view that page.' unless signed_in? end - def set_current_locale - Current.locale = I18n.locale - end - - def set_current_locale_from_subdomain - locale = request.subdomain - - Current.locale = locale if I18n.available_locales.include?(locale.to_sym) - - # Force the subdomain to match the locale. - # Don’t do this in development, because typically local development - # environments don’t support subdomains (en.localhost doesn’t resolve). - if (I18n.locale != I18n.default_locale) && # Don’t redirect to en.crimethinc.com - request.subdomain.empty? && # Don’t redirect if there’s a subdomain - Rails.env.production? # Don’t redirect in development - - redirect_to({ subdomain: I18n.locale }.merge(params.permit!)) - end - end - - def set_current_theme - Current.theme = ENV.fetch('THEME') { '2017' } - end - def check_for_redirection redirect = Redirect.where(source_path: request.path.downcase).last redirect = Redirect.where(source_path: "#{request.path.downcase}/").last if redirect.blank? @@ -127,6 +104,37 @@ def set_page_share private + def set_current_locale + Current.locale = Locale.find_by abbreviation: I18n.locale + end + + def set_current_locale_from_subdomain + locale_abbreviation = request.subdomain + + Current.locale = Locale.find_by abbreviation: locale_abbreviation if I18n.available_locales.include? locale_abbreviation.to_sym + end + + def redirect_to_locale_subdomain + # Force the subdomain to match the locale. + # Don’t do this in development, because typically local development + # environments don’t support subdomains (en.localhost doesn’t resolve). + + # Don’t redirect to en.crimethinc.com + return if Current.locale.english? + + # Don’t redirect if there’s a subdomain + return if request.subdomain.present? + + # Don’t redirect in development + return if Rails.env.production? + + redirect_to({ subdomain: I18n.locale }.merge(params.permit!)) + end + + def set_current_theme + Current.theme = ENV.fetch('THEME') { '2017' } + end + def page_share_url # TODO: implement this algorithm request.url From 53809683ea4b8ef6d7219f9821764bfc7c7623a1 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 25 May 2020 14:01:16 -0700 Subject: [PATCH 05/18] Move set_current_theme before action to a middleware --- app/controllers/application_controller.rb | 5 ----- app/middlewares/rack/current_theme.rb | 13 +++++++++++++ config/application.rb | 2 ++ 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 app/middlewares/rack/current_theme.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b5774bfd6..0067a4b53 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,7 +6,6 @@ class ApplicationController < ActionController::Base before_action :set_current_locale before_action :set_current_locale_from_subdomain - before_action :set_current_theme before_action :redirect_to_locale_subdomain before_action :set_site_locale @@ -131,10 +130,6 @@ def redirect_to_locale_subdomain redirect_to({ subdomain: I18n.locale }.merge(params.permit!)) end - def set_current_theme - Current.theme = ENV.fetch('THEME') { '2017' } - end - def page_share_url # TODO: implement this algorithm request.url diff --git a/app/middlewares/rack/current_theme.rb b/app/middlewares/rack/current_theme.rb new file mode 100644 index 000000000..e181def97 --- /dev/null +++ b/app/middlewares/rack/current_theme.rb @@ -0,0 +1,13 @@ +module Rack + class CurrentTheme + def initialize app + @app = app + end + + def call env + Current.theme = ENV.fetch('THEME') { '2017' } + + @app.call(env) + end + end +end diff --git a/config/application.rb b/config/application.rb index a74a000c1..07ccb0913 100644 --- a/config/application.rb +++ b/config/application.rb @@ -8,6 +8,7 @@ require_relative '../app/middlewares/rack/pic_twitter_redirect' require_relative '../app/middlewares/rack/redirect' require_relative '../app/middlewares/rack/teapot' +require_relative '../app/middlewares/rack/current_theme' require 'rack/contrib' # Require the gems listed in Gemfile, including any gems @@ -25,6 +26,7 @@ class Application < Rails::Application config.middleware.use Rack::Redirect config.middleware.use Rack::Attack config.middleware.use Rack::Locale + config.middleware.use Rack::CurrentTheme config.middleware.insert_after ActionDispatch::Static, Rack::Deflater # Initialize configuration defaults for originally generated Rails version. From 8629ff57f5ca6d2996f865bdb6628d915d8a2add Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 25 May 2020 15:10:57 -0700 Subject: [PATCH 06/18] Move current locale methods to CurrentLocale middleware --- app/controllers/application_controller.rb | 31 -------- app/middlewares/rack/current_locale.rb | 86 +++++++++++++++++++++++ config/application.rb | 2 + 3 files changed, 88 insertions(+), 31 deletions(-) create mode 100644 app/middlewares/rack/current_locale.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0067a4b53..dc7a4b989 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,10 +4,6 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception - before_action :set_current_locale - before_action :set_current_locale_from_subdomain - before_action :redirect_to_locale_subdomain - before_action :set_site_locale before_action :check_for_redirection before_action :strip_file_extension @@ -103,33 +99,6 @@ def set_page_share private - def set_current_locale - Current.locale = Locale.find_by abbreviation: I18n.locale - end - - def set_current_locale_from_subdomain - locale_abbreviation = request.subdomain - - Current.locale = Locale.find_by abbreviation: locale_abbreviation if I18n.available_locales.include? locale_abbreviation.to_sym - end - - def redirect_to_locale_subdomain - # Force the subdomain to match the locale. - # Don’t do this in development, because typically local development - # environments don’t support subdomains (en.localhost doesn’t resolve). - - # Don’t redirect to en.crimethinc.com - return if Current.locale.english? - - # Don’t redirect if there’s a subdomain - return if request.subdomain.present? - - # Don’t redirect in development - return if Rails.env.production? - - redirect_to({ subdomain: I18n.locale }.merge(params.permit!)) - end - def page_share_url # TODO: implement this algorithm request.url diff --git a/app/middlewares/rack/current_locale.rb b/app/middlewares/rack/current_locale.rb new file mode 100644 index 000000000..5bb6abdb6 --- /dev/null +++ b/app/middlewares/rack/current_locale.rb @@ -0,0 +1,86 @@ +module Rack + class CurrentLocale + def initialize app + @app = app + end + + def call env + @req = Rack::Request.new(env) + + set_current_locale + set_current_locale_from_subdomain + redirect_to_locale_subdomain + + @app.call(env) + end + + private + + def set_current_locale + Current.locale = ::Locale.find_by abbreviation: I18n.locale + end + + def set_current_locale_from_subdomain + return if subdomain.blank? + return unless I18n.available_locales.include? subdomain.to_sym + + Current.locale = ::Locale.find_by abbreviation: subdomain + end + + def redirect_to_locale_subdomain + # Force the subdomain to match the locale. + # Don’t do this in development, because typically local development + # environments don’t support subdomains (en.localhost doesn’t resolve). + + # Don’t redirect to en.crimethinc.com + return if Current.locale.english? + + # Don’t redirect if there’s a subdomain + return if subdomain.present? + + # Don’t redirect in development + return if Rails.env.production? + + redirect localized_url + end + + def subdomain + fully_qualified_domain = @req.host + locale_subdomain = fully_qualified_domain.split('.').first + + locale_subdomain unless locale_subdomain == fully_qualified_domain + end + + def decorated_subdomain + "#{subdomain}." unless subdomain.blank? + end + + def decorated_port + ":#{@req.port}" if Rails.env.development? + end + + def decorated_query_params + "?#{@req.query_string}" if @req.query_string.present? + end + + def localized_url + [ + @req.scheme, + '://', + decorated_subdomain, + @req.host, + decorated_port, + @req.path, + decorated_query_params + ].join + end + + def redirect location + [ + 301, + { 'Location' => location, 'Content-Type' => 'text/html' }, + ['Moved Permanently'] + ] + end + end +end diff --git a/config/application.rb b/config/application.rb index 07ccb0913..12457df41 100644 --- a/config/application.rb +++ b/config/application.rb @@ -8,6 +8,7 @@ require_relative '../app/middlewares/rack/pic_twitter_redirect' require_relative '../app/middlewares/rack/redirect' require_relative '../app/middlewares/rack/teapot' +require_relative '../app/middlewares/rack/current_locale' require_relative '../app/middlewares/rack/current_theme' require 'rack/contrib' @@ -26,6 +27,7 @@ class Application < Rails::Application config.middleware.use Rack::Redirect config.middleware.use Rack::Attack config.middleware.use Rack::Locale + config.middleware.use Rack::CurrentLocale config.middleware.use Rack::CurrentTheme config.middleware.insert_after ActionDispatch::Static, Rack::Deflater From a8c9ac3e5fb049ff9e580e93c5495cb5fff7ffb8 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 25 May 2020 15:17:20 -0700 Subject: [PATCH 07/18] Use Current.locale in header link to language page --- app/controllers/application_controller.rb | 6 ------ app/views/2017/shared/_header.html.erb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index dc7a4b989..6dfff28b6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,7 +4,6 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception - before_action :set_site_locale before_action :check_for_redirection before_action :strip_file_extension before_action :authorize, if: :staging? @@ -124,10 +123,5 @@ def page_share_image_url # TODO: implement this algorithm 'https://cloudfront.crimethinc.com/assets/share/crimethinc-site-share.png' end - - def set_site_locale - @site_locale = LocaleService.find(locale: nil, lang_code: I18n.locale) - end - # ...Page Share end diff --git a/app/views/2017/shared/_header.html.erb b/app/views/2017/shared/_header.html.erb index cb2400c41..ddada38de 100644 --- a/app/views/2017/shared/_header.html.erb +++ b/app/views/2017/shared/_header.html.erb @@ -18,7 +18,7 @@ <% unless Locale.english? %>
    - +
<% end %> From e97da9bd8b2ceb9ffc59f3ac5f0c58da291297f3 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 25 May 2020 15:22:07 -0700 Subject: [PATCH 08/18] Use Current.locale in 2020 homepage footer link to lite mode --- app/views/2020/shared/_footer.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/2020/shared/_footer.html.erb b/app/views/2020/shared/_footer.html.erb index 5764ef433..086360c74 100644 --- a/app/views/2020/shared/_footer.html.erb +++ b/app/views/2020/shared/_footer.html.erb @@ -104,7 +104,7 @@ - <% if media_mode? && I18n.locale == :en %> + <% if media_mode? && Current.locale.english? %> From 3e6ed687552ab4b9a000f5b5cbbe7912c14cbb64 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 25 May 2020 15:22:39 -0700 Subject: [PATCH 09/18] Use Current.locale in 2017 footer link to lite mode --- app/views/2017/shared/_footer.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/2017/shared/_footer.html.erb b/app/views/2017/shared/_footer.html.erb index a8c491ad0..c7d21a400 100644 --- a/app/views/2017/shared/_footer.html.erb +++ b/app/views/2017/shared/_footer.html.erb @@ -5,7 +5,7 @@ <%= render_themed "shared/footer/contact" %> - <% if media_mode? && I18n.locale == :en %> + <% if media_mode? && Current.locale.english? %> From f86aa4056a0c5927055591ae2a50c38862d2fb0b Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 25 May 2020 15:26:08 -0700 Subject: [PATCH 10/18] Use Current.locale in language page subdomain switcher --- app/views/2017/languages/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/2017/languages/show.html.erb b/app/views/2017/languages/show.html.erb index 8292acfe1..d6776534c 100644 --- a/app/views/2017/languages/show.html.erb +++ b/app/views/2017/languages/show.html.erb @@ -14,7 +14,7 @@
- <% unless @locale.abbreviation == I18n.locale.to_s %> + <% unless Current.locale == @locale %> <%= render_markdown t("views.languages.view_site_in_locale", locale: @locale.abbreviation) %> <% end %> From f868cb60f2c8d28025cd313f68039f4da0ba383a Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 25 May 2020 15:50:00 -0700 Subject: [PATCH 11/18] Use Current.locale in #preferred_localization --- app/models/article.rb | 6 +++--- app/models/concerns/translatable.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/article.rb b/app/models/article.rb index 1a6f438f1..aa778ac8a 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -105,13 +105,13 @@ def localizations def localization_in locale [ - Article.published.live.find_by(locale: locale, canonical_id: id), - Article.published.live.find_by(locale: locale, id: canonical_id) + Article.published.live.find_by(locale: locale.abbreviation, canonical_id: id), + Article.published.live.find_by(locale: locale.abbreviation, id: canonical_id) ].compact.first end def preferred_localization - localization_in(I18n.locale).presence || self + localization_in(Current.locale).presence || self end def canonical_article diff --git a/app/models/concerns/translatable.rb b/app/models/concerns/translatable.rb index b775161a9..b851b5b9f 100644 --- a/app/models/concerns/translatable.rb +++ b/app/models/concerns/translatable.rb @@ -15,11 +15,11 @@ def id_and_name end def preferred_localization - localization_in(I18n.locale).presence || self + localization_in(Current.locale).presence || self end def localization_in locale - self.class.published.live.where(locale: locale).where('id = ? OR canonical_id = ?', canonical_id, id).limit(1).first + self.class.published.live.where(locale: locale.abbreviation).where('id = ? OR canonical_id = ?', canonical_id, id).limit(1).first end def localizations From c36db4507d577e5530ff87b24e5a46c49b26455a Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 25 May 2020 15:51:30 -0700 Subject: [PATCH 12/18] Delete Locale.english? --- app/models/locale.rb | 4 ---- app/views/2017/shared/_header.html.erb | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/app/models/locale.rb b/app/models/locale.rb index 197264e8b..854fc64c5 100644 --- a/app/models/locale.rb +++ b/app/models/locale.rb @@ -13,10 +13,6 @@ class Locale < ApplicationRecord default_scope { order(abbreviation: :asc) } class << self - def english? - I18n.locale == :en - end - def live Locale.unscoped.order(articles_count: :desc, abbreviation: :asc).where.not(articles_count: 0) end diff --git a/app/views/2017/shared/_header.html.erb b/app/views/2017/shared/_header.html.erb index ddada38de..d17b49592 100644 --- a/app/views/2017/shared/_header.html.erb +++ b/app/views/2017/shared/_header.html.erb @@ -16,7 +16,7 @@ - <% unless Locale.english? %> + <% unless Current.locale.english? %>
From edf4de4881e1763202f29bd18645631e6640d830 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 25 May 2020 15:56:47 -0700 Subject: [PATCH 13/18] Use Current.locale in TagsHelper --- app/helpers/tags_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index ac2cac6e2..b2e9514cc 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -3,11 +3,11 @@ module TagsHelper attr_accessor :html_id def html_dir - article_locale&.language_direction.presence || t('language_direction') + article_locale&.language_direction.presence || Current.locale.language_direction end def html_lang - article_locale&.abbreviation.presence || I18n.locale + article_locale&.abbreviation.presence || Current.locale.abbreviation end def html_prefix From 147c4bc2aad127c64c8467d2f3c1e4c307165ece Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 25 May 2020 16:00:46 -0700 Subject: [PATCH 14/18] Use Current.locale in MarkdownHelper --- app/helpers/markdown_helper.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/helpers/markdown_helper.rb b/app/helpers/markdown_helper.rb index 70430e822..1f68f4d26 100644 --- a/app/helpers/markdown_helper.rb +++ b/app/helpers/markdown_helper.rb @@ -1,6 +1,13 @@ module MarkdownHelper def render_markdown_for page: - content = File.read [Rails.root, "config/locales/pages/#{I18n.locale}", "#{page}.markdown"].join('/') + content = File.read [ + Rails.root, + 'config', + 'locales', + 'pages', + Current.locale.abbreviation, + "#{page}.markdown" + ].join('/') render_markdown content end From 0f90ac565d337a41ea2f635e3c8317bb281b0597 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 25 May 2020 16:06:46 -0700 Subject: [PATCH 15/18] Use Current.locale in locale_nav_item_classes_for (2020 layout) --- app/helpers/locales_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/locales_helper.rb b/app/helpers/locales_helper.rb index 515e0ec71..a130d02d3 100644 --- a/app/helpers/locales_helper.rb +++ b/app/helpers/locales_helper.rb @@ -6,7 +6,7 @@ def locale abbreviation def locale_nav_item_classes_for locale classes = [] classes << locale.abbreviation - classes << 'current' if I18n.locale.to_s == locale.abbreviation + classes << 'current' if Current.locale == locale classes end end From edb00d6269dfec83fb59b0152ec9366bed669e4f Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 25 May 2020 17:06:22 -0700 Subject: [PATCH 16/18] Set Current.theme in spec_helper --- spec/spec_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 64a0afcc0..e423172c7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,6 +6,10 @@ driven_by :selenium_headless, using: :firefox end + config.before do + Current.theme = '2017' + end + config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end From 17477cdc39f3151ea69689d98011ff977c04eea6 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 25 May 2020 17:12:43 -0700 Subject: [PATCH 17/18] Set Current.locale before each spec --- spec/system/tools_index_pages_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/system/tools_index_pages_spec.rb b/spec/system/tools_index_pages_spec.rb index 670339a1b..5c8d083ad 100644 --- a/spec/system/tools_index_pages_spec.rb +++ b/spec/system/tools_index_pages_spec.rb @@ -2,6 +2,7 @@ describe 'Tools Pages' do before do + Current.locale = FactoryBot.build_stubbed :locale Current.theme = '2017' end From cea8506ffe784fe185604c09b6c7def059dcb639 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 25 May 2020 17:15:38 -0700 Subject: [PATCH 18/18] Set Current.locale before each spec in spec helper --- spec/spec_helper.rb | 1 + spec/system/tools_index_pages_spec.rb | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e423172c7..302549a0e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,6 +7,7 @@ end config.before do + Current.locale = FactoryBot.build_stubbed :locale Current.theme = '2017' end diff --git a/spec/system/tools_index_pages_spec.rb b/spec/system/tools_index_pages_spec.rb index 5c8d083ad..670339a1b 100644 --- a/spec/system/tools_index_pages_spec.rb +++ b/spec/system/tools_index_pages_spec.rb @@ -2,7 +2,6 @@ describe 'Tools Pages' do before do - Current.locale = FactoryBot.build_stubbed :locale Current.theme = '2017' end