Skip to content

Conversation

@theomoondev
Copy link

Task List

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe in your own words what the Model is doing in Rails The Model receives data from the Controller, which it stores in a database using SQL commands. The Model can also pass data from the database to the Controller so it can be rendered in the View.
Describe in your own words what the Controller is doing in Rails The Controller receives user input data, which it uses to manipulate the Model. The Controller also receives data from the Model and passes it to the View for rendering. The Controller ultimately compiles the View and sends it to the browser as HTML.
Describe in your own words what the View is doing in Rails The View receives data from the Controller and renders it using HTML and ERB. The View passes this code to the Controller to be sent to the browser.
Describe an edge-case controller test you wrote For the update, destroy, and toggle_complete methods, they "will create a flash alert and redirect for an invalid task". This is an edge-case test because it will only happen if the user tries to make a patch or delete request with an invalid id (for example, when using a tool like Postman). Only get requests can be made through the address bar, as far as I know!
What is the purpose of using strong params? (i.e. the params method in the controller) Strong params provides a safe way to require and permit data that comes from forms, rather than specifying each field separately.
How are Rails migrations related to Rails models? Migrations give us a way to modify the database schema (tables and columns with data passed from the Controller) according to the Model fields. For example, the create_task migration enters a new task into the database with the following fields: "name," "description," "completed_at," "created_at," and "updated_at."
Describe one area of Rails that are still unclear on I'm not sure how to test whether the data remains unchanged when making a patch request with an invalid id (see tests for toggle_complete; I checked whether a flash message was created as a workaround).

Lee added 30 commits April 28, 2020 20:51
peachmakkoli added 25 commits May 4, 2020 21:20
…ct to the root page if given an invalid id
… for comparison, tests if a flash alert is present when an invalid id is passed in
@tildeee
Copy link

tildeee commented May 11, 2020

Task List

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
At least 6 commits with meaningful commit messages ✔️
Routes follow RESTful conventions ✔️
Uses named routes (like _path) ✔️
Creates Models and migrations ✔️
Creates styled views Not really!
Handles errors like nonexistant tasks ✔️ Nice handling for GET /tasks/nonexistent-task!
Uses form_with to render forms in Rails ✔️

Functional Requirements/Manual Testing

Functional Requirement yes/no
Successfully handles index & show ✔️
index & show tests pass ✔️
Successfully handles: New, Create ✔️
New, Create tests pass ✔️
Successfully handles: Edit, Update ✔️
Successfully handles: Destroy, Task Complete ✔️

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 5+ in Code Review && 5+ in Functional Requirements ✔️
Yellow (Approaches Standards) 3+ in Code Review && 4+ in Functional Requirements, or the instructor judges that this project needs special attention
Red (Not at Standard) 0-2 in Code Review or 0-3 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging, or the instructor judges that this project needs special attention

Additional Feedback

Great work on this project, Lee!

I'm also really glad that you got to practice strong params, partial views, and writing test cases for update/delete/custom actions! Super well done!

With regards to your reflection questions: I think that you tested the toggle complete feature appropriately-- you checked the number of tasks and the contents of that task; looks great! When we introduce flash, we won't spend a lot of time testing flash, but testing the messages on flash is totally appropriate and something you can do, so I'm glad you did!

I've really added only one comment about a subtle refactoring-- otherwise, your code looks great! I see you are developing a code style that insists on clarity and conciseness, and that's great and I encourage it :D

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation
Elegant/Clever
Descriptive/Readable
Concise
Logical/Organized

@@ -0,0 +1,88 @@
class TasksController < ApplicationController
def index
@tasks = Task.order("id") # with Task.all, everytime a task was updated, it would jump to the bottom of the list
Copy link

Choose a reason for hiding this comment

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

Nice!

Comment on lines +175 to +200
Task.create(
name: "completed task",
description: "completed description",
completed_at: Time.now
)
end

let (:completed_task_hash) {
{
task: {
name: "completed task",
description: "completed task description",
completed_at: Time.now.to_s,
},
}
}

it "can mark an incomplete task as complete" do
id = Task.first.id

expect {
patch toggle_complete_path(id)
}.wont_change "Task.count"

task = Task.find(id)
expect(task.completed_at).must_equal completed_task_hash[:task][:completed_at]
Copy link

Choose a reason for hiding this comment

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

This is an extremely subtle and minor thing, but just to let it marinate in your brain for future tests:

the value of task is the Task created in your before block... and the value you test it against is the completed_at defined in the completed_task_hash let variable.

Very subtle, but that means you're checking the created Task against an unrelated variable. It ends up working out since the created Task and the completed_task_hash end up having the same values anyway.

However: Imagine a developer who didn't read through this and changes the completed_task_hash contents. Then your tests may break, but not because the feature is broken!

You may want to think about if your created task could directly rip values from the completed_task_hash, or some other way to refactor this. Let me know if you have questions! (btw this line of thinking might also apply to your edit/update tests)

Copy link
Author

Choose a reason for hiding this comment

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

Ahh! My guess is that line 200 needs to be expect(task.completed_at).must_equal Time.now.to_s (and I don't need the completed_task_hash). After writing tests for Ride Share, I'm realizing that I made some pretty funky tests for Task List 😅. Thank you for all your feedback!

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