Skip to content

Commit

Permalink
Fix precompile on docker
Browse files Browse the repository at this point in the history
  • Loading branch information
armandfardeau committed Jun 19, 2023
1 parent 5ca4cc4 commit 228a491
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/decidim/term_customizer/i18n_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Implementation
# Get available locales from the translations hash
def available_locales
Translation.available_locales
rescue ::ActiveRecord::StatementInvalid
rescue ::ActiveRecord::StatementInvalid, ::ActiveRecord::ConnectionNotEstablished, ::PG::ConnectionBad
[]
end

Expand Down
20 changes: 20 additions & 0 deletions spec/lib/decidim/term_customizer/i18n_backend_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,26 @@
end
end

context "when the translation query raises ActiveRecord::StatementInvalid" do
it "returns and empty result" do
expect(Decidim::TermCustomizer::Translation).to receive(
:available_locales
).and_raise(ActiveRecord::ConnectionNotEstablished)

expect(subject.available_locales).to be_empty
end
end

context "when there is no database connection" do
it "returns and empty result" do
expect(Decidim::TermCustomizer::Translation).to receive(
:available_locales
).and_raise(PG::ConnectionBad)

expect(subject.available_locales).to be_empty
end
end

describe "#initialized?" do
context "when translations are not loaded" do
it "returns false" do
Expand Down

0 comments on commit 228a491

Please sign in to comment.