Skip to content

Stabilize student task backend endpoints and tests#304

Open
XiangjunMi832 wants to merge 5 commits intoexpertiza:mainfrom
ravisatyarsg:student-task-backend-hardening
Open

Stabilize student task backend endpoints and tests#304
XiangjunMi832 wants to merge 5 commits intoexpertiza:mainfrom
ravisatyarsg:student-task-backend-hardening

Conversation

@XiangjunMi832
Copy link
Copy Markdown

PR Description

Summary

This PR hardens the backend implementation for the Student Task View feature.

The work focuses on validating and stabilizing the existing student task API flow so it returns consistent composed task data, enforces ownership correctly, and has backend test coverage for the main success and failure paths.

What changed

  • reworked student task assembly to use existing model relationships instead of placeholder/sample data
  • composed student task data from Participant, Assignment, Course, Team, SignedUpTeam/SignUpTopic, DueDate, and review response data
  • returned a more stable JSON payload for frontend consumption, including:
    • assignment and course metadata
    • team and team member data
    • topic data
    • deadlines
    • timeline/stage data
    • feedback data
  • fixed student task detail access so students can only access their own task data
  • returned proper error responses for:
    • unauthorized access
    • forbidden access to another student’s task
    • invalid task IDs
    • empty task lists
  • restricted student task routes to the intended read-only endpoints
  • fixed a shared authorization edge case that could raise a 500 when role records were missing
  • added a fullname compatibility method on User to prevent crashes in response/reviewer-related flows
  • replaced weak/seed-dependent coverage with deterministic backend tests

Tests added/updated

Backend coverage now includes:

  • successful task list retrieval
  • successful task detail retrieval
  • unauthorized access
  • forbidden access to another student’s task
  • invalid task ID
  • empty task list
  • routing coverage for student task endpoints
  • model coverage for student task assembly and ordering

Notes

  • review_grade is intentionally returned as null instead of fabricated placeholder data
  • frontend work is not included here because this repository only contains the backend

Verification

Focused backend student-task specs passed before push:

docker compose exec -T app bundle exec rspec \
  spec/models/student_task_spec.rb \
  spec/requests/api/v1/student_tasks_controller_spec.rb \
  spec/routing/student_tasks_routing_spec.rb \
  spec/routing/signed_up_teams_routing_spec.rb

@github-actions
Copy link
Copy Markdown

2 Warnings
⚠️ Pull request is too big (more than 500 LoC).
⚠️ RSpec tests seem shallow (single it blocks or no context). Consider improving test structure.

Generated by 🚫 Danger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant