Add new DataDoc backend - #47990
Conversation
There was a problem hiding this comment.
I stole all of these from programming_expression_test.rb ... is there a better way?
There was a problem hiding this comment.
since these tests are covering functionality in validate_key_format defined in CurriculumHelper, ideally tests of this detail would be in a test file for that specific helper. if you want to deduplicate this, you could try following these instructions to write a test specifically for the helper: https://guides.rubyonrails.org/testing.html#testing-helpers the helper test seems to implicitly include the module into the test class, but if that doesn't seem to work you could explicitly do something like
validate_key_format so that you can test it.
for this to work, you will probably need to stub out the key method as though it is a method on your test class.
045749e to
d0c2092
Compare
davidsbailey
left a comment
There was a problem hiding this comment.
nice job Meg, it looks like you are off to a great start on picking Data Docs back up! a few comments inline.
| render :not_acceptable, json: @data_doc.errors | ||
| end | ||
| end | ||
| end |
There was a problem hiding this comment.
nit: I don't think this is an official rails convention, but please add a placeholder method for the new action in this file:
# GET /data_docs
def new
end
There was a problem hiding this comment.
Ah, good to know! I wasn't sure what the standard was.
| @@ -0,0 +1,15 @@ | |||
| class DataDocsController < ApplicationController | |||
| load_and_authorize_resource | |||
There was a problem hiding this comment.
new and create should also be protected with require_levelbuilder_mode_or_test_env
| test_user_gets_response_for :new, params: -> {@test_params}, user: nil, response: :redirect | ||
| test_user_gets_response_for :new, params: -> {@test_params}, user: :student, response: :forbidden | ||
| test_user_gets_response_for :new, params: -> {@test_params}, user: :teacher, response: :forbidden | ||
| test_user_gets_response_for :new, params: -> {@test_params}, user: :levelbuilder, response: :success |
There was a problem hiding this comment.
nice tests! can you please add some for the create method too?
There was a problem hiding this comment.
since these tests are covering functionality in validate_key_format defined in CurriculumHelper, ideally tests of this detail would be in a test file for that specific helper. if you want to deduplicate this, you could try following these instructions to write a test specifically for the helper: https://guides.rubyonrails.org/testing.html#testing-helpers the helper test seems to implicitly include the module into the test class, but if that doesn't seem to work you could explicitly do something like
validate_key_format so that you can test it.
for this to work, you will probably need to stub out the key method as though it is a method on your test class.
|
I moved the key validation tests to a separate helper: #48032 |
This work is part of https://codedotorg.atlassian.net/browse/PLAT-1279 –– Curriculum Writers can add new Data Docs.
To see functionality, go to http://localhost-studio.code.org:3000/data_docs/new. It should make you add Levelbuilder permissions to your local account before you can view the page, and you should be able to put in some basic stuff. What actually happens after you submit will come in a separate PR (see follow-up work).
The focus here is on the backend –– we'll finalize the frontend functionality in a separate PR (see follow-up work).
Links
Spec
Engineering Plan
Testing story
There are backend tests here. Frontend tests will come in a future PR.
I added a React page just to test manually –– see video at https://watch.screencastify.com/v/mYC1OEaabGkJn2XyUUTA.
Deployment strategy
Follow-up work
Privacy
Security
Caching
PR Checklist: