Created
May 15, 2015 00:09
-
-
Save danmcclain/0ce93ff2d36372c9dc5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test "Creating a session with a GitHub code" do | |
| use_cassette "successful_sign_in" do | |
| response = conn(:post, "/api/v1/session", %{ "authorizationCode" => "dan", "format" => "json", "provider" => "github-oauth2" }) | |
| |> DoorApi.Endpoint.call([]) | |
| assert response.status == 201 | |
| assert Voorhees.matches_schema?(response.resp_body, [user: [:username, :id]]) | |
| assert Voorhees.matches_payload?(response.resp_body, %{user: %{ username: "danmcclain" } }) | |
| current_session_request = conn(:get, "/api/v1/session") | |
| current_session_response = response.cookies | |
| |> Enum.reduce(current_session_request, fn ({key, value}, conn) -> put_req_cookie(conn, key, value) end) | |
| |> DoorApi.Endpoint.call([]) | |
| assert current_session_response.status == 200 | |
| assert Voorhees.matches_schema?(current_session_response.resp_body, [user: [:username, :id]]) | |
| assert Voorhees.matches_payload?(current_session_response.resp_body, %{user: %{ username: "danmcclain" } }) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment