From 1ffaa680a3c1296eec4016d2f4b612afe8b03fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 12 Sep 2018 19:19:17 +0200 Subject: [PATCH] Create correct translation when visiting root page We set `I18n.locale = :en` before each test, and so creating a new card will automatically create English translations. So visiting the Spanish page won't show the card, since no Spanish translation exists for it. If we visit the klingon page after doing so, the last used locale (Spanish) will still be used, and so the test will fail. Specifically creating Spanish translations instead of the English ones makes the translations visible when visiting the Spanish homepage. --- spec/features/localization_spec.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spec/features/localization_spec.rb b/spec/features/localization_spec.rb index 514170252..eb345cb7c 100644 --- a/spec/features/localization_spec.rb +++ b/spec/features/localization_spec.rb @@ -3,11 +3,13 @@ require 'rails_helper' feature 'Localization' do scenario 'Wrong locale' do - card = create(:widget_card, title: 'Bienvenido a CONSUL', - description: 'Software libre para la participación ciudadana.', - link_text: 'Más información', - link_url: 'http://consulproject.org/', - header: true) + Globalize.with_locale(:es) do + create(:widget_card, title: 'Bienvenido a CONSUL', + description: 'Software libre para la participación ciudadana.', + link_text: 'Más información', + link_url: 'http://consulproject.org/', + header: true) + end visit root_path(locale: :es) visit root_path(locale: :klingon)