solidus_i18n 1.2.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (191) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +35 -0
  3. data/.gem_release.yml +5 -0
  4. data/.github/stale.yml +17 -0
  5. data/.gitignore +4 -8
  6. data/.hound.yml +1 -1
  7. data/.rspec +2 -0
  8. data/.rubocop.yml +3 -6
  9. data/.rubocop_todo.yml +18 -0
  10. data/Gemfile +20 -10
  11. data/{LICENSE.md → LICENSE} +2 -2
  12. data/README.md +47 -46
  13. data/Rakefile +8 -24
  14. data/bin/console +17 -0
  15. data/bin/rails +12 -4
  16. data/bin/setup +8 -0
  17. data/config/locales/bg.yml +1 -47
  18. data/config/locales/ca.yml +12 -49
  19. data/config/locales/cs.yml +1 -48
  20. data/config/locales/da.yml +1 -47
  21. data/config/locales/de-CH.yml +0 -48
  22. data/config/locales/de.yml +408 -257
  23. data/config/locales/en-AU.yml +0 -48
  24. data/config/locales/en-GB.yml +1 -47
  25. data/config/locales/en-IN.yml +7 -53
  26. data/config/locales/en-NZ.yml +0 -48
  27. data/config/locales/es-CL.yml +1 -49
  28. data/config/locales/es-EC.yml +1 -47
  29. data/config/locales/es-MX.yml +417 -111
  30. data/config/locales/es.yml +27 -63
  31. data/config/locales/et.yml +0 -50
  32. data/config/locales/fa.yml +0 -48
  33. data/config/locales/fi.yml +1 -47
  34. data/config/locales/fr.yml +660 -264
  35. data/config/locales/id.yml +2 -46
  36. data/config/locales/it.yml +1196 -646
  37. data/config/locales/ja.yml +7 -53
  38. data/config/locales/ko.yml +0 -48
  39. data/config/locales/lv.yml +0 -48
  40. data/config/locales/nb.yml +0 -48
  41. data/config/locales/nl.yml +1 -47
  42. data/config/locales/pl.yml +1 -47
  43. data/config/locales/pt-BR.yml +1093 -251
  44. data/config/locales/pt.yml +0 -48
  45. data/config/locales/ro.yml +3 -48
  46. data/config/locales/ru.yml +1884 -1240
  47. data/config/locales/sk.yml +1 -45
  48. data/config/locales/sl-SI.yml +0 -48
  49. data/config/locales/sv.yml +1 -47
  50. data/config/locales/th.yml +1 -45
  51. data/config/locales/tr.yml +1 -45
  52. data/config/locales/uk.yml +1 -49
  53. data/config/locales/vi.yml +1 -45
  54. data/config/locales/zh-CN.yml +1 -45
  55. data/config/locales/zh-TW.yml +1 -45
  56. data/config/routes.rb +2 -8
  57. data/i18n-tasks.yml +4 -0
  58. data/lib/generators/solidus_i18n/install/install_generator.rb +10 -13
  59. data/lib/solidus_i18n/engine.rb +9 -36
  60. data/lib/solidus_i18n/factories.rb +4 -0
  61. data/lib/solidus_i18n/version.rb +3 -16
  62. data/lib/solidus_i18n.rb +4 -5
  63. data/lib/tasks/solidus_i18n/upgrade.rake +13 -11
  64. data/solidus_i18n.gemspec +29 -37
  65. data/spec/dummy/README.md +24 -0
  66. data/spec/dummy/Rakefile +6 -0
  67. data/spec/dummy/app/assets/config/manifest.js +2 -0
  68. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  69. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  70. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  71. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  72. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  73. data/spec/dummy/app/jobs/application_job.rb +7 -0
  74. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  75. data/spec/dummy/app/models/application_record.rb +3 -0
  76. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  77. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  78. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  79. data/spec/dummy/bin/rails +4 -0
  80. data/spec/dummy/bin/rake +4 -0
  81. data/spec/dummy/bin/setup +33 -0
  82. data/spec/dummy/config/application.rb +53 -0
  83. data/spec/dummy/config/boot.rb +6 -0
  84. data/spec/dummy/config/cable.yml +10 -0
  85. data/spec/dummy/config/credentials.yml.enc +1 -0
  86. data/spec/dummy/config/database.yml +12 -0
  87. data/spec/dummy/config/environment.rb +5 -0
  88. data/spec/dummy/config/environments/development.rb +76 -0
  89. data/spec/dummy/config/environments/production.rb +120 -0
  90. data/spec/dummy/config/environments/test.rb +36 -0
  91. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  92. data/spec/dummy/config/initializers/assets.rb +12 -0
  93. data/spec/dummy/config/initializers/backtrace_silencers.rb +8 -0
  94. data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
  95. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  96. data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
  97. data/spec/dummy/config/initializers/inflections.rb +16 -0
  98. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  99. data/spec/dummy/config/initializers/permissions_policy.rb +11 -0
  100. data/spec/dummy/config/initializers/spree.rb +74 -0
  101. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  102. data/spec/dummy/config/locales/en.yml +33 -0
  103. data/spec/dummy/config/master.key +1 -0
  104. data/spec/dummy/config/routes.rb +9 -0
  105. data/spec/dummy/config/storage.yml +34 -0
  106. data/spec/dummy/config.ru +6 -0
  107. data/spec/dummy/db/migrate/20210218213814_create_active_storage_tables.active_storage.rb +36 -0
  108. data/spec/dummy/db/migrate/20210218213818_create_action_mailbox_tables.action_mailbox.rb +14 -0
  109. data/spec/dummy/db/migrate/20210218213819_create_action_text_tables.action_text.rb +14 -0
  110. data/spec/dummy/db/migrate/20210218213820_solidus_one_four.spree.rb +1103 -0
  111. data/spec/dummy/db/migrate/20210218213821_create_spree_wallet_payment_sources.spree.rb +28 -0
  112. data/spec/dummy/db/migrate/20210218213822_migrate_credit_cards_to_wallet_payment_sources.spree.rb +30 -0
  113. data/spec/dummy/db/migrate/20210218213823_remove_is_default_from_prices.spree.rb +8 -0
  114. data/spec/dummy/db/migrate/20210218213824_remove_currency_from_line_items.spree.rb +8 -0
  115. data/spec/dummy/db/migrate/20210218213825_add_available_to_columns_and_remove_display_on_from_payment_methods.spree.rb +31 -0
  116. data/spec/dummy/db/migrate/20210218213826_create_spree_promotion_code_batch.spree.rb +39 -0
  117. data/spec/dummy/db/migrate/20210218213827_add_available_to_users_and_remove_display_on_from_shipping_methods.spree.rb +23 -0
  118. data/spec/dummy/db/migrate/20210218213828_add_index_to_spree_payments_number.spree.rb +8 -0
  119. data/spec/dummy/db/migrate/20210218213829_remove_spree_store_credits_column.spree.rb +8 -0
  120. data/spec/dummy/db/migrate/20210218213830_add_lft_and_rgt_indexes_to_taxons.spree.rb +9 -0
  121. data/spec/dummy/db/migrate/20210218213831_remove_order_id_from_inventory_units.spree.rb +31 -0
  122. data/spec/dummy/db/migrate/20210218213832_transform_tax_rate_category_relation.spree.rb +51 -0
  123. data/spec/dummy/db/migrate/20210218213833_add_roles_unique_constraints.spree.rb +9 -0
  124. data/spec/dummy/db/migrate/20210218213834_add_time_range_to_tax_rate.spree.rb +9 -0
  125. data/spec/dummy/db/migrate/20210218213835_rename_bogus_gateways.spree.rb +19 -0
  126. data/spec/dummy/db/migrate/20210218213836_remove_default_tax_from_spree_zones.spree.rb +8 -0
  127. data/spec/dummy/db/migrate/20210218213837_create_promotion_rule_stores.spree.rb +13 -0
  128. data/spec/dummy/db/migrate/20210218213838_create_store_shipping_methods.spree.rb +13 -0
  129. data/spec/dummy/db/migrate/20210218213839_add_available_locales_to_stores.spree.rb +10 -0
  130. data/spec/dummy/db/migrate/20210218213840_add_amount_remaining_to_store_credit_events.spree.rb +62 -0
  131. data/spec/dummy/db/migrate/20210218213841_add_join_characters_to_promotion_code_batch.spree.rb +12 -0
  132. data/spec/dummy/db/migrate/20210218213842_add_apply_to_all_to_variant_property_rule.spree.rb +13 -0
  133. data/spec/dummy/db/migrate/20210218213843_create_spree_store_credit_reasons_table.spree.rb +56 -0
  134. data/spec/dummy/db/migrate/20210218213844_remove_code_from_spree_promotions.spree.rb +43 -0
  135. data/spec/dummy/db/migrate/20210218213845_drop_spree_store_credit_update_reasons.spree.rb +20 -0
  136. data/spec/dummy/db/migrate/20210218213846_add_default_billng_flag_to_user_addresses.spree.rb +7 -0
  137. data/spec/dummy/db/migrate/20210218213847_add_bcc_email_to_spree_stores.spree.rb +8 -0
  138. data/spec/dummy/db/migrate/20210218213848_add_discontinue_on_to_spree_products.spree.rb +8 -0
  139. data/spec/dummy/db/migrate/20210218213849_add_name_to_spree_addresses.spree.rb +14 -0
  140. data/spec/dummy/db/migrate/20210218213850_add_api_key_to_spree_users.spree_api.rb +10 -0
  141. data/spec/dummy/db/migrate/20210218213851_resize_api_key_field.spree_api.rb +10 -0
  142. data/spec/dummy/db/migrate/20210218213852_rename_api_key_to_spree_api_key.spree_api.rb +10 -0
  143. data/spec/dummy/db/migrate/20210218213853_add_index_to_user_spree_api_key.spree_api.rb +10 -0
  144. data/spec/dummy/db/schema.rb +1215 -0
  145. data/spec/dummy/db/seeds.rb +10 -0
  146. data/spec/dummy/db/solidus_test.sqlite3 +0 -0
  147. data/spec/dummy/log/test.log +1198 -0
  148. data/spec/dummy/public/404.html +67 -0
  149. data/spec/dummy/public/422.html +67 -0
  150. data/spec/dummy/public/500.html +66 -0
  151. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  152. data/spec/dummy/public/apple-touch-icon.png +0 -0
  153. data/spec/dummy/public/favicon.ico +0 -0
  154. data/spec/dummy/tmp/development_secret.txt +1 -0
  155. data/spec/dummy/vendor/assets/javascripts/spree/backend/all.js +10 -0
  156. data/spec/dummy/vendor/assets/javascripts/spree/frontend/all.js +10 -0
  157. data/{app/assets/stylesheets/spree/backend/solidus_i18n.css → spec/dummy/vendor/assets/stylesheets/spree/backend/all.css} +1 -0
  158. data/{app/assets/stylesheets/spree/frontend/solidus_i18n.css → spec/dummy/vendor/assets/stylesheets/spree/frontend/all.css} +1 -0
  159. data/spec/examples.txt +4 -0
  160. data/spec/solidus_i18n_spec.rb +67 -0
  161. data/spec/spec_helper.rb +15 -13
  162. metadata +222 -264
  163. data/.travis.yml +0 -30
  164. data/app/assets/javascripts/spree/backend/solidus_i18n.js +0 -2
  165. data/app/assets/javascripts/spree/backend/translations.js.coffee +0 -5
  166. data/app/assets/javascripts/spree/frontend/locale.js.coffee +0 -3
  167. data/app/assets/javascripts/spree/frontend/solidus_i18n.js +0 -2
  168. data/app/controllers/spree/admin/locales_controller.rb +0 -16
  169. data/app/controllers/spree/api/base_controller_decorator.rb +0 -3
  170. data/app/controllers/spree/base_controller_decorator.rb +0 -3
  171. data/app/controllers/spree/locale_controller_decorator.rb +0 -6
  172. data/app/helpers/solidus_i18n/locale_helper.rb +0 -31
  173. data/app/overrides/spree/admin/shared/_configuration_menu/add_i18n_tab.html.erb.deface +0 -2
  174. data/app/overrides/spree/shared/_main_nav_bar/locale_selector.html.erb.deface +0 -16
  175. data/app/views/spree/admin/locales/show.html.erb +0 -27
  176. data/config/initializers/country_names.rb +0 -51
  177. data/config/initializers/routing_filter.rb +0 -2
  178. data/db/migrate/20150609154031_remove_translations_from_spree_tables.rb +0 -65
  179. data/lib/solidus_i18n/configuration.rb +0 -9
  180. data/lib/solidus_i18n/controller_locale_helper.rb +0 -29
  181. data/lib/solidus_i18n/locale.rb +0 -13
  182. data/spec/controllers/locales_controller_spec.rb +0 -24
  183. data/spec/features/admin/translations_spec.rb +0 -34
  184. data/spec/features/russian_errors_translation_spec.rb +0 -17
  185. data/spec/features/translation_spec.rb +0 -31
  186. data/spec/features/translations_spec.rb +0 -28
  187. data/spec/support/capybara.rb +0 -11
  188. data/spec/support/database_cleaner.rb +0 -23
  189. data/spec/support/factory_girl.rb +0 -5
  190. data/spec/support/i18n.rb +0 -5
  191. data/spec/support/spree.rb +0 -12
@@ -1,31 +0,0 @@
1
- module SolidusI18n
2
- module LocaleHelper
3
-
4
- def select_available_locales
5
- select_tag('available_locales[]', options_for_select(
6
- all_locales_options,
7
- Config.available_locales
8
- ), common_options)
9
- end
10
-
11
- def available_locales_options
12
- Config.available_locales.map { |locale| locale_presentation(locale) }
13
- end
14
-
15
- # Need to manually add en to the array because the en.yml was moved from
16
- # this project. solidusio/solidus now has those keys.
17
- def all_locales_options
18
- SolidusI18n::Locale.all.map { |locale| locale_presentation(locale) }.push(['English (EN)', :en])
19
- end
20
-
21
- private
22
-
23
- def locale_presentation(locale)
24
- [Spree.t(:'i18n.this_file_language', locale: locale), locale]
25
- end
26
-
27
- def common_options
28
- { class: 'fullwidth', multiple: 'true' }
29
- end
30
- end
31
- end
@@ -1,2 +0,0 @@
1
- <!-- insert_bottom '[data-hook=admin_configurations_sidebar_menu]'-->
2
- <%= tab :locales, url: spree.admin_locale_path %>
@@ -1,16 +0,0 @@
1
- <!-- insert_bottom '#main-nav-bar' -->
2
- <% if SolidusI18n::Config.available_locales.many? %>
3
- <li id="locale-select" data-hook>
4
- <%= form_tag spree.set_locale_path, class: 'navbar-form' do %>
5
- <div class="form-group">
6
- <label for="switch_to_locale" class="sr-only">
7
- <%= Spree.t(:'i18n.language') %>
8
- </label>
9
- <%= select_tag(:switch_to_locale,
10
- options_for_select(available_locales_options, I18n.locale),
11
- class: 'form-control') %>
12
- <noscript><%= submit_tag %></noscript>
13
- </div>
14
- <% end %>
15
- </li>
16
- <% end %>
@@ -1,27 +0,0 @@
1
- <%= render 'spree/admin/shared/configuration_menu' %>
2
-
3
- <%= form_tag admin_locale_path, method: :patch do %>
4
- <div class="panel panel-default panel-localization">
5
- <div class="panel-heading">
6
- <h1 class="panel-title">
7
- <%= Spree.t(:'i18n.localization_settings') %>
8
- </h1>
9
- </div>
10
-
11
- <div class="panel-body" data-hook="localization_settings_body">
12
- <div class="form-group">
13
- <label for="available_locales_">
14
- <%= Spree.t(:'i18n.available_locales') %>
15
- </label>
16
- <%= select_available_locales %>
17
- <p class="help-block">
18
- <%= Spree.t(:'i18n.locales_displayed_on_frontend_select_box') %>
19
- </p>
20
- </div>
21
- </div>
22
- </div>
23
-
24
- <div class="form-buttons filter-actions actions" data-hook="buttons">
25
- <%= button Spree.t('actions.update') %>
26
- </div>
27
- <% end %>
@@ -1,51 +0,0 @@
1
- require 'i18n_data'
2
-
3
- module I18n
4
- module Backend
5
- class I18nDataBackend
6
- module Implementation
7
- include Base, Flatten
8
-
9
- def available_locales
10
- I18nData.languages.keys.map(&:to_sym)
11
- end
12
-
13
- def lookup(locale, key, scope = [], options = {})
14
- I18nData.countries(locale)[key]
15
- rescue I18nData::NoTranslationAvailable
16
- # rescue failed lookup to fall back to this extensions locale files.
17
- end
18
- end
19
-
20
- include Implementation
21
- end
22
- end
23
- end
24
-
25
- I18n.backend = I18n::Backend::Chain.new(I18n::Backend::I18nDataBackend.new, I18n.backend)
26
-
27
- module I18nData
28
- private
29
-
30
- def self.normal_to_region_code(normal)
31
- country_mappings = {
32
- 'DE-CH' => 'de',
33
- 'FR-CH' => 'fr',
34
- 'EN-AU' => 'en',
35
- 'EN-GB' => 'en',
36
- 'EN-US' => 'en',
37
- 'EN-IN' => 'en',
38
- 'EN-NZ' => 'en',
39
- 'ES-CL' => 'es',
40
- 'ES-EC' => 'es',
41
- 'ES-MX' => 'es',
42
- 'PT-BR' => 'pt',
43
- 'SL-SI' => 'sl',
44
- 'ZH-TW' => 'zh_TW',
45
- 'ZH-CN' => 'zh_CN',
46
- 'ZH' => 'zh_CN',
47
- 'BN' => 'bn_IN'
48
- }
49
- country_mappings[normal] || normal
50
- end
51
- end
@@ -1,2 +0,0 @@
1
- # do not include the default locale in the URL
2
- RoutingFilter::Locale.include_default_locale = false
@@ -1,65 +0,0 @@
1
- class RemoveTranslationsFromSpreeTables < SolidusSupport::Migration[4.2]
2
- def up
3
- # Don't migrate if we still use Globalize, i.e. through spree_globalize Gem
4
- return if defined?(Globalize)
5
-
6
- %w(
7
- OptionType
8
- OptionValue
9
- ProductProperty
10
- Product
11
- Promotion
12
- Property
13
- Store
14
- Taxon
15
- Taxonomy
16
- ).each do |class_name|
17
- migrate_translation_data!(class_name)
18
- end
19
- end
20
-
21
- def down
22
- return if defined?(Globalize)
23
- raise ActiveRecord::IrreversibleMigration
24
- end
25
-
26
- private
27
-
28
- def current_locale
29
- I18n.default_locale || 'en'
30
- end
31
-
32
- def migrate_translation_data!(class_name)
33
- klass = "Spree::#{class_name}".constantize
34
- table_name = klass.table_name
35
- singular_table_name = table_name.singularize
36
-
37
- return if !table_exists?(table_name) || !table_exists?("#{singular_table_name}_translations")
38
-
39
- # We can't rely on Globalize drop_translation_table! here,
40
- # because the Gem has been already removed, so we need to run custom SQL
41
- records = exec_query("SELECT * FROM #{singular_table_name}_translations WHERE locale = '#{current_locale}';")
42
-
43
- records.each do |record|
44
- id = record["#{singular_table_name}_id"]
45
- attributes = record.except(
46
- 'id',
47
- "#{singular_table_name}_id",
48
- 'locale',
49
- 'deleted_at',
50
- 'created_at',
51
- 'updated_at'
52
- )
53
- object = if klass.respond_to?(:with_deleted)
54
- klass.with_deleted.find(id)
55
- else
56
- klass.find(id)
57
- end
58
- object.update_columns(attributes)
59
- end
60
-
61
- say "Migrated #{current_locale} translation for #{class_name} back into original table."
62
-
63
- drop_table "#{singular_table_name}_translations"
64
- end
65
- end
@@ -1,9 +0,0 @@
1
- module SolidusI18n
2
- class Configuration < Spree::Preferences::Configuration
3
- # These configs intend to, respectively:
4
- #
5
- # Set locales that should be available for end users
6
- #
7
- preference :available_locales, :array, default: [:en]
8
- end
9
- end
@@ -1,29 +0,0 @@
1
- module SolidusI18n
2
- # The fact this logic is in a single module also helps to apply a custom
3
- # locale on the spree/api context since api base controller inherits from
4
- # MetalController instead of Spree::BaseController
5
- module ControllerLocaleHelper
6
- extend ActiveSupport::Concern
7
-
8
- included do
9
- prepend_before_action :set_user_language
10
-
11
- private
12
-
13
- # Overrides the Spree::Core::ControllerHelpers::Common logic so that only
14
- # supported locales defined by SolidusI18n::Config.supported_locales can
15
- # actually be set
16
- def set_user_language
17
- # params[:locale] can be added by routing-filter gem
18
- I18n.locale = \
19
- if params[:locale] && Config.available_locales.include?(params[:locale].to_sym)
20
- params[:locale]
21
- elsif respond_to?(:config_locale, true) && !config_locale.blank?
22
- config_locale
23
- else
24
- Rails.application.config.i18n.default_locale || I18n.default_locale
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,13 +0,0 @@
1
- module SolidusI18n
2
- class Locale
3
- class << self
4
- def all
5
- Dir["#{dir}/*.yml"].map { |f| File.basename(f, '.yml').to_sym }
6
- end
7
-
8
- def dir
9
- File.join(File.dirname(__FILE__), '/../../config/locales')
10
- end
11
- end
12
- end
13
- end
@@ -1,24 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Spree::HomeController, type: :controller do
4
- routes { Spree::Core::Engine.routes }
5
-
6
- before do
7
- reset_spree_preferences
8
- SolidusI18n::Config.available_locales = [:en, :es]
9
- end
10
-
11
- context 'tries not supported fr locale' do
12
- it 'falls back do default locale' do
13
- get :index, params: { locale: 'fr' }
14
- expect(I18n.locale).to eq :en
15
- end
16
- end
17
-
18
- context 'tries supported es locale' do
19
- it 'takes this locale' do
20
- get :index, params: { locale: 'es' }
21
- expect(I18n.locale).to eq :es
22
- end
23
- end
24
- end
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.feature 'Translations', :js do
4
- stub_authorization!
5
-
6
- given!(:store) { create(:store) }
7
-
8
- background do
9
- reset_spree_preferences
10
- end
11
-
12
- context 'localization settings' do
13
- given(:language) { Spree.t(:this_file_language, scope: 'i18n', locale: 'de') }
14
- given(:french) { Spree.t(:this_file_language, scope: 'i18n', locale: 'fr') }
15
-
16
- background do
17
- SolidusI18n::Config.available_locales = []
18
- visit spree.edit_admin_general_settings_path
19
- click_on "Locales"
20
- end
21
-
22
- scenario 'adds german to available locales' do
23
- targetted_select2_search(language, from: '#s2id_available_locales_')
24
- click_on 'Update'
25
- expect(SolidusI18n::Config.available_locales).to include(:de)
26
- end
27
-
28
- scenario 'adds french to available locales' do
29
- targetted_select2_search(french, from: '#s2id_available_locales_')
30
- click_on 'Update'
31
- expect(SolidusI18n::Config.available_locales).to include(:fr)
32
- end
33
- end
34
- end
@@ -1,17 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- RSpec.describe 'Russian errors translations' do
5
- def translation(count)
6
- Spree.t(:errors_prohibited_this_record_from_being_saved, count: count)
7
- end
8
-
9
- context 'when current locale is Russian' do
10
- it 'translation is available' do
11
- I18n.locale = :ru
12
- expect(translation(1)).to eq 'Одна ошибка не позволяет сохранить запись в базе'
13
- expect(translation(3)).to eq '3 ошибки не позволяют сохранить запись в базе'
14
- expect(translation(10)).to eq '10 ошибок не позволяют сохранить запись в базе'
15
- end
16
- end
17
- end
@@ -1,31 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- RSpec.describe 'Translation' do
5
- def translation
6
- I18n.t('activerecord.attributes.spree/address.zipcode')
7
- end
8
-
9
- context 'when current locale is en' do
10
- it 'translation is available' do
11
- I18n.locale = :en
12
- expect(translation).to eq 'Zip Code'
13
- end
14
- end
15
-
16
- # German is chosen as an example of language whose translations are found in a file.
17
- context 'when current locale is German' do
18
- it 'translation is available' do
19
- I18n.locale = :de
20
- expect(translation).to eq 'PLZ'
21
- end
22
- end
23
-
24
- # Chilean spanish is chosen
25
- context 'when current locale is Chilean Spanish' do
26
- it 'translation is available' do
27
- I18n.locale = :'es-CL'
28
- expect(translation).to eq 'Código Postal'
29
- end
30
- end
31
- end
@@ -1,28 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- RSpec.feature 'Translations', :js do
5
- given(:language) { Spree.t(:this_file_language, scope: 'i18n', locale: 'pt-BR') }
6
-
7
- background do
8
- reset_spree_preferences
9
- SolidusI18n::Config.available_locales = [:en, :'pt-BR']
10
- end
11
-
12
- context 'page' do
13
- context 'switches locale from the dropdown' do
14
- before do
15
- visit spree.root_path
16
- select(language, from: Spree.t(:language, scope: 'i18n'))
17
- end
18
-
19
- scenario 'selected translation is applied' do
20
- expect(page).to have_content(/#{Spree.t(:home, locale: 'pt-BR')}/i)
21
- end
22
-
23
- scenario 'JS cart link is translated' do
24
- expect(page).to have_content(/#{Spree.t(:cart, locale: 'pt-BR')}/i)
25
- end
26
- end
27
- end
28
- end
@@ -1,11 +0,0 @@
1
- require 'capybara/rspec'
2
- require 'capybara/rails'
3
- require 'capybara/poltergeist'
4
-
5
- RSpec.configure do
6
- Capybara.javascript_driver = :poltergeist
7
-
8
- Capybara.register_driver(:poltergeist) do |app|
9
- Capybara::Poltergeist::Driver.new app, timeout: 90
10
- end
11
- end
@@ -1,23 +0,0 @@
1
- require 'database_cleaner'
2
-
3
- RSpec.configure do |config|
4
- config.before(:suite) do
5
- DatabaseCleaner.clean_with :truncation
6
- end
7
-
8
- config.before do
9
- DatabaseCleaner.strategy = :transaction
10
- end
11
-
12
- config.before(:each, :js) do
13
- DatabaseCleaner.strategy = :truncation
14
- end
15
-
16
- config.before do
17
- DatabaseCleaner.start
18
- end
19
-
20
- config.after do
21
- DatabaseCleaner.clean
22
- end
23
- end
@@ -1,5 +0,0 @@
1
- require 'factory_bot'
2
-
3
- RSpec.configure do |config|
4
- config.include FactoryBot::Syntax::Methods
5
- end
data/spec/support/i18n.rb DELETED
@@ -1,5 +0,0 @@
1
- RSpec.configure do |config|
2
- config.before do
3
- I18n.locale = I18n.default_locale
4
- end
5
- end
@@ -1,12 +0,0 @@
1
- require 'spree/testing_support/factories'
2
- require 'spree/testing_support/preferences'
3
- require 'spree/testing_support/url_helpers'
4
- require 'spree/testing_support/capybara_ext'
5
- require 'spree/testing_support/controller_requests'
6
- require 'spree/testing_support/authorization_helpers'
7
-
8
- RSpec.configure do |config|
9
- config.include Spree::TestingSupport::UrlHelpers
10
- config.include Spree::TestingSupport::Preferences
11
- config.include Spree::TestingSupport::ControllerRequests, type: :controller
12
- end