Sha256: 79c2489e7f648e012e935aef83532811efd25d9f0fce48b90e9845f6b3255a3a

Contents?: true

Size: 1.46 KB

Versions: 31

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe 'setting locale', type: :feature do
  def with_locale(locale)
    I18n.locale = locale
    Spree::Frontend::Config[:locale] = locale
    yield
    I18n.locale = 'en'
    Spree::Frontend::Config[:locale] = 'en'
  end

  context 'shopping cart link and page' do
    before do
      I18n.backend.store_translations(:fr,
       spree: {
         cart: 'Panier',
         shopping_cart: 'Panier'
      })
    end

    it 'should be in french' do
      with_locale('fr') do
        visit spree.root_path
        click_link 'Panier'
        expect(page).to have_content('Panier')
      end
    end
  end

  context 'checkout form validation messages' do
    include_context 'checkout setup'

    let(:error_messages) do
      {
        'en' => 'This field is required.',
        'fr' => 'Ce champ est obligatoire.',
        'de' => 'Dieses Feld ist ein Pflichtfeld.',
      }
    end

    def check_error_text(text)
      %w(firstname lastname address1 city).each do |attr|
        expect(find("#b#{attr} label.error").text).to eq(text)
      end
    end

    it 'shows translated jquery.validate error messages', js: true do
      visit spree.root_path
      click_link mug.name
      click_button 'add-to-cart-button'
      error_messages.each do |locale, message|
        with_locale(locale) do
          visit '/checkout/address'
          find('.form-buttons input[type=submit]').click
          check_error_text message
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
spree_frontend-3.3.0.rc1 spec/features/locale_spec.rb
spree_frontend-3.1.5 spec/features/locale_spec.rb
spree_frontend-3.2.1 spec/features/locale_spec.rb
spree_frontend-3.2.0 spec/features/locale_spec.rb
spree_frontend-3.1.4 spec/features/locale_spec.rb
spree_frontend-3.2.0.rc3 spec/features/locale_spec.rb
spree_frontend-3.2.0.rc2 spec/features/locale_spec.rb
spree_frontend-3.2.0.rc1 spec/features/locale_spec.rb
spree_frontend-3.1.3 spec/features/locale_spec.rb
spree_frontend-3.1.2 spec/features/locale_spec.rb
spree_frontend-3.0.10 spec/features/locale_spec.rb
spree_frontend-3.1.1 spec/features/locale_spec.rb
spree_frontend-3.1.0 spec/features/locale_spec.rb
spree_frontend-3.1.0.rc4 spec/features/locale_spec.rb
spree_frontend-3.0.9 spec/features/locale_spec.rb
spree_frontend-3.1.0.rc3 spec/features/locale_spec.rb
spree_frontend-3.1.0.rc2 spec/features/locale_spec.rb
spree_frontend-3.1.0.rc1 spec/features/locale_spec.rb
spree_frontend-3.0.8 spec/features/locale_spec.rb
spree_frontend-3.0.7 spec/features/locale_spec.rb