diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 00000000..2fbf0ffd --- /dev/null +++ b/.bundle/config @@ -0,0 +1 @@ +--- {} diff --git a/Gemfile b/Gemfile index b831a074..57090d6f 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,9 @@ source "https://rubygems.org" branch = ENV.fetch('SOLIDUS_BRANCH', 'master') gem "solidus", github: "solidusio/solidus", branch: branch +# Provides basic authentication functionality for testing parts of your engine +gem 'solidus_auth_devise' + if branch == 'master' || branch >= "v2.0" gem "rails-controller-testing", group: :test else diff --git a/app/controllers/spree/devise_controllers_decorator.rb b/app/controllers/spree/devise_controllers_decorator.rb new file mode 100644 index 00000000..7d72260b --- /dev/null +++ b/app/controllers/spree/devise_controllers_decorator.rb @@ -0,0 +1,8 @@ +begin + Spree::UserPasswordsController.include SolidusI18n::ControllerLocaleHelper + Spree::UserRegistrationsController.include SolidusI18n::ControllerLocaleHelper + Spree::UserSessionsController.include SolidusI18n::ControllerLocaleHelper + Spree::Admin::UserSessionsController.include SolidusI18n::ControllerLocaleHelper +rescue NameError + # App is not using solidus_auth_devise +end diff --git a/config/locales/it.yml b/config/locales/it.yml index 4797877c..290c1676 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -604,7 +604,7 @@ it: add: Nuovo credito back_to_user_list: Lista utenti select_reason: Motivo - admin_login: Login + admin_login: Login amministratore administration: Amministrazione advertise: Promuovi agree_to_privacy_policy: Accetta Politica di Privacy @@ -708,6 +708,7 @@ it: other: Subtotale (%{count} articoli) categories: Categorie category: Categoria + change_my_password: Cambia la mia password charged: Addebitato check_for_spree_alerts: Visualizza le segnalazioni di Spree checkout: Checkout diff --git a/spec/features/admin/translations_spec.rb b/spec/features/admin/translations_spec.rb index 07c6d276..ea1b36bf 100644 --- a/spec/features/admin/translations_spec.rb +++ b/spec/features/admin/translations_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.feature 'Translations', :js do +RSpec.feature 'Admin translations', :js do stub_authorization! given!(:store) { create(:store) } @@ -53,4 +53,15 @@ end end end + + context 'solidus_auth_devise pages translation' do + background do + store.update_attributes(preferred_available_locales: [:en, :it]) + end + + scenario 'the login page is translated' do + visit spree.admin_login_path(locale: "it") + expect(page).to have_content(/#{Spree.t(:admin_login, locale: :it)}/i) + end + end end diff --git a/spec/features/translations_spec.rb b/spec/features/translations_spec.rb index 1d3793b5..272d80cc 100644 --- a/spec/features/translations_spec.rb +++ b/spec/features/translations_spec.rb @@ -2,13 +2,13 @@ require 'spec_helper' -RSpec.feature 'Translations', :js do +RSpec.feature 'Frontend translations', :js do given(:language) { Spree.t(:this_file_language, scope: 'i18n', locale: 'pt-BR') } given(:store) { create(:store) } background do reset_spree_preferences - store.update_attributes(preferred_available_locales: %i[en pt-BR]) + store.update_attributes(preferred_available_locales: %i[en pt-BR it]) end context 'page' do @@ -27,4 +27,28 @@ end end end + + context 'solidus_auth_devise pages translation' do + let(:locale) { :it } + + scenario 'the login page is translated' do + visit spree.login_path(locale: locale) + expect(page).to have_content(/#{Spree.t(:login_as_existing, locale: locale)}/i) + end + + scenario 'the signup page is translated' do + visit spree.signup_path(locale: locale) + expect(page).to have_content(/#{Spree.t(:new_customer, locale: locale)}/i) + end + + scenario 'the forgot password page is translated' do + visit spree.recover_password_path(locale: locale) + expect(page).to have_content(/#{Spree.t(:forgot_password, locale: locale)}/i) + end + + scenario 'the change password page is translated' do + visit spree.edit_password_path(locale: locale, reset_password_token: "123") + expect(page).to have_content(/#{Spree.t(:change_my_password, locale: locale)}/i) + end + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1d03c34f..e45b71c8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -26,6 +26,8 @@ config.expect_with :rspec do |expectations| expectations.syntax = :expect end + + config.include Devise::Test::ControllerHelpers, type: :controller end Dir[File.join(File.dirname(__FILE__), '/support/**/*.rb')].each { |file| require file }