From 2f500a6b56af58d1c6c6bf33d4459f785e6ccb09 Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 23 Jan 2020 16:39:44 +0100 Subject: [PATCH] Fix detect_remote_translations for Legislation::Proposal Legislation::Proposal is not Globalize model but use CommentableActions and try detect remote translations. Add new condition to discard Non Globalize models. This fix is necessary since the following commit was included: c1f3a4ad. --- app/controllers/concerns/remotely_translatable.rb | 2 +- spec/controllers/concerns/remotely_translatable_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/concerns/remotely_translatable.rb b/app/controllers/concerns/remotely_translatable.rb index 7f47f0c8f..6bbf791d1 100644 --- a/app/controllers/concerns/remotely_translatable.rb +++ b/app/controllers/concerns/remotely_translatable.rb @@ -16,7 +16,7 @@ module RemotelyTranslatable end def translation_empty?(resource) - resource.translations.where(locale: I18n.locale).empty? + resource.class.translates? && resource.translations.where(locale: I18n.locale).empty? end def resources_groups(*args) diff --git a/spec/controllers/concerns/remotely_translatable_spec.rb b/spec/controllers/concerns/remotely_translatable_spec.rb index 8320e778c..d9cd7e73e 100644 --- a/spec/controllers/concerns/remotely_translatable_spec.rb +++ b/spec/controllers/concerns/remotely_translatable_spec.rb @@ -65,5 +65,13 @@ describe RemotelyTranslatable do expect(detect_remote_translations([proposal, comment])).to eq [] end + + it "When resource class is not translatable should not detect remote_translations" do + legislation_proposal = create(:legislation_proposal) + + I18n.with_locale(:es) do + expect(detect_remote_translations([legislation_proposal])).to eq [] + end + end end end