From 0d8e7b105d42d291906599a590e9a35b5524e320 Mon Sep 17 00:00:00 2001
From: agagotowiec
Date: Thu, 31 Mar 2022 14:47:20 +0100
Subject: [PATCH 01/11] connected to psql, created databses, added messages
---
Gemfile.lock | 3 +++
app.rb | 10 ++++++++--
lib/post.rb | 9 +++++++++
spec/features/test_page_spec.rb | 6 ------
spec/features/viewing_posts_spec.rb | 15 +++++++++++++++
spec/post_spec.rb | 12 ++++++++++++
views/index.erb | 5 +++++
7 files changed, 52 insertions(+), 8 deletions(-)
create mode 100644 lib/post.rb
delete mode 100644 spec/features/test_page_spec.rb
create mode 100644 spec/features/viewing_posts_spec.rb
create mode 100644 spec/post_spec.rb
create mode 100644 views/index.erb
diff --git a/Gemfile.lock b/Gemfile.lock
index 7d4eb449..21826b1e 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -18,6 +18,8 @@ GEM
mini_mime (1.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
+ nokogiri (1.12.3-arm64-darwin)
+ racc (~> 1.4)
nokogiri (1.12.3-x86_64-darwin)
racc (~> 1.4)
parallel (1.20.1)
@@ -83,6 +85,7 @@ GEM
nokogiri (~> 1.8)
PLATFORMS
+ arm64-darwin-21
x86_64-darwin-20
DEPENDENCIES
diff --git a/app.rb b/app.rb
index 2450fb92..1fc4d1c1 100644
--- a/app.rb
+++ b/app.rb
@@ -1,8 +1,14 @@
require 'sinatra/base'
+require './lib/post'
class Chitter < Sinatra::Base
- get '/test' do
- 'Test page'
+ get '/' do
+ 'Chitter App'
+ end
+
+ get '/posts' do
+ @posts = Post.all
+ erb :index
end
run! if app_file == $0
diff --git a/lib/post.rb b/lib/post.rb
new file mode 100644
index 00000000..b0f86773
--- /dev/null
+++ b/lib/post.rb
@@ -0,0 +1,9 @@
+require 'pg'
+
+class Post
+ def self.all
+ connection = PG.connect(dbname: 'chitter')
+ result = connection.exec('SELECT * FROM peeps')
+ result.map { |post| post['message'] }
+ end
+end
diff --git a/spec/features/test_page_spec.rb b/spec/features/test_page_spec.rb
deleted file mode 100644
index b65ac196..00000000
--- a/spec/features/test_page_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-feature 'Viewing test page' do
- scenario 'visiting the test page' do
- visit('/test')
- expect(page).to have_content "Test page"
- end
-end
diff --git a/spec/features/viewing_posts_spec.rb b/spec/features/viewing_posts_spec.rb
new file mode 100644
index 00000000..eff259cf
--- /dev/null
+++ b/spec/features/viewing_posts_spec.rb
@@ -0,0 +1,15 @@
+feature 'Welcome page' do
+ scenario 'user visits homepage ' do
+ visit('/')
+ expect(page).to have_content "Chitter App"
+ end
+end
+
+feature 'Viewing posts' do
+ scenario 'user can see posts' do
+ visit('/posts')
+ expect(page).to have_content "Best day of my life"
+ expect(page).to have_content "Tennis related news"
+ expect(page).to have_content "Grateful"
+ end
+end
diff --git a/spec/post_spec.rb b/spec/post_spec.rb
new file mode 100644
index 00000000..c7a92d40
--- /dev/null
+++ b/spec/post_spec.rb
@@ -0,0 +1,12 @@
+require 'post'
+
+RSpec.describe Post do
+ describe '.all' do
+ it 'returns all posts' do
+ post = Post.all
+ expect(post).to include("Best day of my life")
+ expect(post).to include("Tennis related news")
+ expect(post).to include("Grateful")
+ end
+ end
+end
diff --git a/views/index.erb b/views/index.erb
new file mode 100644
index 00000000..30826f8c
--- /dev/null
+++ b/views/index.erb
@@ -0,0 +1,5 @@
+
+<% @posts.each do |post| %>
+ - <%= post %>
+ <% end %>
+
\ No newline at end of file
From 8c7d065c7f5b83f7571cd3f20b77104380e6a485 Mon Sep 17 00:00:00 2001
From: agagotowiec
Date: Fri, 1 Apr 2022 12:12:40 +0100
Subject: [PATCH 02/11] added post creating functionality and css
---
Gemfile | 1 +
Gemfile.lock | 3 ++
app.rb | 10 +++++
db/migrations/02_add_author_to_the_post.sql | 1 +
db/migrations/03_add_date_to_the_post.sql | 0
lib/post.rb | 33 +++++++++++++--
spec/database_helpers.rb | 6 +++
spec/features/creating_post_spec.rb | 10 +++++
spec/features/viewing_posts_spec.rb | 14 ++++---
spec/post_spec.rb | 32 ++++++++++++---
views/index.erb | 45 +++++++++++++++++++--
views/new_post.erb | 29 +++++++++++++
12 files changed, 168 insertions(+), 16 deletions(-)
create mode 100644 db/migrations/02_add_author_to_the_post.sql
create mode 100644 db/migrations/03_add_date_to_the_post.sql
create mode 100644 spec/database_helpers.rb
create mode 100644 spec/features/creating_post_spec.rb
create mode 100644 views/new_post.erb
diff --git a/Gemfile b/Gemfile
index 99d8e519..2fb95daa 100644
--- a/Gemfile
+++ b/Gemfile
@@ -12,6 +12,7 @@ group :test do
gem 'rspec'
gem 'simplecov', require: false
gem 'simplecov-console', require: false
+ gem 'launchy'
end
group :development, :test do
diff --git a/Gemfile.lock b/Gemfile.lock
index 21826b1e..5762ffdf 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -15,6 +15,8 @@ GEM
xpath (~> 3.2)
diff-lcs (1.4.4)
docile (1.4.0)
+ launchy (2.5.0)
+ addressable (~> 2.7)
mini_mime (1.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
@@ -90,6 +92,7 @@ PLATFORMS
DEPENDENCIES
capybara
+ launchy
pg
rspec
rubocop (= 1.20)
diff --git a/app.rb b/app.rb
index 1fc4d1c1..cae1ef19 100644
--- a/app.rb
+++ b/app.rb
@@ -4,12 +4,22 @@
class Chitter < Sinatra::Base
get '/' do
'Chitter App'
+ redirect '/posts/new'
end
get '/posts' do
@posts = Post.all
erb :index
end
+
+ get '/posts/new' do
+ erb :new_post
+ end
+
+ post '/posts' do
+ Post.create(author: params[:author], message: params[:message])
+ redirect '/posts'
+ end
run! if app_file == $0
end
diff --git a/db/migrations/02_add_author_to_the_post.sql b/db/migrations/02_add_author_to_the_post.sql
new file mode 100644
index 00000000..631e251f
--- /dev/null
+++ b/db/migrations/02_add_author_to_the_post.sql
@@ -0,0 +1 @@
+ALTER TABLE peeps ADD COLUMN author VARCHAR(60);
\ No newline at end of file
diff --git a/db/migrations/03_add_date_to_the_post.sql b/db/migrations/03_add_date_to_the_post.sql
new file mode 100644
index 00000000..e69de29b
diff --git a/lib/post.rb b/lib/post.rb
index b0f86773..139d8afe 100644
--- a/lib/post.rb
+++ b/lib/post.rb
@@ -1,9 +1,36 @@
require 'pg'
class Post
+ attr_reader :id, :author, :message
+
+ def initialize(id:, author:, message:)
+ @id = id
+ @author = author
+ @message = message
+ end
+
def self.all
- connection = PG.connect(dbname: 'chitter')
- result = connection.exec('SELECT * FROM peeps')
- result.map { |post| post['message'] }
+ if ENV['ENVIRONMENT'] == 'test'
+ connection = PG.connect(dbname: 'chitter_test')
+ else
+ connection = PG.connect(dbname: 'chitter')
+ end
+ result = connection.exec("SELECT * FROM peeps;")
+ result.map do |peep|
+ Post.new(id: peep['id'], author: peep['author'], message: peep['message'])
+ end
+ end
+
+ def self.create(author:, message:)
+ if ENV['ENVIRONMENT'] == 'test'
+ connection = PG.connect(dbname: 'chitter_test')
+ else
+ connection = PG.connect(dbname: 'chitter')
+ end
+
+ result = connection.exec(
+ "INSERT INTO peeps (author, message) VALUES('#{author}', '#{message}')
+ RETURNING id, author, message;")
+ Post.new(id: result[0]['id'], author: result[0]['author'], message: result[0]['message'])
end
end
diff --git a/spec/database_helpers.rb b/spec/database_helpers.rb
new file mode 100644
index 00000000..ce8e636c
--- /dev/null
+++ b/spec/database_helpers.rb
@@ -0,0 +1,6 @@
+require 'pg'
+
+def persisted_data(id:)
+ connection = PG.connect(dbname: 'chitter_test')
+ result = connection.query("SELECT * FROM peeps WHERE id = #{id};")
+end
diff --git a/spec/features/creating_post_spec.rb b/spec/features/creating_post_spec.rb
new file mode 100644
index 00000000..56cdc56a
--- /dev/null
+++ b/spec/features/creating_post_spec.rb
@@ -0,0 +1,10 @@
+feature 'Adding a new post' do
+ scenario 'a user can add a new post' do
+ visit('/posts/new')
+ fill_in("author", with: "Rose")
+ fill_in("message", with: "How are you?")
+ click_button('Submit')
+
+ expect(page).to have_content("Rose", "How are you?")
+ end
+end
diff --git a/spec/features/viewing_posts_spec.rb b/spec/features/viewing_posts_spec.rb
index eff259cf..18f0d7cf 100644
--- a/spec/features/viewing_posts_spec.rb
+++ b/spec/features/viewing_posts_spec.rb
@@ -1,15 +1,19 @@
+require 'pg'
+
feature 'Welcome page' do
scenario 'user visits homepage ' do
- visit('/')
+ visit('/posts/new')
expect(page).to have_content "Chitter App"
end
end
feature 'Viewing posts' do
- scenario 'user can see posts' do
+ scenario 'visiting /posts shows all posts' do
+
+ Post.create(author: "Rose", message: "How are you?")
+
visit('/posts')
- expect(page).to have_content "Best day of my life"
- expect(page).to have_content "Tennis related news"
- expect(page).to have_content "Grateful"
+ expect(page).to have_content("Rose", "How are you?")
+
end
end
diff --git a/spec/post_spec.rb b/spec/post_spec.rb
index c7a92d40..a140b2ac 100644
--- a/spec/post_spec.rb
+++ b/spec/post_spec.rb
@@ -1,12 +1,34 @@
require 'post'
+require 'pg'
+require 'database_helpers'
RSpec.describe Post do
describe '.all' do
- it 'returns all posts' do
- post = Post.all
- expect(post).to include("Best day of my life")
- expect(post).to include("Tennis related news")
- expect(post).to include("Grateful")
+ it 'returns a list of posts' do
+ connection = PG.connect(dbname: 'chitter_test')
+
+ post = Post.create(author: 'Kate', message: 'This is my first post!')
+ Post.create(author: 'Rose', message: 'How are you?')
+ Post.create(author: 'Emma', message: 'Working from home')
+
+ messages = Post.all
+ expect(messages.length).to eq 3
+ expect(messages.first).to be_a Post
+ expect(messages.first.id).to eq post.id
+ expect(messages.first.author).to eq 'Kate'
+ expect(messages.first.message).to eq 'This is my first post!'
+ end
+ end
+
+ describe '.create' do
+ it 'creates a new post' do
+ post = Post.create(author: 'Kate', message: 'This is my first post!')
+ persisted_data = persisted_data(id: post.id)
+
+ expect(post).to be_a Post
+ expect(post.id).to eq persisted_data.first['id']
+ expect(post.author).to eq 'Kate'
+ expect(post.message).to eq 'This is my first post!'
end
end
end
diff --git a/views/index.erb b/views/index.erb
index 30826f8c..e3d70500 100644
--- a/views/index.erb
+++ b/views/index.erb
@@ -1,5 +1,44 @@
+
+
+
+
+Recent Peeps
+
+
\ No newline at end of file
diff --git a/views/new_post.erb b/views/new_post.erb
new file mode 100644
index 00000000..d1bd272c
--- /dev/null
+++ b/views/new_post.erb
@@ -0,0 +1,29 @@
+
+
+
+
+Chitter App
+
+
\ No newline at end of file
From 4ee5f96071400c7eca7ae3e37868beed8b2033eb Mon Sep 17 00:00:00 2001
From: agagotowiec
Date: Fri, 1 Apr 2022 12:55:23 +0100
Subject: [PATCH 03/11] 3rd user story done
---
app.rb | 2 +-
lib/post.rb | 15 ++++++++-------
spec/features/creating_post_spec.rb | 25 ++++++++++++++++++++++++-
spec/features/viewing_posts_spec.rb | 27 ++++++++++++++++++++++++---
spec/post_spec.rb | 10 ++++++----
views/index.erb | 17 +++++++++--------
views/new_post.erb | 14 ++++++++------
7 files changed, 80 insertions(+), 30 deletions(-)
diff --git a/app.rb b/app.rb
index cae1ef19..1d3f2484 100644
--- a/app.rb
+++ b/app.rb
@@ -17,7 +17,7 @@ class Chitter < Sinatra::Base
end
post '/posts' do
- Post.create(author: params[:author], message: params[:message])
+ Post.create(date: params[:date], author: params[:author], message: params[:message])
redirect '/posts'
end
diff --git a/lib/post.rb b/lib/post.rb
index 139d8afe..8f977f55 100644
--- a/lib/post.rb
+++ b/lib/post.rb
@@ -1,10 +1,11 @@
require 'pg'
class Post
- attr_reader :id, :author, :message
+ attr_reader :id, :date, :author, :message
- def initialize(id:, author:, message:)
+ def initialize(id:, date:, author:, message:)
@id = id
+ @date = date
@author = author
@message = message
end
@@ -17,11 +18,11 @@ def self.all
end
result = connection.exec("SELECT * FROM peeps;")
result.map do |peep|
- Post.new(id: peep['id'], author: peep['author'], message: peep['message'])
+ Post.new(id: peep['id'], date: peep['date'], author: peep['author'], message: peep['message'])
end
end
- def self.create(author:, message:)
+ def self.create(date:, author:, message:)
if ENV['ENVIRONMENT'] == 'test'
connection = PG.connect(dbname: 'chitter_test')
else
@@ -29,8 +30,8 @@ def self.create(author:, message:)
end
result = connection.exec(
- "INSERT INTO peeps (author, message) VALUES('#{author}', '#{message}')
- RETURNING id, author, message;")
- Post.new(id: result[0]['id'], author: result[0]['author'], message: result[0]['message'])
+ "INSERT INTO peeps (date, author, message) VALUES('#{date}', '#{author}', '#{message}')
+ RETURNING id, date, author, message;")
+ Post.new(id: result[0]['id'], date: result[0]['date'], author: result[0]['author'], message: result[0]['message'])
end
end
diff --git a/spec/features/creating_post_spec.rb b/spec/features/creating_post_spec.rb
index 56cdc56a..4048cd79 100644
--- a/spec/features/creating_post_spec.rb
+++ b/spec/features/creating_post_spec.rb
@@ -1,10 +1,33 @@
feature 'Adding a new post' do
scenario 'a user can add a new post' do
visit('/posts/new')
+ fill_in("date", with: "2022-04-01")
fill_in("author", with: "Rose")
fill_in("message", with: "How are you?")
click_button('Submit')
- expect(page).to have_content("Rose", "How are you?")
+ expect(page).to have_content("How are you?")
+ end
+end
+feature 'Adding a new post' do
+ scenario 'a user can add a new post' do
+ visit('/posts/new')
+ fill_in("date", with: "2022-04-01")
+ fill_in("author", with: "Rose")
+ fill_in("message", with: "How are you?")
+ click_button('Submit')
+
+ expect(page).to have_content("Rose")
+ end
+end
+feature 'Adding a new post' do
+ scenario 'a user can add a new post' do
+ visit('/posts/new')
+ fill_in("date", with: "2022-04-01")
+ fill_in("author", with: "Rose")
+ fill_in("message", with: "How are you?")
+ click_button('Submit')
+
+ expect(page).to have_content("2022-04-01")
end
end
diff --git a/spec/features/viewing_posts_spec.rb b/spec/features/viewing_posts_spec.rb
index 18f0d7cf..5cbaa701 100644
--- a/spec/features/viewing_posts_spec.rb
+++ b/spec/features/viewing_posts_spec.rb
@@ -8,12 +8,33 @@
end
feature 'Viewing posts' do
- scenario 'visiting /posts shows all posts' do
+ scenario 'visiting /posts shows message text' do
- Post.create(author: "Rose", message: "How are you?")
+ Post.create(date: "2022-04-01", author: "Kate", message: "How are you?")
visit('/posts')
- expect(page).to have_content("Rose", "How are you?")
+ expect(page).to have_content("How are you?")
end
end
+
+feature 'Viewing posts' do
+ scenario 'visiting /posts shows message author' do
+
+ Post.create(date: "2022-04-01", author: "Kate", message: "How are you?")
+
+ visit('/posts')
+ expect(page).to have_content("Kate")
+
+ end
+end
+feature 'Viewing posts' do
+ scenario 'visiting /posts shows message date' do
+
+ Post.create(date: "2022-04-01", author: "Kate", message: "How are you?")
+
+ visit('/posts')
+ expect(page).to have_content("2022-04-01")
+
+ end
+end
\ No newline at end of file
diff --git a/spec/post_spec.rb b/spec/post_spec.rb
index a140b2ac..ad31ab50 100644
--- a/spec/post_spec.rb
+++ b/spec/post_spec.rb
@@ -7,14 +7,15 @@
it 'returns a list of posts' do
connection = PG.connect(dbname: 'chitter_test')
- post = Post.create(author: 'Kate', message: 'This is my first post!')
- Post.create(author: 'Rose', message: 'How are you?')
- Post.create(author: 'Emma', message: 'Working from home')
+ post = Post.create(date: "2022-04-01", author: 'Kate', message: 'This is my first post!')
+ Post.create(date: "2022-04-02", author: 'Rose', message: 'How are you?')
+ Post.create(date: "2022-04-03", author: 'Emma', message: 'Working from home')
messages = Post.all
expect(messages.length).to eq 3
expect(messages.first).to be_a Post
expect(messages.first.id).to eq post.id
+ expect(messages.first.date).to eq "2022-04-01"
expect(messages.first.author).to eq 'Kate'
expect(messages.first.message).to eq 'This is my first post!'
end
@@ -22,11 +23,12 @@
describe '.create' do
it 'creates a new post' do
- post = Post.create(author: 'Kate', message: 'This is my first post!')
+ post = Post.create(date: "2022-04-01", author: 'Kate', message: 'This is my first post!')
persisted_data = persisted_data(id: post.id)
expect(post).to be_a Post
expect(post.id).to eq persisted_data.first['id']
+ expect(post.date).to eq '2022-04-01'
expect(post.author).to eq 'Kate'
expect(post.message).to eq 'This is my first post!'
end
diff --git a/views/index.erb b/views/index.erb
index e3d70500..d5c8ee9b 100644
--- a/views/index.erb
+++ b/views/index.erb
@@ -6,22 +6,22 @@ body {
}
div {
- background-color: white;
- margin: 20px 20px;
- padding: 60px 60px;
- border: 2px solid green;
+ margin: 20px 60px;
+ padding: 50px 300px;
}
h1 {
- font-size: 30px;
+ font-size: 40px;
text-align: center;
}
h3 {
+ padding: 10px 10px;
font-size: 26px;
color: navy;
text-align: center;
+ border: 1px solid black;
+ background-color: white;
}
-
ul {
list-style: none;
}
@@ -34,8 +34,9 @@ ul {
<% @posts.each do |peep| %>
- name: <%= peep.author %>
- message: <%= peep.message %>
+ date: <%= peep.date %>
+ name: <%= peep.author %>
+ message: <%= peep.message %>
<% end %>
diff --git a/views/new_post.erb b/views/new_post.erb
index d1bd272c..c3bbfcd7 100644
--- a/views/new_post.erb
+++ b/views/new_post.erb
@@ -5,15 +5,15 @@ body {
margin: 20px 20px;
text-align: center;
}
+h1 {
+ font-size: 50px;
+}
.tweet {
display: inline-block;
background-color: white;
margin: 20px 20px;
- padding: 60px 60px;
-}
-form {
- margin: 0 auto;
- display: ;
+ padding: 30px 60px;
+ border: 2px solid black;
}
@@ -21,8 +21,10 @@ form {
Chitter App
From 6ba2585fb187f9db0b66859b90bb7edf5b4c1be1 Mon Sep 17 00:00:00 2001
From: agagotowiec
Date: Fri, 1 Apr 2022 13:44:06 +0100
Subject: [PATCH 04/11] secured app from sql injection
---
lib/post.rb | 6 ++----
spec/features/creating_post_spec.rb | 24 ++----------------------
spec/features/viewing_posts_spec.rb | 25 +++----------------------
views/index.erb | 19 +++++++++++--------
views/new_post.erb | 2 +-
5 files changed, 19 insertions(+), 57 deletions(-)
diff --git a/lib/post.rb b/lib/post.rb
index 8f977f55..2d2bb6dc 100644
--- a/lib/post.rb
+++ b/lib/post.rb
@@ -29,9 +29,7 @@ def self.create(date:, author:, message:)
connection = PG.connect(dbname: 'chitter')
end
- result = connection.exec(
- "INSERT INTO peeps (date, author, message) VALUES('#{date}', '#{author}', '#{message}')
- RETURNING id, date, author, message;")
+ result = connection.exec_params("INSERT INTO peeps (date, author, message) VALUES('#{date}', $1, $2) RETURNING id, date, author, message;", [author, message])
Post.new(id: result[0]['id'], date: result[0]['date'], author: result[0]['author'], message: result[0]['message'])
end
-end
+ end
diff --git a/spec/features/creating_post_spec.rb b/spec/features/creating_post_spec.rb
index 4048cd79..b6c20905 100644
--- a/spec/features/creating_post_spec.rb
+++ b/spec/features/creating_post_spec.rb
@@ -6,28 +6,8 @@
fill_in("message", with: "How are you?")
click_button('Submit')
- expect(page).to have_content("How are you?")
- end
-end
-feature 'Adding a new post' do
- scenario 'a user can add a new post' do
- visit('/posts/new')
- fill_in("date", with: "2022-04-01")
- fill_in("author", with: "Rose")
- fill_in("message", with: "How are you?")
- click_button('Submit')
-
- expect(page).to have_content("Rose")
- end
-end
-feature 'Adding a new post' do
- scenario 'a user can add a new post' do
- visit('/posts/new')
- fill_in("date", with: "2022-04-01")
- fill_in("author", with: "Rose")
- fill_in("message", with: "How are you?")
- click_button('Submit')
-
expect(page).to have_content("2022-04-01")
+ expect(page).to have_content("Rose")
+ expect(page).to have_content("How are you?")
end
end
diff --git a/spec/features/viewing_posts_spec.rb b/spec/features/viewing_posts_spec.rb
index 5cbaa701..cf7e9d17 100644
--- a/spec/features/viewing_posts_spec.rb
+++ b/spec/features/viewing_posts_spec.rb
@@ -8,33 +8,14 @@
end
feature 'Viewing posts' do
- scenario 'visiting /posts shows message text' do
-
- Post.create(date: "2022-04-01", author: "Kate", message: "How are you?")
-
- visit('/posts')
- expect(page).to have_content("How are you?")
-
- end
-end
-
-feature 'Viewing posts' do
- scenario 'visiting /posts shows message author' do
+ scenario 'visiting /posts shows message ' do
Post.create(date: "2022-04-01", author: "Kate", message: "How are you?")
visit('/posts')
+ expect(page).to have_content("2022-04-01")
expect(page).to have_content("Kate")
+ expect(page).to have_content("How are you?")
end
end
-feature 'Viewing posts' do
- scenario 'visiting /posts shows message date' do
-
- Post.create(date: "2022-04-01", author: "Kate", message: "How are you?")
-
- visit('/posts')
- expect(page).to have_content("2022-04-01")
-
- end
-end
\ No newline at end of file
diff --git a/views/index.erb b/views/index.erb
index d5c8ee9b..a5a769bc 100644
--- a/views/index.erb
+++ b/views/index.erb
@@ -2,25 +2,28 @@
-Recent Peeps
-
-
\ No newline at end of file
+Chitter App
+
+Recent Peeps
+
+
diff --git a/views/see_posts.erb b/views/see_posts.erb
new file mode 100644
index 00000000..7bb7675c
--- /dev/null
+++ b/views/see_posts.erb
@@ -0,0 +1,44 @@
+
\ No newline at end of file
From 32f986603d0a6d610131e71f9ede8b82cdd4af50 Mon Sep 17 00:00:00 2001
From: agagotowiec
Date: Fri, 1 Apr 2022 17:32:31 +0100
Subject: [PATCH 08/11] changes following rubocop tests
---
db/migrations/01_create_chitter_table.sql | 2 +-
lib/post.rb | 2 +-
spec/features/viewing_posts_spec.rb | 2 +-
views/index.erb | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/db/migrations/01_create_chitter_table.sql b/db/migrations/01_create_chitter_table.sql
index 6e077248..a153af4c 100644
--- a/db/migrations/01_create_chitter_table.sql
+++ b/db/migrations/01_create_chitter_table.sql
@@ -1 +1 @@
-CREATE TABLE peeps(id SERIAL PRIMARY KEY, message VARCHAR(60));
+CREATE TABLE peeps(id SERIAL PRIMARY KEY, message VARCHAR(500));
diff --git a/lib/post.rb b/lib/post.rb
index 8a371c9f..4f90328d 100644
--- a/lib/post.rb
+++ b/lib/post.rb
@@ -32,4 +32,4 @@ def self.create(date:, author:, message:)
result = connection.exec_params("INSERT INTO peeps (date, author, message) VALUES('#{date}', $1, $2) RETURNING id, date, author, message;", [author, message])
Post.new(id: result[0]['id'], date: result[0]['date'], author: result[0]['author'], message: result[0]['message'])
end
- end
+end
diff --git a/spec/features/viewing_posts_spec.rb b/spec/features/viewing_posts_spec.rb
index 539f1d67..70cd7c26 100644
--- a/spec/features/viewing_posts_spec.rb
+++ b/spec/features/viewing_posts_spec.rb
@@ -34,4 +34,4 @@
expect(page).to have_content("2022-06-01")
expect(page).to have_content("2022-04-01")
end
-end
\ No newline at end of file
+end
diff --git a/views/index.erb b/views/index.erb
index c2c4513c..15755a20 100644
--- a/views/index.erb
+++ b/views/index.erb
@@ -32,9 +32,9 @@ a {
From ef8939b26aee513ae62dcd1a907d79b428c6249f Mon Sep 17 00:00:00 2001
From: agagotowiec
Date: Fri, 1 Apr 2022 17:39:38 +0100
Subject: [PATCH 09/11] changed html
---
db/migrations/01_create_chitter_table.sql | 2 +-
views/new_post.erb | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/db/migrations/01_create_chitter_table.sql b/db/migrations/01_create_chitter_table.sql
index a153af4c..6e077248 100644
--- a/db/migrations/01_create_chitter_table.sql
+++ b/db/migrations/01_create_chitter_table.sql
@@ -1 +1 @@
-CREATE TABLE peeps(id SERIAL PRIMARY KEY, message VARCHAR(500));
+CREATE TABLE peeps(id SERIAL PRIMARY KEY, message VARCHAR(60));
diff --git a/views/new_post.erb b/views/new_post.erb
index c846e7ff..94be244f 100644
--- a/views/new_post.erb
+++ b/views/new_post.erb
@@ -21,10 +21,10 @@ h1 {
Chitter App
From c846ac9d265237102cb7c6f966476cf13f07ef6f Mon Sep 17 00:00:00 2001
From: agagotowiec
Date: Mon, 4 Apr 2022 10:04:53 +0100
Subject: [PATCH 10/11] updated .gitignore file
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 5399405e..022fa62f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@ coverage
# Local cache of Rubocop remote config
.rubocop-*
+capybara-*.html
From 892cab6eed7d93f07507dff5e16e31d33881571e Mon Sep 17 00:00:00 2001
From: agagotowiec
Date: Mon, 4 Apr 2022 10:23:04 +0100
Subject: [PATCH 11/11] updated readme
---
README.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/README.md b/README.md
index f9638b66..5fab7844 100644
--- a/README.md
+++ b/README.md
@@ -32,6 +32,10 @@ command `CREATE DATABASE chitter_test;`;
You should see 1 passing test.
+## Testing
+To test this code run
+* rspec
+
## User stories
```