Hide languages link when there's only one language
Most existing Consul Democracy installations will have changed their `config.i18n.available_locales` option so only a few locales are available. In many cases, only one locale will be available. In these cases, rendering a form that only offers one option is useless. We've considered adding a text in this case mentioning that, in order to enable more languages, they need to configure their `config.i18n.available_locales`. However, we haven't done it for two reasons. First, if they've changed the available locales to just one, there's a good chance they aren't interested at all in configuring the locales. And, second, if there's only one available locale, administrators will learn to ignore the "languages" link, so they won't realize that locales can be configured if developers change the available locales. If we hide the link, on the other hand, they will notice that locales can now be configured once developers change the available locales. Note we're still allowing access by entering the URL. This is harmless, though, since people accessing it this way will see a form with only one possible option and won't be able to modify anything.
This commit is contained in:
@@ -35,4 +35,28 @@ describe Admin::MenuComponent, controller: Admin::NewslettersController do
|
||||
expect(page).to have_css "[aria-current]", exact_text: "Polls"
|
||||
end
|
||||
end
|
||||
|
||||
describe "#locales_link" do
|
||||
it "is present when two or more locales are available" do
|
||||
render_inline Admin::MenuComponent.new
|
||||
|
||||
expect(page).to have_link "Languages"
|
||||
end
|
||||
|
||||
it "is present when two or more locales are available but only one is enabled" do
|
||||
Setting["locales.enabled"] = "en"
|
||||
|
||||
render_inline Admin::MenuComponent.new
|
||||
|
||||
expect(page).to have_link "Languages"
|
||||
end
|
||||
|
||||
it "is not present when only one locale is available" do
|
||||
allow(I18n).to receive(:available_locales).and_return([:en])
|
||||
|
||||
render_inline Admin::MenuComponent.new
|
||||
|
||||
expect(page).not_to have_link "Languages"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user