Skip to content

Chitter solo challenge#231

Open
olliefreeman94 wants to merge 15 commits into
makersacademy:mainfrom
olliefreeman94:main
Open

Chitter solo challenge#231
olliefreeman94 wants to merge 15 commits into
makersacademy:mainfrom
olliefreeman94:main

Conversation

@olliefreeman94
Copy link
Copy Markdown

@olliefreeman94 olliefreeman94 commented Jul 15, 2022

Your name

Ollie Freeman

User stories

Please list which user stories you've implemented (delete the ones that don't apply).

  • User story 1: "I want to see all the messages (peeps) in a browser"
  • User story 2: "I want to post a message (peep) to chitter"
  • User story 3: "I want to see the date the message was posted"
  • User story 4: "I want to see a list of peeps in reverse chronological order"
  • User story 5: "I want to filter on a specific keyword"

README checklist

Does your README contains instructions for

  • how to install,
  • how to run,
  • and how to test your code?

Here is a pill that can help you write a great README!

@olliefreeman94 olliefreeman94 marked this pull request as ready for review July 15, 2022 09:36
@olliefreeman94 olliefreeman94 changed the title Project setup Chitter solo challenge Jul 17, 2022
Comment thread app.rb
@view_all_button = 1
erb :'peeps/index'
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

clean and concise. I can follow the workflow from how the methods are structured.

Comment thread notes.txt
- message character limit validation
- cf. Bookmark Manager extensions,
e.g. update (inc. logging?), delete, user authentication
- equivilent of Twitter #
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

good use of notes and to do to plan next steps

Comment thread views/peeps/new.erb

<form action="/peeps" method="post">
<input type="text" name="message" placeholder="Message"/>
<input type="hidden" name="date" value="<%=Date.today%>">
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

awesome way to get the time stamp with a hidden field

Copy link
Copy Markdown
Contributor

@siellsiell siellsiell left a comment

Choose a reason for hiding this comment

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

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

Comment thread README.md
@@ -1,66 +1,42 @@
## Chitter Challenge
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice README, it's very clear.

Comment thread app.rb
Comment on lines 5 to 7
get '/test' do
'Test page'
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's always a good idea to remove test code from code you submit for code review (anywhere, not just at Makers)

Comment thread app.rb
Comment on lines +23 to +35
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You've shown good use of RESTful routes 👍🏽

Comment thread app.rb

get '/peeps/filtered' do
@peeps = Peep.filter(params[:keyword])
@view_all_button = 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines +11 to +12
expect(page).to have_content "Banana peep (2022-07-15)"
expect(page).to have_content "Another banana peep (2022-07-05)"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is very thorough, nice!


visit('/peeps')

expect(page).to have_content(/New peep.*Old peep/)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice way to test this.

Comment thread spec/units/peep_spec.rb
Comment on lines +14 to +17
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")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread views/peeps/new.erb

<form action="/peeps" method="post">
<input type="text" name="message" placeholder="Message"/>
<input type="hidden" name="date" value="<%=Date.today%>">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

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.

3 participants