Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chitter-challenge #210

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Chitter-challenge #210

wants to merge 3 commits into from

Conversation

ShannonWL
Copy link

Your name

Shannon White

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"

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!

@ShannonWL ShannonWL changed the title User Story 1 Chitter-challenge Apr 1, 2022
Copy link

@Leigh-Rose Leigh-Rose left a comment

Choose a reason for hiding this comment

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

Code formatted nicely and is readable and succinct, everything looks like it would work, Just a few newlines to be added.

@@ -84,6 +84,7 @@ GEM

PLATFORMS
x86_64-darwin-20
x86_64-darwin-21

Choose a reason for hiding this comment

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

Line 87 interesting, what does this do?

result = connection.exec("INSERT INTO peeps (message) VALUES('#{message}') RETURNING id, message")
Peep.new(id: result[0]['id'], message: result[0]['message'])
end
end

Choose a reason for hiding this comment

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

Newline

connection = PG.connect(dbname: 'chitter_test')
result = connection.query("SELECT * FROM peeps WHERE id = #{id};")
result.first
end

Choose a reason for hiding this comment

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

Newline


expect(page).to have_content 'This is another peep'
end
end

Choose a reason for hiding this comment

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

Newline


expect(page).to have_content 'This is a peep!'
end
end

Choose a reason for hiding this comment

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

Newline

connection = PG.connect(dbname: 'chitter')
end

result = connection.exec("INSERT INTO peeps (message) VALUES('#{message}') RETURNING id, message")

Choose a reason for hiding this comment

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

Line 32 could be open to SQL injection attack.

<%= peep.message %>
</li>
<% end %>
</ul>

Choose a reason for hiding this comment

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

Newline

<form action="/peeps" method="post">
<input type="text" name="message" />
<input type="submit" name="Submit" />
</form>

Choose a reason for hiding this comment

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

Newline

Copy link
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, it's Simo, a coach. I've reviewed your code and left a few comments below. If you have any questions, please ask!

Comment on lines 10 to 12
get '/test' do
'Test page'
end
Copy link
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)

erb :"peeps/index"
end

get '/peeps/new' do
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice use of RESTful route names!

Comment on lines +26 to +30
if ENV['ENVIRONMENT'] == 'test'
connection = PG.connect(dbname: 'chitter_test')
else
connection = PG.connect(dbname: 'chitter')
end
Copy link
Contributor

Choose a reason for hiding this comment

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

This piece of code appears twice in this file. How might you remove this duplication?

Comment on lines +13 to +16
expect(peeps.length).to eq 2
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!'
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally you'd check that both results in the array are correct

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.

None yet

3 participants