Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions frontend/public/src/containers/App_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ describe("Top-level App", () => {
const { inner } = await renderPage()

assert.notExists(inner.find(".app").prop("children"))
sinon.assert.calledWith(helper.handleRequestStub, "/api/users/me", "GET")
sinon.assert.calledWith(
helper.handleRequestStub,
"/api/v0/users/current_user/",
"GET"
)
})

it("fetches user data on load and renders user in the header", async () => {
Expand All @@ -65,7 +69,11 @@ describe("Top-level App", () => {
const { inner } = await renderPage()
// So we look to be sure the next child is there, which is <Header />, which is not there otherwise
assert.exists(inner.find("Header"))
sinon.assert.calledWith(helper.handleRequestStub, "/api/users/me", "GET")
sinon.assert.calledWith(
helper.handleRequestStub,
"/api/v0/users/current_user/",
"GET"
)
})

it("adds a user notification if a stored message is found in cookies", async () => {
Expand Down Expand Up @@ -104,7 +112,11 @@ describe("Top-level App", () => {
})
await renderPage()
// Should call /api/users/me to get user data
sinon.assert.calledWith(helper.handleRequestStub, "/api/users/me", "GET")
sinon.assert.calledWith(
helper.handleRequestStub,
"/api/v0/users/current_user/",
"GET"
)
// Should NOT call the cart items count API for unauthenticated users
sinon.assert.neverCalledWith(
helper.handleRequestStub,
Expand Down
18 changes: 15 additions & 3 deletions frontend/public/src/containers/HeaderApp_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,22 @@ describe("Top-level HeaderApp", () => {
inner.update()
// So we look to be sure the next child is there, which is <Header />
assert.exists(inner.find("Header"))
sinon.assert.calledWith(helper.handleRequestStub, "/api/users/me", "GET")
sinon.assert.calledWith(
helper.handleRequestStub,
"/api/v0/users/current_user/",
"GET"
)
})

it("tries to fetch user data and no response or an incorrect response renders nothing", async () => {
helper.handleRequestStub.returns({})
const { inner } = await renderPage()
assert.notExists(inner.find("div").prop("children"))
sinon.assert.calledWith(helper.handleRequestStub, "/api/users/me", "GET")
sinon.assert.calledWith(
helper.handleRequestStub,
"/api/v0/users/current_user/",
"GET"
)
})

it("adds a user notification if a stored message is found in cookies", async () => {
Expand Down Expand Up @@ -98,7 +106,11 @@ describe("Top-level HeaderApp", () => {
})
await renderPage()
// Should call /api/users/me to get user data
sinon.assert.calledWith(helper.handleRequestStub, "/api/users/me", "GET")
sinon.assert.calledWith(
helper.handleRequestStub,
"/api/v0/users/current_user/",
"GET"
)
// Should NOT call the cart items count API for unauthenticated users
sinon.assert.neverCalledWith(
helper.handleRequestStub,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe("EditProfilePage", () => {
await inner.find("EditProfileForm").prop("onSubmit")(values, actions)
sinon.assert.calledWith(
helper.handleRequestStub,
"/api/users/me",
"/api/v0/users/me",
"PATCH",
{
body: values,
Expand Down
6 changes: 3 additions & 3 deletions frontend/public/src/lib/queries/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const DEFAULT_OPTIONS = {

export default {
currentUserQuery: () => ({
url: "/api/users/me",
url: "/api/v0/users/current_user/",
transform: transformCurrentUser,
update: updateResult
}),
Expand All @@ -48,7 +48,7 @@ export default {
...DEFAULT_OPTIONS,
transform: transformCurrentUser,
update: updateResult,
url: "/api/users/me",
url: "/api/v0/users/me",
body: {
...profileData
}
Expand All @@ -57,7 +57,7 @@ export default {
...DEFAULT_OPTIONS,
transform: transformCurrentUser,
update: updateResult,
url: "/api/users/current_user",
url: "/api/v0/users/current_user",
body: {
...profileData
}
Expand Down
14 changes: 0 additions & 14 deletions users/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,6 @@
router.register(r"user_search", UsersViewSet, basename="users_search_api")

urlpatterns = [
path(
"api/users/me",
CurrentUserRetrieveUpdateViewSet.as_view(
{"patch": "update", "get": "retrieve"}
),
name="users_api-me",
),
path(
"api/users/current_user/",
NewCurrentUserRetrieveUpdateViewSet.as_view(
{"patch": "update", "get": "retrieve"}
),
name="users_api-current_user",
),
path("api/", include(router.urls)),
path(
"api/v0/users/me",
Expand Down