Skip to content

E2610 #315

Open
AtharvaW195 wants to merge 15 commits intoexpertiza:mainfrom
AtharvaW195:main
Open

E2610 #315
AtharvaW195 wants to merge 15 commits intoexpertiza:mainfrom
AtharvaW195:main

Conversation

@AtharvaW195
Copy link
Copy Markdown

No description provided.

KrishaDarji and others added 6 commits March 17, 2026 16:13
…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
@github-actions
Copy link
Copy Markdown

3 Warnings
⚠️ Pull request is too big (more than 500 LoC).
⚠️ Schema changes detected without a corresponding DB migration.
⚠️ RSpec tests seem shallow (single it blocks or no context). Consider improving test structure.

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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you creating a TeamsParticipant object in here if it the team is full?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, remove the tp creation

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the unused TeamsParticipant.new(...) lines.

Comment thread app/controllers/teams_controller.rb Outdated
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]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before_action makes more sense here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted to before_action

Comment thread app/controllers/teams_controller.rb Outdated
render json: { error: 'Team not found' }, status: :not_found
end

def current_user_member_of_team?(team)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is already a method which does the same thing inside team.rb
remove this method and use that instead wherever required

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please explain with a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments

Comment thread app/models/team.rb
def max_size
if is_a?(AssignmentTeam) && assignment&.max_team_size
assignment.max_team_size
elsif is_a?(CourseTeam) && course&.max_team_size
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this check removed?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@github-actions
Copy link
Copy Markdown

🚨 RSpec Tests Report

Failing Model Test Cases:
rspec ./spec/models/invitation_spec.rb:61 # Invitation accepts invitation and update invitee's team

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 1, 2026

🚨 RSpec Tests Report

All tests passed.

KrishaDarji and others added 3 commits April 3, 2026 17:26
- Unenrolled rejection case intentionally still passes a User to prove the system blocks non-participants
- All 9 CourseTeam examples passing
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 6, 2026

🚨 RSpec Tests Report

All tests passed.

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.

3 participants