Add validation to check translations amount on updates

In order to not allow users to remove all persited
translations from any resource. A few exceptions were
added:

* Does not apply to globalizable models without
   translatable attributes required
* Make a copy of main model error on current translations to be more realistic
This commit is contained in:
Senén Rodero Rodríguez
2019-06-07 16:45:14 +02:00
parent 12d20b481d
commit d3422acbb7
4 changed files with 55 additions and 0 deletions

View File

@@ -236,6 +236,19 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t
expect_not_to_have_language "Español"
end
scenario "Remove all translations should show an error message", :js do
skip("can't have invalid translations") if required_fields.empty?
visit path
click_link "Remove language"
click_link "Remove language"
click_button update_button_text
expect(page).to have_content "Is mandatory to provide one translation at least"
end
scenario "Remove a translation with invalid data", :js do
skip("can't have invalid translations") if required_fields.empty?