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.
This commit is contained in:
taitus
2020-01-23 16:39:44 +01:00
parent d853366d38
commit 2f500a6b56
2 changed files with 9 additions and 1 deletions

View File

@@ -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)

View File

@@ -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