Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. defmodule MyApp.AbsintheSchemaTest do
  2. use MyApp.ConnCase
  3.  
  4. import MyApp.Factories
  5.  
  6.  
  7. @query """
  8. query($id: ID) {
  9. user(id: $id) {
  10. name
  11. email
  12.  
  13. post {
  14. content
  15. }
  16. }
  17. """
  18. test "post field returns post content when the user has access to it" do
  19. user = insert(:user)
  20. post = insert(:post, user: user)
  21.  
  22. conn = build_conn()
  23. conn = get(conn, "/gql", query: @query, variables: %{"id" => post.id})
  24.  
  25. assert json_response(conn, 200) == %{
  26. "data" => %{
  27. "user" => %{
  28. "name" => user.name,
  29. "email" => user.email,
  30. "post" => %{
  31. "content" => post.content
  32. }
  33. }
  34. }
  35. }
  36. end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement