Skip to content
This repository was archived by the owner on Mar 13, 2021. It is now read-only.

Commit

Permalink
previously made listings are displayed on /listings
Browse files Browse the repository at this point in the history
  • Loading branch information
russellyeo committed Dec 12, 2016
1 parent 51b8800 commit 6562afc
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 24 deletions.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
--color
--require spec_helper
-fd
12 changes: 12 additions & 0 deletions app/views/listings.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<h1>Listings</h1>

<ul id='listings'>
<% @listings.each do |listing| %>
<li>
Name: <%= listing.name %>
Price: <%= listing.price %>
Available from: <%= listing.start_date %>
Available until: <%= listing.end_date %>
</li>
<% end %>
</ul>
6 changes: 6 additions & 0 deletions app/vradbnb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ class VRADBnB < Sinatra::Base
price: params[:price], start_date: params[:start_date],
end_date: params[:end_date])
listing.save
redirect '/listings'
end

get '/listings' do
@listings = Listing.all
erb :listings
end
# start the server if ruby file executed directly
run! if app_file == $0
Expand Down
4 changes: 2 additions & 2 deletions spec/features/create_listing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
scenario "Owner submits a listing for their space" do
visit '/listings/new'

fill_in('name', with: 'Russel')
fill_in('description', with: "Sunny palace")
fill_in('name', with: 'Sunny palace')
fill_in('description', with: "Russell's crib")
fill_in('price', with: 5000)
fill_in('start_date', with: '31/01/2016')
fill_in('end_date', with: '01/01/2017')
Expand Down
22 changes: 0 additions & 22 deletions views/create_listing.erb

This file was deleted.

0 comments on commit 6562afc

Please sign in to comment.