diff --git a/app/helpers/alchemy/pages_helper.rb b/app/helpers/alchemy/pages_helper.rb index ce0c7256b8..8888330668 100644 --- a/app/helpers/alchemy/pages_helper.rb +++ b/app/helpers/alchemy/pages_helper.rb @@ -91,11 +91,15 @@ def render_menu(menu_type, options = {}) end render("alchemy/menus/#{menu_type}/wrapper", menu: root_node, options: options) - rescue ActionView::MissingTemplate => e - warning <<~WARN - Menu partial not found for #{menu_type}. - #{e} - WARN + rescue ActionView::MissingTemplate => error + if Rails.application.config.consider_all_requests_local? + raise error + else + warning <<~WARN + Menu partial not found for #{menu_type}. + #{error} + WARN + end end # Returns page links in a breadcrumb beginning from root to current page. diff --git a/spec/helpers/alchemy/pages_helper_spec.rb b/spec/helpers/alchemy/pages_helper_spec.rb index 84450090e8..ece3f0e106 100644 --- a/spec/helpers/alchemy/pages_helper_spec.rb +++ b/spec/helpers/alchemy/pages_helper_spec.rb @@ -79,7 +79,17 @@ module Alchemy context "but the template does not exist" do let(:menu_type) { "unknown" } - it { is_expected.to be_nil } + context "in production environment" do + before { allow(Rails.application.config).to receive(:consider_all_requests_local?).and_return(false) } + + it { is_expected.to be_nil } + end + + context "in dev or test environment" do + before { allow(Rails.application.config).to receive(:consider_all_requests_local?).and_return(true) } + + it { expect { subject }.to raise_error(ActionView::MissingTemplate) } + end end end