Skip to content

Commit

Permalink
Deprecate passing a String to render_elements from_page
Browse files Browse the repository at this point in the history
Passing a String to `render_elements` `from_page` option will
not be supported anymore in Alchemy 6. Please load the page
beforehand and pass it as object instead.
  • Loading branch information
tvdeyen committed Dec 21, 2020
1 parent 61f9f73 commit 56061e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
3 changes: 3 additions & 0 deletions lib/alchemy/elements_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ def get_page(page_or_layout)
when Alchemy::Page
page_or_layout
when String
Alchemy::Deprecation.warn "Passing a String as `from_page` option to " \
"`render_elements` is deprecated and will be removed with Alchemy 6.0. " \
"Please load the page beforehand and pass it as an object instead."
Alchemy::Page.find_by(
language: Alchemy::Language.current,
page_layout: page_or_layout,
Expand Down
20 changes: 0 additions & 20 deletions spec/libraries/elements_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,25 +149,5 @@
end
end
end

context "with page layout name given as options[:from_page]" do
subject { finder.elements(page: "standard") }

let(:page) { create(:alchemy_page, :public, page_layout: "standard") }
let!(:visible_element) { create(:alchemy_element, public: true, page: page) }
let!(:hidden_element) { create(:alchemy_element, public: false, page: page) }

it "returns all public elements from page with given page layout" do
is_expected.to eq([visible_element])
end

context "that is not found" do
subject { finder.elements(page: "foobaz") }

it "returns empty active record relation" do
is_expected.to eq(Alchemy::Element.none)
end
end
end
end
end

0 comments on commit 56061e7

Please sign in to comment.