Skip to content

Fix to rescue ActiveRecord::ConnectionNotEstablished in available_locales - #134

Open
takahashim wants to merge 1 commit into
mainio:mainfrom
takahashim:fix-rescue-ConnectionNotEstablished
Open

takahashim wants to merge 1 commit into
mainio:mainfrom
takahashim:fix-rescue-ConnectionNotEstablished

Conversation

@takahashim

Copy link
Copy Markdown
Contributor

Fixes #133

@takahashim
takahashim marked this pull request as ready for review August 8, 2026 17:19
@takahashim

Copy link
Copy Markdown
Contributor Author

I'm not sure why the test is failing, but the i18n_backend_spec.rb pass in my local development environment, as shown below:

$ bundle exec rspec spec/lib/decidim/term_customizer/i18n_backend_spec.rb

Randomized with seed 21223

Decidim::TermCustomizer::I18nBackend
  #translations
    returns the correct translations list
  #translate
    calls lookup
    with actual translations
      translates the translation keys correctly
    with plural forms
      translates the translation keys correctly
  #initialized?
    when translations are loaded
      returns true
    when translations are not loaded
      returns false
  #available_locales
    when translations are available
      returns an empty result
    when the translation query raises ActiveRecord::ConnectionNotEstablished
      returns an empty result
    when the translation query raises ActiveRecord::StatementInvalid
      returns and empty result
    when no translations are available
      returns an empty result
  #reload!
    resets the translations

Top 10 slowest examples (2.19 seconds, 16.7% of total time):
  Decidim::TermCustomizer::I18nBackend#available_locales when translations are available returns an empty result
    1.24 seconds ./spec/lib/decidim/term_customizer/i18n_backend_spec.rb:65
  Decidim::TermCustomizer::I18nBackend#translate with plural forms translates the translation keys correctly
    0.92439 seconds ./spec/lib/decidim/term_customizer/i18n_backend_spec.rb:175
  Decidim::TermCustomizer::I18nBackend#translations returns the correct translations list
    0.02311 seconds ./spec/lib/decidim/term_customizer/i18n_backend_spec.rb:137
  Decidim::TermCustomizer::I18nBackend#available_locales when the translation query raises ActiveRecord::ConnectionNotEstablished returns an empty result
    0.00293 seconds ./spec/lib/decidim/term_customizer/i18n_backend_spec.rb:81
  Decidim::TermCustomizer::I18nBackend#initialized? when translations are loaded returns true
    0.00176 seconds ./spec/lib/decidim/term_customizer/i18n_backend_spec.rb:106
  Decidim::TermCustomizer::I18nBackend#translate calls lookup
    0.00151 seconds ./spec/lib/decidim/term_customizer/i18n_backend_spec.rb:143
  Decidim::TermCustomizer::I18nBackend#reload! resets the translations
    0.0012 seconds ./spec/lib/decidim/term_customizer/i18n_backend_spec.rb:121
  Decidim::TermCustomizer::I18nBackend#available_locales when the translation query raises ActiveRecord::StatementInvalid returns and empty result
    0.00087 seconds ./spec/lib/decidim/term_customizer/i18n_backend_spec.rb:71
  Decidim::TermCustomizer::I18nBackend#available_locales when no translations are available returns an empty result
    0.0008 seconds ./spec/lib/decidim/term_customizer/i18n_backend_spec.rb:51
  Decidim::TermCustomizer::I18nBackend#translate with actual translations translates the translation keys correctly
    0.00078 seconds ./spec/lib/decidim/term_customizer/i18n_backend_spec.rb:157

Finished in 13.14 seconds (files took 4.47 seconds to load)
11 examples, 0 failures

Randomized with seed 21223

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

I18nBackend#available_locales does not rescue ActiveRecord::ConnectionNotEstablished

1 participant