More detailed notification when setup is not completed (#10375)

This commit is contained in:
Anna Buianova 2020-09-18 16:24:49 +03:00 committed by GitHub
parent b24c96010d
commit fec947ce45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View file

@ -28,7 +28,11 @@ module VerifySetupCompleted
end
def setup_completed?
MANDATORY_CONFIGS.all? { |config| SiteConfig.public_send(config).present? }
missing_configs.empty?
end
def missing_configs
MANDATORY_CONFIGS.reject { |config| SiteConfig.public_send(config).present? }
end
private
@ -37,8 +41,9 @@ module VerifySetupCompleted
return if config_path? || setup_completed? || SiteConfig.waiting_on_first_user
link = helpers.link_to("the configuration page", admin_config_path, "data-no-instant" => true)
missing_configs_text = missing_configs.map { |c| c.to_s.tr("_", " ") }.join(", ")
# rubocop:disable Rails/OutputSafety
flash[:global_notice] = "Setup not completed yet, please visit #{link}.".html_safe
flash[:global_notice] = "Setup not completed yet, missing #{missing_configs_text}. Please visit #{link}.".html_safe
# rubocop:enable Rails/OutputSafety
end

View file

@ -20,13 +20,19 @@ RSpec.describe "Admin manages configuration", type: :system do
context "when mandatory options are missing" do
it "does not show the banner on the config page" do
allow(SiteConfig).to receive(:tagline).and_return(nil)
expect(page).not_to have_content("Setup not completed yet, please visit the configuration page.")
expect(page).not_to have_content("Setup not completed yet")
end
it "does show the banner on other pages" do
allow(SiteConfig).to receive(:tagline).and_return(nil)
visit root_path
expect(page).to have_content("Setup not completed yet, please visit the configuration page.")
expect(page).to have_content("Setup not completed yet")
end
it "includes information about missing fields on the config pages" do
allow(SiteConfig).to receive(:tagline).and_return(nil)
visit root_path
expect(page.body).to match(/Setup not completed yet, missing(.*)tagline/)
end
end
end