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.
63 lines
1.8 KiB
Ruby
63 lines
1.8 KiB
Ruby
require "rails_helper"
|
|
|
|
describe Admin::MenuComponent, controller: Admin::NewslettersController do
|
|
it "disables all buttons when JavaScript isn't available" do
|
|
render_inline Admin::MenuComponent.new
|
|
|
|
expect(page).to have_button disabled: true
|
|
expect(page).not_to have_button disabled: false
|
|
end
|
|
|
|
it "expands the current section" do
|
|
render_inline Admin::MenuComponent.new
|
|
|
|
expect(page).to have_css "button[aria-expanded='true']", exact_text: "Messages to users"
|
|
end
|
|
|
|
it "does not expand other sections" do
|
|
render_inline Admin::MenuComponent.new
|
|
|
|
expect(page).to have_css "button[aria-expanded='false']", exact_text: "Settings"
|
|
end
|
|
|
|
describe "#polls_link" do
|
|
it "is marked as current when managing poll options",
|
|
controller: Admin::Poll::Questions::OptionsController do
|
|
render_inline Admin::MenuComponent.new
|
|
|
|
expect(page).to have_css "[aria-current]", exact_text: "Polls"
|
|
end
|
|
|
|
it "is marked as current when managing poll options content",
|
|
controller: Admin::Poll::Questions::Options::VideosController do
|
|
render_inline Admin::MenuComponent.new
|
|
|
|
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
|