File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ def definition
8383 definition = PageDefinition . get ( page_layout )
8484 if definition . nil?
8585 log_warning "Page definition for `#{ page_layout } ` not found. Please check `page_layouts.yml` file."
86- return PageDefinition . new ( name : page_layout )
86+ return PageDefinition . new
8787 end
8888 definition
8989 end
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ class PageDefinition
2828 }
2929
3030 delegate :[] , to : :attributes
31+ delegate :blank? , to : :name
3132
3233 class << self
3334 # Returns all page layouts.
Original file line number Diff line number Diff line change @@ -22,6 +22,22 @@ module Alchemy
2222 it { is_expected . to have_key ( :hint ) }
2323 end
2424
25+ describe "#blank?" do
26+ subject { definition . blank? }
27+
28+ context "with name given" do
29+ let ( :definition ) { described_class . new ( name : "standard" ) }
30+
31+ it { is_expected . to be ( false ) }
32+ end
33+
34+ context "without name given" do
35+ let ( :definition ) { described_class . new }
36+
37+ it { is_expected . to be ( true ) }
38+ end
39+ end
40+
2541 describe "validations" do
2642 it { is_expected . to validate_presence_of ( :name ) }
2743 end
Original file line number Diff line number Diff line change @@ -1214,20 +1214,22 @@ module Alchemy
12141214 context "if the page layout could not be found in the definition file" do
12151215 let ( :page ) { build_stubbed ( :alchemy_page , page_layout : "notexisting" ) }
12161216
1217- it "it loggs a warning." do
1217+ it "it logs a warning." do
12181218 expect ( Alchemy ::Logger ) . to receive ( :warn )
12191219 page . definition
12201220 end
12211221
1222- it "it returns empty hash ." do
1222+ it "it returns empty definition ." do
12231223 expect ( page . definition ) . to be_an ( Alchemy ::PageDefinition )
1224- expect ( page . definition . name ) . to eq ( "notexisting" )
1224+ expect ( page . definition . name ) . to be_nil
12251225 end
12261226 end
12271227
1228- context "for a language root page" do
1229- it "it returns the page layout definition as hash." do
1230- expect ( language_root . definition . name ) . to eq ( "index" )
1228+ context "for a page with existing definition" do
1229+ let ( :page ) { build_stubbed ( :alchemy_page ) }
1230+
1231+ it "it returns the page layout definition." do
1232+ expect ( page . definition . name ) . to eq ( "standard" )
12311233 end
12321234 end
12331235 end
You can’t perform that action at this time.
0 commit comments