Skip to content

Add new DataDoc backend - #47990

Merged
megcrenshaw merged 15 commits into
stagingfrom
add-new-doc-backend
Sep 9, 2022
Merged

Add new DataDoc backend#47990
megcrenshaw merged 15 commits into
stagingfrom
add-new-doc-backend

Conversation

@megcrenshaw

@megcrenshaw megcrenshaw commented Sep 7, 2022

Copy link
Copy Markdown

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

  • Refactor React component with styling and error-handling and testing.
  • Add UI test?
  • Create page to actually see the DataDoc that was created –– this is a separate work item in the engineering plan. We should redirect to the corresponding page once a data doc is created.

Privacy

Security

Caching

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • 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

@megcrenshaw megcrenshaw changed the title Add new doc backend Add new DataDoc backend Sep 7, 2022
Comment thread dashboard/test/models/data_doc_test.rb Outdated

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I stole all of these from programming_expression_test.rb ... is there a better way?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

class PdWorkshopHelperTest < ActionView::TestCase
include PdWorkshopHelper
to get access to 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.

@megcrenshaw
megcrenshaw requested a review from a team September 8, 2022 15:52

@davidsbailey davidsbailey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ah, good to know! I wasn't sure what the standard was.

@@ -0,0 +1,15 @@
class DataDocsController < ApplicationController
load_and_authorize_resource

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice tests! can you please add some for the create method too?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch!

Comment thread dashboard/test/models/data_doc_test.rb Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

class PdWorkshopHelperTest < ActionView::TestCase
include PdWorkshopHelper
to get access to 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.

@megcrenshaw

Copy link
Copy Markdown
Author

I moved the key validation tests to a separate helper: #48032

@megcrenshaw
megcrenshaw merged commit beb1295 into staging Sep 9, 2022
@megcrenshaw
megcrenshaw deleted the add-new-doc-backend branch September 9, 2022 20:12
@megcrenshaw megcrenshaw mentioned this pull request Sep 12, 2022
8 tasks
@TurnerRiley TurnerRiley mentioned this pull request Sep 22, 2022
8 tasks
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.

2 participants