-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move these two plugs with their other friends. Note that this commit introduces a backwards incompatible change: it renames the `PlugResponseContentType` to `ResponseContentType`.
- Loading branch information
Showing
3 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
lib/jsonapi/plug.ex → lib/jsonapi/plugs/response_content_type.ex
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
defmodule JSONAPI.ResponseContentTypeTest do | ||
use ExUnit.Case | ||
use Plug.Test | ||
|
||
alias JSONAPI.ResponseContentType | ||
|
||
test "sets response content type" do | ||
conn = | ||
:get | ||
|> conn("/example", "") | ||
|> ResponseContentType.call([]) | ||
|> send_resp(200, "done") | ||
|
||
assert get_resp_header(conn, "content-type") == ["application/vnd.api+json; charset=utf-8"] | ||
end | ||
|
||
test "can be overridden when in play" do | ||
conn = | ||
:get | ||
|> conn("/example", "") | ||
|> Plug.Conn.assign(:override_jsonapi, true) | ||
|> ResponseContentType.call([]) | ||
|> send_resp(200, "done") | ||
|
||
refute get_resp_header(conn, "content-type") == ["application/vnd.api+json; charset=utf-8"] | ||
end | ||
end |