diff --git a/app/helpers/alchemy/pages_helper.rb b/app/helpers/alchemy/pages_helper.rb index f1ffa60f7d..2cdd0215ae 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.env.production? + warning <<~WARN + Menu partial not found for #{menu_type}. + #{error} + WARN + else + raise error + 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 c2b96019b3..427c1b5f55 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.env).to receive(:production?).and_return(true) } + + it { is_expected.to be_nil } + end + + context "in dev or test environment" do + before { allow(Rails.env).to receive(:production?).and_return(false) } + + it { expect { subject }.to raise_error(ActionView::MissingTemplate) } + end end end