File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed
Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ module ElementsHelper
7272 #
7373 def render_elements ( options = { } , &blk )
7474 options = {
75- from_page : Current . page ,
75+ from_page : Current . page || @page ,
7676 render_format : "html"
7777 } . update ( options )
7878
Original file line number Diff line number Diff line change @@ -75,9 +75,30 @@ module Alchemy
7575 context "without any options" do
7676 let ( :options ) { { } }
7777
78- it "should render all elements from current pages public version." do
79- is_expected . to have_selector ( "##{ element . dom_id } " )
80- is_expected . to have_selector ( "##{ another_element . dom_id } " )
78+ context "with Current.page set" do
79+ before { Current . page = page }
80+
81+ it "should render all elements from current pages public version." do
82+ is_expected . to have_selector ( "##{ element . dom_id } " )
83+ is_expected . to have_selector ( "##{ another_element . dom_id } " )
84+ end
85+ end
86+
87+ context "with Current.page not set" do
88+ before { Current . page = nil }
89+
90+ it "should not render any elements." do
91+ is_expected . to be_empty
92+ end
93+
94+ context "but with @page set" do
95+ before { helper . instance_variable_set ( :@page , page ) }
96+
97+ it "should render all elements from current pages public version." do
98+ is_expected . to have_selector ( "##{ element . dom_id } " )
99+ is_expected . to have_selector ( "##{ another_element . dom_id } " )
100+ end
101+ end
81102 end
82103
83104 context "in preview_mode" do
You can’t perform that action at this time.
0 commit comments