Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/api/v1/participants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def find_participant
# Validates that the authorization parameter is present and is one of the following valid authorizations: reader, reviewer, submitter, mentor
# Returns the authorization if valid
def validate_authorization
valid_authorizations = %w[reader reviewer submitter mentor]
valid_authorizations = %w[participant reader reviewer submitter mentor]
authorization = params[:authorization]
authorization = authorization.downcase if authorization.present?

Expand All @@ -184,7 +184,7 @@ def validate_authorization
end

unless valid_authorizations.include?(authorization)
render json: { error: 'authorization not valid. Valid authorizations are: Reader, Reviewer, Submitter, Mentor' },
render json: { error: 'authorization not valid. Valid authorizations are: Participant, Reader, Reviewer, Submitter, Mentor' },
status: :unprocessable_entity
return
end
Expand Down
1 change: 1 addition & 0 deletions app/helpers/participants_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def retrieve_participant_permissions(authorization)
}

permissions_map = {
'participant' => {},
'reader' => { can_submit: false },
'reviewer' => { can_submit: false, can_take_quiz: false },
'submitter' => { can_review: false, can_take_quiz: false },
Expand Down
5 changes: 5 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@
user_id: student_user_ids[i],
assignment_id: assignment_ids[i%num_assignments],
team_id: team_ids[i%num_teams],
authorization: :participant,
can_review: true,
can_submit: true,
can_take_quiz: true,
can_mentor: false,
).id
end

Expand Down
4 changes: 2 additions & 2 deletions spec/requests/api/v1/participants_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
consumes 'application/json'
produces 'application/json'

parameter name: :authorization, in: :path, type: :string, description: 'Authorization level (Reader, Reviewer, Submitter, Mentor)'
parameter name: :authorization, in: :path, type: :string, description: 'Authorization level (Participant, Reader, Reviewer, Submitter, Mentor)'
parameter name: 'Authorization', in: :header, type: :string, required: true, description: 'Bearer token'
parameter name: :participant, in: :body, schema: {
type: :object,
Expand Down Expand Up @@ -325,7 +325,7 @@ def fetch_username(user_id)
let(:participant) { { user_id: studentb.id, assignment_id: assignment1.id } }

run_test! do |response|
expect(JSON.parse(response.body)['error']).to eql('authorization not valid. Valid authorizations are: Reader, Reviewer, Submitter, Mentor')
expect(JSON.parse(response.body)['error']).to eql('authorization not valid. Valid authorizations are: Participant, Reader, Reviewer, Submitter, Mentor')
end
end

Expand Down
Loading