Skip to content

Commit

Permalink
refactor(team.rb): Removing some styling errors
Browse files Browse the repository at this point in the history
  • Loading branch information
darshil0193 committed Nov 4, 2017
1 parent 8fe0ca5 commit 18e3ea1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/controllers/response_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def action_allowed?
# if it is a review response map, all the members of reviewee team should be able to view the reponse (can be done from heat map)
if map.is_a? ReviewResponseMap
reviewee_team = AssignmentTeam.find(map.reviewee_id)
return current_user_id?(response.map.reviewer.user_id) || reviewee_team.user?(current_user) || current_user.role.name == 'Administrator' || (current_user.role.name == 'Instructor' and assignment.instructor_id == current_user.id) || (current_user.role.name == 'Teaching Assistant' and TaMapping.exists?(ta_id: current_user.id, course_id: assignment.course.id))
return current_user_id?(response.map.reviewer.user_id) || reviewee_team.user?(current_user) || current_user.role.name == 'Administrator' ||
(current_user.role.name == 'Instructor' and assignment.instructor_id == current_user.id) || (current_user.role.name == 'Teaching Assistant' and
TaMapping.exists?(ta_id: current_user.id, course_id: assignment.course.id))
else
return current_user_id?(response.map.reviewer.user_id)
end
Expand Down
4 changes: 3 additions & 1 deletion app/models/assignment_team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ def copy(course_id)

# Add Participants to the current Assignment Team
def add_participant(assignment_id, user)
AssignmentParticipant.create(parent_id: assignment_id, user_id: user.id, permission_granted: user.master_permission_granted) if AssignmentParticipant.find_by(parent_id: assignment_id, user_id: user.id).nil?
if AssignmentParticipant.find_by(parent_id: assignment_id, user_id: user.id).nil?
AssignmentParticipant.create(parent_id: assignment_id, user_id: user.id, permission_granted: user.master_permission_granted)
end
end

# Return the parent Assignment
Expand Down
3 changes: 2 additions & 1 deletion app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ def self.assign_single_users_to_teams(min_team_size, parent, teams, users)
teams.each do |team|
curr_team_size = Team.size(team.id)
member_num_difference = min_team_size - curr_team_size
for i in (1..member_num_difference).to_a
while(member_num_difference > 0) do
team.add_member(users.first, parent.id)
users.delete(users.first)
member_num_difference = member_num_difference - 1
break if users.empty?
end
break if users.empty?
Expand Down
2 changes: 1 addition & 1 deletion spec/models/team_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
context 'when team exists' do
it 'raises a TeamExistsError' do
allow(AssignmentTeam).to receive(:where).with(parent_id: 1, name: team.name).and_return([team])
expect { Team.check_for_existing(team, team.name, 'Assignment')}.to raise_error(TeamExistsError)
expect { Team.check_for_existing(team, team.name, 'Assignment') }.to raise_error(TeamExistsError)
end
end

Expand Down

0 comments on commit 18e3ea1

Please sign in to comment.