Conversation
Task ListWhat We're Looking For
|
CheezItMan
reviewed
Apr 17, 2019
|
|
||
| def create | ||
| task = Task.new(task_params) | ||
| if task.name == "" || task.description == "" || task.completion_date == "" |
There was a problem hiding this comment.
This is a little weird. .save is a method, you shouldn't assign it a value.
It also crashes rails
| if is_successful | ||
| redirect_to task_path(task.id) | ||
| else | ||
| head :temporary_redirect |
There was a problem hiding this comment.
Why temporary redirect? why not server error or something?
| <%= f.label :completion_date %> | ||
| <%= f.text_field :completion_date%> | ||
|
|
||
| <%= f.submit action_name, class:"task-form_submit-btn"%> |
| <%= link_to task.name, task_path(task.id)%> | ||
| Details: <%= task.description%>, due <%= task.completion_date%> <%= link_to "Mark Complete", toggle_path(task.id), method: :patch, data: { confirm: "Mark Complete?" } %> | ||
| </li> | ||
| <li><%= link_to "Delete", task_path(task.id), method: :delete, data: { confirm: "Are you sure you want to delete?" } %></li> |
| def toggle | ||
| @complete_task = Task.find_by(id: params[:id]) | ||
| # is_complete = complete_task.update(status ) | ||
| if @complete_task.update(:status => false) |
There was a problem hiding this comment.
This if statement is checking to see if the update method works or not, it doesn't check to see what complete_task.status is.
Instead I would do:
@complete_task = Task.find_by(id: params[:id])
if @complete_task
@complete_task.status = ! @complete_task.status
if @complete_task.save
redirect_to tasks_path
else
head :server_error
end
else
head :not_found
end| patch toggle_path(complete_task.id) | ||
| toggle = Task.find_by(id: complete_task.id) | ||
| # Assert | ||
| expect(toggle.status).must_equal true |
There was a problem hiding this comment.
This test is failing... Also you need to test that once you toggle a task to complete, you can toggle it incomplete.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task List
Congratulations! You're submitting your assignment!
Comprehension Questions