test/unit/test_context.rb in spontaneous-0.2.0.beta5 vs test/unit/test_context.rb in spontaneous-0.2.0.beta6
- old
+ new
@@ -107,11 +107,11 @@
@context = @context_class.new(@target)
result = @context.navigation(boxes: [:area1]).map { |p, a| [p.path, a]}
result.must_equal [["/area1-page1", false], ["/area1-page2", true]]
end
- it "allows for limiting the navigation to a particular box" do
+ it "allows for excluding a particular box" do
@target = Page.new
@area1_page2.area2 << @target
@target.save.reload
@context = @context_class.new(@target)
result = @context.navigation(except: :area2).map { |p, a| [p.path, a]}
@@ -132,8 +132,35 @@
@area1_page2.area2 << @target
@target.save.reload
@context = @context_class.new(@target)
result = @context.navigation(exclude: Page).map { |p, a| [p.path, a]}
result.must_equal [["/area1-page2", true], ["/area2-page2", false]]
+ end
+
+ it "shows children of the public root when rendering a private root" do
+ @target = Page.create_root "error"
+ @context = @context_class.new(@target)
+ result = @context.navigation.map { |p, a| [p.path, a]}
+ result.must_equal [["/area1-page1", false], ["/area1-page2", false], ["/area2-page1", false], ["/area2-page2", false]]
+ end
+
+ it "shows children of the public root when rendering a private page" do
+ root = Page.create_root "error"
+ @target = Page.new
+ root.area2 << @target
+ @target.save.reload
+ @context = @context_class.new(@target)
+ result = @context.navigation.map { |p, a| [p.path, a]}
+ result.must_equal [["/area1-page1", false], ["/area1-page2", false], ["/area2-page1", false], ["/area2-page2", false]]
+ end
+
+ it "doesn't throw errors when attempting to render from a non-existant parent" do
+ root = Page.create_root "error"
+ @target = Page.new
+ root.area2 << @target
+ @target.save.reload
+ @context = @context_class.new(@target)
+ result = @context.navigation(depth: 2).map { |p, a| [p.path, a]}
+ result.must_equal []
end
end
end
\ No newline at end of file