Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NoMethodError in assessments controller #36480

Merged
merged 2 commits into from
Aug 31, 2020
Merged

Conversation

clareconstantine
Copy link

This was causing an HB error when current_user was nil - now we check that we have a current user before verifying that the current user is an authorized teacher.

Links

Testing story

Reviewer Checklist:

  • Tests provide adequate coverage
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@clareconstantine clareconstantine requested review from a team, cforkish and jmkulwik and removed request for a team August 27, 2020 02:03
@@ -24,7 +24,7 @@ def load_from_cache
# GET '/dashboardapi/assessments'
def index
# Only authorized teachers have access to locked question and answer data.
render status: :forbidden unless current_user.authorized_teacher?
render status: :forbidden unless current_user && current_user.authorized_teacher?
Copy link
Contributor

Choose a reason for hiding this comment

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

i recently learned about current_user&.authorized_teacher? syntax. do we prefer that for this type of check?

Copy link
Author

Choose a reason for hiding this comment

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

yes! thanks!

Copy link
Contributor

@jmkulwik jmkulwik left a comment

Choose a reason for hiding this comment

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

LGTM!

@clareconstantine clareconstantine merged commit 384bc4d into staging Aug 31, 2020
@clareconstantine clareconstantine deleted the assessments-error branch August 31, 2020 21:15
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.

None yet

3 participants