Conversation
…s within the same course or multiple assignment teams within the same assignment
- Fixed validate_membership in CourseTeam to check CourseParticipant instead of assignment participants - Removed invalid course.max_team_size call in Team#max_size since Course model does not have a max_team_size column - All CourseTeam specs passing (9/9)
- Added 'can add enrolled user' success case to assignment_team_spec - Added 'does not add unenrolled user' rejection case to mentored_team_spec - MentoredTeam tests verify duty-based mentor logic (not role-based) - All 29 examples passing across CourseTeam, AssignmentTeam, MentoredTeam
Generated by 🚫 Danger |
| team.with_lock do | ||
| # Re-check while holding the lock (race-safe) | ||
| if team.full? | ||
| tp = TeamsParticipant.new(team: team, participant: participant, user_id: participant.user_id) |
There was a problem hiding this comment.
why are you creating a TeamsParticipant object in here if it the team is full?
There was a problem hiding this comment.
I removed the unused TeamsParticipant.new(...) lines.
| # Add participant to the new team (uses Team#add_member capacity check + MentoredTeam override) | ||
| result = team.add_member(participant) | ||
| unless result[:success] | ||
| tp = TeamsParticipant.new(team: team, participant: participant, user_id: participant.user_id) |
There was a problem hiding this comment.
again, remove the tp creation
There was a problem hiding this comment.
I removed the unused TeamsParticipant.new(...) lines.
| class TeamsController < ApplicationController | ||
| # Set the @team instance variable before executing actions except index and create | ||
| before_action :set_team, except: [:index, :create] | ||
| prepend_before_action :set_team, except: [:index, :create] |
There was a problem hiding this comment.
before_action makes more sense here.
| render json: { error: 'Team not found' }, status: :not_found | ||
| end | ||
|
|
||
| def current_user_member_of_team?(team) |
There was a problem hiding this comment.
there is already a method which does the same thing inside team.rb
remove this method and use that instead wherever required
There was a problem hiding this comment.
Removed current_user_member_of_team? from the controller and replaced its usage with the existing has_member? method defined in team.rb to avoid duplication.
| return unless mentor_duty | ||
|
|
||
| mentor_participant = AssignmentParticipant | ||
| .joins('INNER JOIN teams_participants ON teams_participants.participant_id = participants.id') |
There was a problem hiding this comment.
please explain with a comment
| def max_size | ||
| if is_a?(AssignmentTeam) && assignment&.max_team_size | ||
| assignment.max_team_size | ||
| elsif is_a?(CourseTeam) && course&.max_team_size |
There was a problem hiding this comment.
why is this check removed?
There was a problem hiding this comment.
Restored the elsif is_a?(CourseTeam) check in max_size that was previously removed. Added a respond_to? guard since the Course model does not currently have a max_team_size column
…nd clean up teams controller
|
🚨 RSpec Tests Report |
|
🚨 RSpec Tests Report |
- Unenrolled rejection case intentionally still passes a User to prove the system blocks non-participants - All 9 CourseTeam examples passing
|
🚨 RSpec Tests Report |
No description provided.