Chitter solo challenge#231
Conversation
| @view_all_button = 1 | ||
| erb :'peeps/index' | ||
| end | ||
|
|
There was a problem hiding this comment.
clean and concise. I can follow the workflow from how the methods are structured.
| - message character limit validation | ||
| - cf. Bookmark Manager extensions, | ||
| e.g. update (inc. logging?), delete, user authentication | ||
| - equivilent of Twitter # |
There was a problem hiding this comment.
good use of notes and to do to plan next steps
|
|
||
| <form action="/peeps" method="post"> | ||
| <input type="text" name="message" placeholder="Message"/> | ||
| <input type="hidden" name="date" value="<%=Date.today%>"> |
There was a problem hiding this comment.
awesome way to get the time stamp with a hidden field
siellsiell
left a comment
There was a problem hiding this comment.
Hey Ollie,
This is a great solution to the challenge, really well done. Your testing in particular is very thorough, which is nice to see.
I've left a few more detailed comments below for things you could do in the future to make your code even better.
If you have any questions, feel free to ask in the comments on here or in a DM.
Simo
| @@ -1,66 +1,42 @@ | |||
| ## Chitter Challenge | |||
There was a problem hiding this comment.
Nice README, it's very clear.
| get '/test' do | ||
| 'Test page' | ||
| end |
There was a problem hiding this comment.
It's always a good idea to remove test code from code you submit for code review (anywhere, not just at Makers)
| get '/peeps/new' do | ||
| erb :'peeps/new' | ||
| end | ||
|
|
||
| get '/peeps/search' do | ||
| erb :'peeps/search' | ||
| end | ||
|
|
||
| get '/peeps/filtered' do | ||
| @peeps = Peep.filter(params[:keyword]) | ||
| @view_all_button = 1 | ||
| erb :'peeps/index' | ||
| end |
There was a problem hiding this comment.
You've shown good use of RESTful routes 👍🏽
|
|
||
| get '/peeps/filtered' do | ||
| @peeps = Peep.filter(params[:keyword]) | ||
| @view_all_button = 1 |
There was a problem hiding this comment.
I saw further down that you're using this as a kind of boolean flag, in which case it would be better to make your intention explicit here and set this to true rather than one.
| @@ -0,0 +1 @@ | |||
| ALTER TABLE peeps ADD COLUMN date DATE; | |||
There was a problem hiding this comment.
Separate migration file -- great. And DATE is an appropriate datatype to use. Another option would have been to use TIMESTAMP. That would give you flexibility in the future if it ever becomes necessary to show time information too.
| expect(page).to have_content "Banana peep (2022-07-15)" | ||
| expect(page).to have_content "Another banana peep (2022-07-05)" |
There was a problem hiding this comment.
This is good but doesn't exclude the possibility that the other non-banana peeps are also on the page! How could you test for that?
| @@ -0,0 +1,43 @@ | |||
| feature 'pathing between routes' do | |||
There was a problem hiding this comment.
This is very thorough, nice!
|
|
||
| visit('/peeps') | ||
|
|
||
| expect(page).to have_content(/New peep.*Old peep/) |
| expect(peeps.first).to be_a Peep | ||
| expect(peeps.first.id).to eq peep.id | ||
| expect(peeps.first.message).to eq("This is a peep!") | ||
| expect(peeps.first.date).to eq("2022-07-15") |
There was a problem hiding this comment.
Since the peeps array could have duplicates (due to a bug), it's also necessary to test that the other 2 peeps are the ones you expect.
|
|
||
| <form action="/peeps" method="post"> | ||
| <input type="text" name="message" placeholder="Message"/> | ||
| <input type="hidden" name="date" value="<%=Date.today%>"> |
There was a problem hiding this comment.
Using a hidden field works but it does mean that a malicious user could issue their own POST request and set a time of their choosing. The other pitfall is that the date will be generated at the time when this page is rendered rather than at the time when the user clicks submit, so at midnight boundaries it might end up being wrong.
For reasons like that it can be better to generate the date in your Model code just before you insert the data into the database.
Your name
Ollie Freeman
User stories
Please list which user stories you've implemented (delete the ones that don't apply).
README checklist
Does your README contains instructions for
Here is a pill that can help you write a great README!