diff --git a/app/controllers/api/v1/participants_controller.rb b/app/controllers/api/v1/participants_controller.rb index 75f982f44..12b6bdf9b 100644 --- a/app/controllers/api/v1/participants_controller.rb +++ b/app/controllers/api/v1/participants_controller.rb @@ -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? @@ -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 diff --git a/app/helpers/participants_helper.rb b/app/helpers/participants_helper.rb index 6a3e7011a..eb2292eba 100644 --- a/app/helpers/participants_helper.rb +++ b/app/helpers/participants_helper.rb @@ -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 }, diff --git a/db/seeds.rb b/db/seeds.rb index b6de376f2..19a82eeea 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -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 diff --git a/spec/requests/api/v1/participants_controller_spec.rb b/spec/requests/api/v1/participants_controller_spec.rb index d974640a3..d1f1b90ad 100644 --- a/spec/requests/api/v1/participants_controller_spec.rb +++ b/spec/requests/api/v1/participants_controller_spec.rb @@ -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, @@ -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