Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,8 @@ GEM
net-smtp (0.3.3)
net-protocol
nio4r (2.5.9)
nokogiri (1.14.5-arm64-darwin)
racc (~> 1.4)
nokogiri (1.14.5-x86_64-linux)
racc (~> 1.4)
oauth (1.1.0)
Expand Down Expand Up @@ -799,6 +801,7 @@ GEM
zeitwerk (2.6.11)

PLATFORMS
arm64-darwin-22
x86_64-linux

DEPENDENCIES
Expand Down
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
16 changes: 16 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,22 @@
end
end

context "when the translation query raises ActiveRecord::StatementInvalid" do
it "returns and empty result" do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you mean an, not and

allow(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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you mean an, not and

allow(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