Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass a variable that is needed to template #335

Merged
merged 1 commit into from Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/tilex_web/controllers/post_controller.ex
Expand Up @@ -171,7 +171,7 @@ defmodule TilexWeb.PostController do
|> redirect(to: post_path(conn, :show, post))

{:error, changeset} ->
render(conn, "edit.html", post: post, changeset: changeset)
render(conn, "edit.html", post: post, changeset: changeset, current_user: current_user)
end
end

Expand Down
23 changes: 23 additions & 0 deletions test/features/admin_edits_post_test.exs
Expand Up @@ -30,4 +30,27 @@ defmodule AdminEditsPostTest do
session
|> PostShowPage.ensure_page_loaded("Even Awesomer Post!")
end

test "enters a title that is too long", %{session: session} do
Factory.insert!(:channel, name: "phoenix")
developer = Factory.insert!(:developer)

post =
Factory.insert!(
:post,
title: "Limited characters",
developer: developer,
body: "Bugs revealed"
)

session
|> sign_in(developer)
|> PostForm.navigate(post)
|> PostForm.ensure_page_loaded()
|> PostForm.fill_in_title(String.duplicate("I can codez ", 10))
|> PostForm.click_submit()

session
|> PostForm.expect_form_has_error("Title should be at most 50 character(s)")
end
end
7 changes: 7 additions & 0 deletions test/support/pages/post_form.ex
Expand Up @@ -70,4 +70,11 @@ defmodule Tilex.Integration.Pages.PostForm do
session
|> click(Query.button("Submit"))
end

def expect_form_has_error(session, error_text) do
session
|> assert_has(Query.css("form", text: error_text))

session
end
end