Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix and deprecate page_active? helper #2073

Merged
merged 1 commit into from Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/helpers/alchemy/pages_helper.rb
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? helper 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
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