From 7b8413ae57260d28ba54a14006073511da5ea225 Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Wed, 11 Jun 2025 09:52:06 -0700 Subject: [PATCH] Add tests for posts route --- conf/nginx.conf | 2 +- spec/routes_spec.moon | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 1d06c71..c7ddbcc 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -23,7 +23,7 @@ http { # redirect requests ending in a forward slash location ~ ^/(.+)/$ { - return 302 /$1; + return 301 /$1; } location /css { diff --git a/spec/routes_spec.moon b/spec/routes_spec.moon index 58aa1e1..9c9e21f 100644 --- a/spec/routes_spec.moon +++ b/spec/routes_spec.moon @@ -48,3 +48,17 @@ describe "http://miti.sh/index.html", -> assert.same request\statusCode!, 200 assert.same request\statusMessage!, "OK" assert.same request\body!\match("(.*)"), index_title + +describe "http://miti.sh/posts/", -> + it "permanently redirects to http://miti.sh/posts", -> + request = req "http://miti.sh/posts/" + assert.same request\statusCode!, 301 + assert.same request\statusMessage!, "Moved Permanently" + assert.same request\header!.Location, "http://miti.sh/posts" + +describe "http://miti.sh/posts", -> + it "sends /posts/index.html", -> + request = req "http://miti.sh/posts" + assert.same request\statusCode!, 200 + assert.same request\statusMessage!, "OK" + assert.same request\body!\match("(.*)"), "miti.sh ยท Posts"