Allow direct access to draft and scheduled posts by slug
This commit is contained in:
@@ -125,10 +125,14 @@ defmodule Blogex.BlogTest do
|
||||
end
|
||||
end
|
||||
|
||||
test "raises for draft post id", %{blog: blog} do
|
||||
assert_raise Blogex.NotFoundError, fn ->
|
||||
blog.get_post!("draft-post")
|
||||
end
|
||||
test "returns a future-dated published post by slug", %{blog: blog} do
|
||||
post = blog.get_post!("future-post")
|
||||
assert post.id == "future-post"
|
||||
end
|
||||
|
||||
test "returns a draft post by slug", %{blog: blog} do
|
||||
post = blog.get_post!("draft-post")
|
||||
assert post.id == "draft-post"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -136,6 +140,14 @@ defmodule Blogex.BlogTest do
|
||||
test "returns nil for unknown id", %{blog: blog} do
|
||||
assert blog.get_post("nope") == nil
|
||||
end
|
||||
|
||||
test "returns a future-dated post", %{blog: blog} do
|
||||
assert %{id: "future-post"} = blog.get_post("future-post")
|
||||
end
|
||||
|
||||
test "returns a draft post", %{blog: blog} do
|
||||
assert %{id: "draft-post"} = blog.get_post("draft-post")
|
||||
end
|
||||
end
|
||||
|
||||
describe "paginate/2" do
|
||||
|
||||
@@ -70,10 +70,10 @@ defmodule Blogex.RouterTest do
|
||||
assert conn.status == 404
|
||||
end
|
||||
|
||||
test "returns 404 for draft post" do
|
||||
test "returns 200 for draft post accessed by slug" do
|
||||
conn = call(:get, "/draft")
|
||||
|
||||
assert conn.status == 404
|
||||
assert conn.status == 200
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user