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

Alice Wood - Chitter Challenge #2198

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
360d42e
Project setup
aliceswood May 5, 2023
d14ec56
setting up the chitter database
aliceswood May 9, 2023
e67e34f
organising project READMEs
aliceswood May 9, 2023
953dc11
amending initial approach and creating database connection file
aliceswood May 9, 2023
1092018
updating documentation to have same terminology - peeps
aliceswood May 9, 2023
604b3a0
adding pg gem requirement to Gemfile
aliceswood May 9, 2023
6595839
updating gemfile to have pg gem
aliceswood May 9, 2023
1767ba4
peep repository class - find all peeps tested and passing
aliceswood May 9, 2023
60eaaba
peep repository - add method tdd'ed
aliceswood May 9, 2023
508c071
fixing database connection file to link to correct database
aliceswood May 9, 2023
176f995
updating test to check that peeps are sorted reverse chronologically
aliceswood May 9, 2023
234a3b8
creating the first sinatra path for / test driven - user/name not yet…
aliceswood May 9, 2023
8e30ab1
first draft of homepage printing peeps
aliceswood May 9, 2023
0714fef
added the name and username display for the homepage
aliceswood May 9, 2023
7747e1a
trying to fix the readme initial plan image
aliceswood May 9, 2023
609fd71
Account model and Repository class TDD'ed
aliceswood May 9, 2023
a68c6c8
updating README.md
aliceswood May 10, 2023
a12ddf5
tidying up seed data
aliceswood May 10, 2023
914905f
refactoring some of the sql queries
aliceswood May 10, 2023
e5fe4ad
you can add a peep to the homepage and it redirects you back
aliceswood May 10, 2023
ad29f47
added redirection buttons after peep is submitted
aliceswood May 10, 2023
705a6c6
added sign up link to the homepage - still need to make this conditio…
aliceswood May 10, 2023
7369a9c
sign in page and log in page created ahead of session being implemented
aliceswood May 10, 2023
5a466f8
fixed the sorting of peeps to be via time not just id and unique chec…
aliceswood May 10, 2023
a7a440f
updating readme now that MVP is completed
aliceswood May 10, 2023
97890dd
updated seeds and tests to have test emails as @example.com
aliceswood May 10, 2023
164ed9b
adding my first box to erb file! Also added placeholders to forms and…
aliceswood May 10, 2023
0fcc8b7
some css for the background and font
aliceswood May 10, 2023
a8523c3
updated spec to reflect the css changes in app.rb
aliceswood May 11, 2023
3169b1a
updating view files with css
aliceswood May 11, 2023
2c3a8a4
successful log in working - errors for incorrect details being worked on
aliceswood May 11, 2023
78f04a5
safe navigation operator added for account login
aliceswood May 11, 2023
e084e74
makes the sign up, log in and post conditional on session id
aliceswood May 11, 2023
7fa1780
added a log out button and used sessions to implement
aliceswood May 11, 2023
1770878
fixed the html to try and improve layout - amended tests accordingly
aliceswood May 11, 2023
e493127
update readme
aliceswood May 11, 2023
cdf96be
added bcrypt for passwords
aliceswood May 11, 2023
fd97380
fixing sessions bug and updating html
aliceswood May 12, 2023
fce620c
html edit
aliceswood May 12, 2023
7cf72c3
adding reflection to my README
aliceswood May 12, 2023
e4fe7d0
fixing formatting
aliceswood May 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
peep repository - add method tdd'ed
aliceswood committed May 9, 2023
commit 60eaaba58c9f367b8c4f027d41242fcbf7712d4f
16 changes: 2 additions & 14 deletions design/peep_respository_class_recipe.md
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ class PeepRepository
# Takes a peep object as an argument
def add(peep)
# Executes the SQL query:
# INSERT INTO peeps (time, contents, account_id) VALUES ($1, $2, $3);'
# INSERT INTO peeps (time, contents, account_id) VALUES ($1, $2, $3);

# Returns nil, just creates an object.
end
@@ -114,20 +114,8 @@ peeps.first.time # => '2023-05-09 11:09:00'
peeps.first.contents # => 'hello, this is the first peep!'
peeps.first.account_id # => 1

# 2
# Get a single peep

repo = PeepRepository.new

peep = repo.find(1)

peep.id # => 1
peep.time # => '2023-05-09 11:09:00'
peep.contents # => 'hello, this is the first peep!'
peep.account_id # => 1


# 3
# 2
# Add a peep

repo = PeepRepository.new
9 changes: 7 additions & 2 deletions lib/peep_repository.rb
Original file line number Diff line number Diff line change
@@ -13,14 +13,19 @@ def all
peep.time = record['time']
peep.contents = record['contents']
peep.account_id = record['account_id'].to_i


peeps << peep
end
return peeps
end

def add(peep)
# adds a peep object to the peep table
sql = 'INSERT INTO peeps (time, contents, account_id) VALUES ($1, $2, $3);'
sql_params = [peep.time, peep.contents, peep.account_id]

DatabaseConnection.exec_params(sql, sql_params)

return peep
end
end
18 changes: 17 additions & 1 deletion spec/peep_repository_spec.rb
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ def reset_peeps_table
before(:each) do
reset_peeps_table
end

it 'finds all peeps' do
peep_repo = PeepRepository.new

@@ -24,4 +24,20 @@ def reset_peeps_table
expect(peeps.first.account_id).to eq(1)
end


it 'adds a peep' do
repo = PeepRepository.new
new_peep = Peep.new

new_peep.time = Time.now
new_peep.contents = "we are adding a new peep!"
new_peep.account_id = 1

repo.add(new_peep)

peeps = repo.all

expect(peeps.length).to eq(4)
expect(peeps.last.contents).to eq("we are adding a new peep!")
end
end