Add edit DataDoc backend - #48243
Conversation
megcrenshaw
left a comment
There was a problem hiding this comment.
I added a couple of small changes, but this looks great! Love how you split up the PR
|
|
||
| # GET /data_docs/:key/edit | ||
| def edit | ||
| @data_doc = DataDoc.find_by(key: params[:key]) |
There was a problem hiding this comment.
up to you but if all the routes are fetching the data doc by key, it might be worth moving this into a private method and using before_action :set_data_doc, like in scripts_controller.rb.
There was a problem hiding this comment.
Good call. I tried using load_resource id_param: :key but had no luck ...
There was a problem hiding this comment.
Done! Thank you
bethanyaconnor
left a comment
There was a problem hiding this comment.
lgtm after addressing Meg's comment
|
|
||
| def set_data_doc | ||
| @data_doc = DataDoc.find_by(key: params[:key]) | ||
| return render :not_found unless @data_doc |
There was a problem hiding this comment.
not to keep on this but I've struggled with rendering not found in the private method. Does this work correctly? If so, looks great!
There was a problem hiding this comment.
I re-tested locally and was able to go through all the routes of creating, editing, and submitting data docs so I think it still works correctly! I'm waiting to make sure all drone tests still pass just in case but I think it should be good
There was a problem hiding this comment.
Hi @TurnerRiley , what happens when you do one of these actions (edit or update) with a key that does not exist? that's what needs to be tested to evaluate Bethany's concern.
There was a problem hiding this comment.
just closing the loop, it looks like this is giving a 404 as expected: http://localhost-studio.code.org:3000/data_docs/foo/edit
This is part of this Jira ticket for adding an editing interface for existing DataDocs (to be able to change the name and content of them). This PR is just focused on updating/adding backend files to prep for the next PR which will add the actual editing form itself.
To see where the editor will be:
Links
Jira ticket: here
Spec: requirement #2 here
Following up work from previous DataDoc PR's: New DataDoc backend, New DataDoc frontend, and Add DataDoc show page
Testing story
Local testing to ensure the addition of these files do not disrupt the current DataDoc creation and viewing behavior. Backend tests were also added for these changes.
Follow-up work
PR Checklist: