59 lines
1.7 KiB
Elixir
59 lines
1.7 KiB
Elixir
defmodule FirehoseWeb.BlogControllerTest do
|
|
use FirehoseWeb.ConnCase, async: false
|
|
|
|
describe "GET /blog/:blog_id/:slug - status banners" do
|
|
test "authenticated user sees draft banner on draft post", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> init_test_session(%{})
|
|
|> assign(:current_user, %{id: 1})
|
|
|> get(~p"/blog/engineering/hello-world")
|
|
|
|
assert html_response(conn, 200) =~ "Draft"
|
|
assert conn.resp_body =~ "not published"
|
|
end
|
|
|
|
test "authenticated user sees scheduled banner on future post", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> init_test_session(%{})
|
|
|> assign(:current_user, %{id: 1})
|
|
|> get(~p"/blog/engineering/future-test-post")
|
|
|
|
response = html_response(conn, 200)
|
|
assert response =~ "scheduled for"
|
|
assert response =~ "January 01, 2099"
|
|
end
|
|
|
|
test "authenticated user sees no banner on live post", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> init_test_session(%{})
|
|
|> assign(:current_user, %{id: 1})
|
|
|> get(~p"/blog/engineering/why-firehose")
|
|
|
|
response = html_response(conn, 200)
|
|
refute response =~ "Draft"
|
|
refute response =~ "scheduled for"
|
|
end
|
|
|
|
test "unauthenticated user sees no banner on draft post", %{conn: conn} do
|
|
response =
|
|
conn
|
|
|> get(~p"/blog/engineering/hello-world")
|
|
|> html_response(200)
|
|
|
|
refute response =~ "post-status-banner"
|
|
end
|
|
|
|
test "unauthenticated user sees no banner on future post", %{conn: conn} do
|
|
response =
|
|
conn
|
|
|> get(~p"/blog/engineering/future-test-post")
|
|
|> html_response(200)
|
|
|
|
refute response =~ "post-status-banner"
|
|
end
|
|
end
|
|
end
|