Add buttons to check all/none available languages

Although most Consul Democracy installations will only have a few
available languages using `config.i18n.available_locales`, there's a
chance some installation will keep every language as available and will
enable the desired ones using the admin interface. In these cases,
enabling (or disabling) every language would be tedious, particularly
when casually experimenting in a staging environment or while using the
official Consul Democracy demo.

So we're adding buttons to simplify the process. Since some
installations might have only a couple of available languages, and in
this case these buttons would be pretty much useless, we're only showing
them when there are many languages available.
This commit is contained in:
Javi Martín
2024-04-12 03:34:22 +02:00
parent a911b0dec7
commit c367f21705
8 changed files with 118 additions and 13 deletions

View File

@@ -51,4 +51,22 @@ describe "Locales management", :admin do
expect(page).not_to have_link "English"
end
end
scenario "select all/none" do
allow_any_instance_of(Admin::Locales::FormComponent).to receive(:many_available_locales?).and_return(true)
visit admin_locales_path
within_fieldset "Enabled languages" do
expect(page).to have_field type: :checkbox
click_button "Select all"
expect(all(:checkbox)).to all(be_checked)
click_button "Select none"
all(:checkbox).each { |checkbox| expect(checkbox).not_to be_checked }
end
end
end