fix(api): link created resources to the selected course offering - #2
Open
sclibraries wants to merge 1 commit into
Open
fix(api): link created resources to the selected course offering#2sclibraries wants to merge 1 commit into
sclibraries wants to merge 1 commit into
Conversation
POST /course/create-resource resolved the offering by (course_id, term_id), which is ambiguous when a course has several sections in one term: a resource added while viewing section 03 was linked to section 01. This ports the production hotfix into apps/api unchanged: require offering_id, verify it belongs to the course, verify its FOLIO listing matches the request, and link to that exact offering. The admin client already sends offering_id. Regression coverage ports the legacy standalone harness into the isolated Codeception stack (CreateResourceOfferingCest): section 03 links to section 03, a mismatched listing is rejected, a missing offering_id is rejected. Test-config changes needed for that: a small Helper\Functional module to post raw JSON bodies, and config/test.php now mirrors config/web.php by parsing JSON bodies and resolving bearer tokens through JwtIdentity. The latter also makes FacultySubmissionCest's authenticated read pass; the remaining functional errors/failures are the pre-existing baseline. Verified in the isolated stack on PHP 7.2.34 / MariaDB 10.3.39: CreateResourceOfferingCest 3/3 green (red before the fix), functional 18 tests (4 errors, 1 failure = baseline minus the now-passing read), unit 75 tests unchanged from baseline, PHPCompatibility 7.2 clean. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lr3h4fx5cxzRJbQoZ6ijPa
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
apps/api:POST /course/create-resourcenow requiresoffering_id, checks it belongs to the course and matches the FOLIO listing, and links the resource to that exact offering. Previously the lookup by course + term returned the first section, so a resource added in section 03 landed on section 01.CreateResourceOfferingCest, a Codeception port of the legacy regression harness: section 03 links to 03, mismatched listing → 400, missingoffering_id→ 400.config/web.php(JSON body parser,JwtIdentityfor bearer tokens) plus a tinyHelper\Functionalmodule for raw JSON posts. This also makes the pre-existingFacultySubmissionCestauthenticated read pass.actionCreateResource()is byte-identical to the deployed production controller. No frontend change needed; the admin client already sendsoffering_id.Test plan
Run in the isolated stack (
docker-compose.test.yml, PHP 7.2.34 / MariaDB 10.3.39):codecept run functional CreateResourceOfferingCest— red before the fix (03 linked to 01; invalid requests returned 200), green after: 3 tests, 7 assertionscodecept run functional— 18 tests, 4 errors, 1 failure (baseline was 15 tests, 4 errors, 2 failures; the delta is the now-passing faculty read)codecept run unit— 75 tests, unchanged from baselinephpcs --standard=PHPCompatibility --runtime-set testVersion 7.2clean on changed files🤖 Generated with Claude Code