-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle custom CSRF header name. Fixes #14.
- Loading branch information
Showing
5 changed files
with
73 additions
and
7 deletions.
There are no files selected for viewing
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
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,9 @@ | ||
import test from "ava"; | ||
import { init } from "../../../django_unicorn/static/js/unicorn.js"; | ||
|
||
test("init unicorn", (t) => { | ||
const actual = init("unicorn/", "X-Unicorn"); | ||
|
||
t.true(actual.messageUrl === "unicorn/"); | ||
t.true(actual.csrfTokenHeaderName === "X-Unicorn"); | ||
}); |
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,38 @@ | ||
from django_unicorn.templatetags.unicorn import unicorn_scripts | ||
|
||
|
||
def test_unicorn_scripts(): | ||
actual = unicorn_scripts() | ||
|
||
assert actual["CSRF_HEADER_NAME"] == "X-CSRFTOKEN" | ||
assert actual["MINIFIED"] is True | ||
|
||
|
||
def test_unicorn_scripts_debug(settings): | ||
settings.DEBUG = True | ||
actual = unicorn_scripts() | ||
|
||
assert actual["CSRF_HEADER_NAME"] == "X-CSRFTOKEN" | ||
assert actual["MINIFIED"] is False | ||
|
||
|
||
def test_unicorn_scripts_minified_true(settings): | ||
settings.UNICORN = {"MINIFIED": True} | ||
actual = unicorn_scripts() | ||
|
||
assert actual["CSRF_HEADER_NAME"] == "X-CSRFTOKEN" | ||
assert actual["MINIFIED"] is True | ||
|
||
|
||
def test_unicorn_scripts_minified_false(settings): | ||
settings.UNICORN = {"MINIFIED": False} | ||
actual = unicorn_scripts() | ||
|
||
assert actual["MINIFIED"] is False | ||
|
||
|
||
def test_unicorn_scripts_csrf_header_name(settings): | ||
settings.CSRF_HEADER_NAME = "HTTP_X_UNICORN" | ||
actual = unicorn_scripts() | ||
|
||
assert actual["CSRF_HEADER_NAME"] == "X-UNICORN" |