test/render.rb in cuba-3.1.0 vs test/render.rb in cuba-3.1.1
- old
+ new
@@ -56,10 +56,18 @@
_, _, body = Cuba.call({ "PATH_INFO" => "/home", "SCRIPT_NAME" => "/" })
assert_response body, ["<title>Cuba: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>\n\n"]
end
+
+ test "custom default layout support" do
+ Cuba.settings[:render][:layout] = "layout-alternative"
+
+ _, _, body = Cuba.call({ "PATH_INFO" => "/home", "SCRIPT_NAME" => "/" })
+
+ assert_response body, ["<title>Alternative Layout: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>\n"]
+ end
end
test "caching behavior" do
Thread.current[:_cache] = nil
@@ -91,6 +99,21 @@
end
_, _, resp = Cuba.call({})
assert_response resp, ["Header\nThis is the actual content.\nFooter\n"]
+end
+
+test "overrides layout" do
+ Cuba.plugin Cuba::Render
+ Cuba.settings[:render][:views] = "./test/views"
+
+ Cuba.define do
+ on true do
+ res.write view("home", { name: "Agent Smith", title: "Home" }, "layout-alternative")
+ end
+ end
+
+ _, _, body = Cuba.call({})
+
+ assert_response body, ["<title>Alternative Layout: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>\n"]
end