Skip to content

Commit

Permalink
hotfix and deprecate page_active? helper
Browse files Browse the repository at this point in the history
The `page_active?` helper used to depend on `Page.ancestors_for` which got removed with AlchemyCMS#1813. This PR hotfixes `page_active?`, but since menus got introduced with AlchemyCMS#1667 the helper is obsolete and is now marked for deletion.
  • Loading branch information
robinboening committed Apr 19, 2021
1 parent ed99394 commit 611779c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/helpers/alchemy/pages_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ def render_menu(menu_type, options = {})

# Returns true if page is in the active branch
def page_active?(page)
@_page_ancestors ||= Page.ancestors_for(@page)
Alchemy::Deprecation.warn("page_active? is deprecated and will be removed from Alchemy 6.0")

@_page_ancestors ||= @page.self_and_ancestors.contentpages
@_page_ancestors.include?(page)
end

Expand Down
8 changes: 8 additions & 0 deletions spec/helpers/alchemy/pages_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ module Alchemy
@root_page = language_root # We need this instance variable in the helpers
end

describe "page_active?" do
it "shows a deprecation warning" do
@page = public_page
expect(Alchemy::Deprecation).to receive(:warn).with /will be removed from Alchemy 6/
helper.page_active?(public_page)
end
end

describe "#render_page_layout" do
it "should render the current page layout" do
@page = public_page
Expand Down

0 comments on commit 611779c

Please sign in to comment.