Skip to content

Commit

Permalink
Pass on category param in files API
Browse files Browse the repository at this point in the history
refs MAT-767

Test Plan:
Follow the test plan in the associated
canvas-lms commit

Change-Id: I1d80fb116ee0a6170186d01e254604b9c8335f1a
Reviewed-on: https://gerrit.instructure.com/c/canvas-rce-api/+/287066
Tested-by: Service Cloud Jenkins <[email protected]>
Reviewed-by: Gonzalo Penaranda <[email protected]>
QA-Review: Gonzalo Penaranda <[email protected]>
Product-Review: David Lyons <[email protected]>
  • Loading branch information
westonkd committed Mar 15, 2022
1 parent ad7865c commit 8e90c9f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/api/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const packageBookmark = require("./packageBookmark");
const { fileEmbed } = require("../../shared/mimeClass");
const { getSearch } = require("../utils/search");
const { getSort } = require("../utils/sort");
const { optionalQuery } = require("../utils/optionalQuery");

function canvasPath(request) {
if (request.query.contextType === "user") {
Expand All @@ -15,7 +16,7 @@ function canvasPath(request) {
request.query.per_page
}&include[]=preview_url&use_verifiers=0${getSearch(request.query)}${getSort(
request.query
)}`;
)}${optionalQuery(request.query, "category")}`;
}
}

Expand Down
18 changes: 18 additions & 0 deletions test/service/api/files.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@ describe("Files API", () => {
const expectedPath = `/api/v1/folders/${id}/files?per_page=50&include[]=preview_url&use_verifiers=0&sort=created_at&order=desc`;
assert.equal(canvasPath({ params, query }), expectedPath);
});

describe("when a category is given", () => {
let params, query;

const subject = () => canvasPath({ params, query });

beforeEach(() => {
params = { folderId: 7 };
query = { category: "uncategorized" };
});

it("adds the category as a query param", () => {
assert.equal(
subject(),
"/api/v1/folders/7/files?per_page=undefined&include[]=preview_url&use_verifiers=0&category=uncategorized"
);
});
});
});
});

Expand Down

0 comments on commit 8e90c9f

Please sign in to comment.