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

User7 #43

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b34f6fb
Initial commit includes changes to Gemfile and rails_helper
MillsProvosty Apr 30, 2019
cec8947
Began test file in comedians.index_spec
MillsProvosty Apr 30, 2019
d6bf276
Adds first test for comedians
MillsProvosty Apr 30, 2019
14e677c
Added seed data
MillsProvosty Apr 30, 2019
28046e8
Added create comedians migrate
MillsProvosty Apr 30, 2019
565de27
Adds index to comedians controller
MillsProvosty Apr 30, 2019
20b9f27
Adds index route
MillsProvosty Apr 30, 2019
2acd089
Adds changes to controller
MillsProvosty Apr 30, 2019
3cbb9e2
Changes image_url to thumb_url
MillsProvosty Apr 30, 2019
6043c78
Adds changes to coverage
MillsProvosty Apr 30, 2019
07d91eb
Trying to render url image
MillsProvosty Apr 30, 2019
6eda1ea
Got URL functioning, and added width
MillsProvosty May 1, 2019
abdd7c7
Adds specials models
MillsProvosty May 1, 2019
5a9e29e
Adds HTML for thumb_url
MillsProvosty May 1, 2019
3d42e14
Fixes errors related to page containing URL
MillsProvosty May 1, 2019
28b2038
Adds spacing to views file
MillsProvosty May 1, 2019
c3e7815
Adds Special Model
MillsProvosty May 1, 2019
97d1627
Adds migrate for speicals table
MillsProvosty May 1, 2019
a4acb25
Adds validates presence of name and runtime
MillsProvosty May 1, 2019
012b921
Changes schema to include foreign key
MillsProvosty May 1, 2019
65423ae
Commiting deletion
MillsProvosty May 2, 2019
6c80f49
Added @specials
MillsProvosty May 2, 2019
d64bab5
Adjusted spacing
MillsProvosty May 2, 2019
0736828
Adjusted spacing
MillsProvosty May 2, 2019
8eff83d
Added identification for comedian ID
MillsProvosty May 2, 2019
4b7ec3b
Adjusted seed data
MillsProvosty May 2, 2019
04c5945
Changed data for tests
MillsProvosty May 2, 2019
0413073
Changed spacing
MillsProvosty May 2, 2019
7d82d50
Adds functionality for searching by age
MillsProvosty May 3, 2019
b92697a
Adds functionality for specials count
MillsProvosty May 3, 2019
5437e94
Adds functionality for user story 6
MillsProvosty May 3, 2019
9d3ffd7
Adds part of User story 7
MillsProvosty May 6, 2019
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
/yarn-error.log

.byebug_history
/coverage
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ group :development, :test do
gem 'capybara'
gem 'launchy'
gem 'shoulda-matchers'
gem 'simplecov'
end

group :development do
Expand Down
16 changes: 12 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ GEM
bindex (0.7.0)
builder (3.2.3)
byebug (11.0.1)
capybara (3.17.0)
capybara (3.18.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
Expand All @@ -63,6 +63,7 @@ GEM
concurrent-ruby (1.1.5)
crass (1.0.4)
diff-lcs (1.3)
docile (1.3.1)
erubi (1.8.0)
execjs (2.7.0)
ffi (1.10.0)
Expand All @@ -73,6 +74,7 @@ GEM
jbuilder (2.8.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
json (2.2.0)
launchy (2.4.3)
addressable (~> 2.3)
listen (3.1.5)
Expand All @@ -90,7 +92,7 @@ GEM
minitest (5.11.3)
multi_json (1.13.1)
nio4r (2.3.1)
nokogiri (1.10.2)
nokogiri (1.10.3)
mini_portile2 (~> 2.4.0)
pg (1.1.4)
pry (0.12.2)
Expand Down Expand Up @@ -131,7 +133,7 @@ GEM
regexp_parser (1.4.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
rspec-expectations (3.8.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
Expand Down Expand Up @@ -160,6 +162,11 @@ GEM
tilt (>= 1.1, < 3)
shoulda-matchers (4.0.1)
activesupport (>= 4.2.0)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand Down Expand Up @@ -202,9 +209,10 @@ DEPENDENCIES
rspec-rails
sass-rails (~> 5.0)
shoulda-matchers
simplecov
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)

BUNDLED WITH
1.16.2
1.17.3
20 changes: 20 additions & 0 deletions app/controllers/comedians_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
class ComediansController < ApplicationController
def index
if params[:age] != nil
@comedians = Comedian.where(age: params[:age])
else
@comedians = Comedian.all
end
end

def new
end

def create
Comedian.create(comedian_params)
redirect_to '/comedians'
end
#everything above private is "public" and users can access all of it.
private
def comedian_params
params.require(:comedian).permit(:name, :age, :birthplace, :thumb_url)
end
end
16 changes: 16 additions & 0 deletions app/models/comedian.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
class Comedian < ApplicationRecord
has_many :specials

validates_presence_of :name
validates_presence_of :age
validates_presence_of :birthplace
validates_presence_of :thumb_url


def specials_count
specials.count
end

def self.average_age
Comedian.average(:age).round(2)
end

end
5 changes: 5 additions & 0 deletions app/models/special.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Special < ApplicationRecord
belongs_to :comedian

validates_presence_of :name, :runtime, :thumb_url
end
19 changes: 19 additions & 0 deletions app/views/comedians/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h1>Comedians</h1>
<h2>Statistics</h2>
<p>Average Age:<%= @comedians.average_age unless @comedians == [] %><p>

<%@comedians.each do |comedian|%>
<div class="comedian-card" id="Comedian-<%= comedian.id %>">
<p><img src="<%= comedian.thumb_url%>" alt="Comedian Pic" width="200"></p>
<h2><%= comedian.name %></h2>
<p>Age: <%= comedian.age %></p>
<p>Birthplace: <%= comedian.birthplace %></p>
<p>Specials Count: <%= comedian.specials_count %> </p>

<% comedian.specials.each do |special| %>
<p>Special Name: <%= special.name %></p>
<p>Run Time: <%= special.runtime %> minutes</p>

<% end %>
</div>
<% end %>
18 changes: 18 additions & 0 deletions app/views/comedians/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

<%= form_for Comedian.new do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>

<%= f.label :age %>
<%= f.number_field :age %>

<%= f.label :birthplace %>
<%= f.text_field :birthplace %>

<%= f.label :thumb_url %>
<%= f.text_field :thumb_url %>


<%= f.submit %>

<% end %>
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
get '/comedians', to: 'comedians#index'
get '/comedians/new', to: 'comedians#new'
post '/comedians', to: 'comedians#create'
end
12 changes: 12 additions & 0 deletions db/migrate/20190430213407_create_comedians.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateComedians < ActiveRecord::Migration[5.1]
def change
create_table :comedians do |t|
t.string :name
t.integer :age
t.string :birthplace
t.string :thumb_url

t.timestamps
end
end
end
10 changes: 10 additions & 0 deletions db/migrate/20190501213457_create_specials.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateSpecials < ActiveRecord::Migration[5.1]
def change
create_table :specials do |t|
t.string :name
t.integer :runtime

t.timestamps
end
end
end
5 changes: 5 additions & 0 deletions db/migrate/20190501220121_add_comedians_to_specials.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddComediansToSpecials < ActiveRecord::Migration[5.1]
def change
add_reference :specials, :comedian, foreign_key: true
end
end
5 changes: 5 additions & 0 deletions db/migrate/20190501233931_add_thumb_url_to_special.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddThumbUrlToSpecial < ActiveRecord::Migration[5.1]
def change
add_column :specials, :thumb_url, :string
end
end
38 changes: 38 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20190501233931) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "comedians", force: :cascade do |t|
t.string "name"
t.integer "age"
t.string "birthplace"
t.string "thumb_url"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "specials", force: :cascade do |t|
t.string "name"
t.integer "runtime"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "comedian_id"
t.string "thumb_url"
t.index ["comedian_id"], name: "index_specials_on_comedian_id"
end

add_foreign_key "specials", "comedians"
end
41 changes: 41 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,44 @@
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
comedian_1 = Comedian.create(name:"Hannibal Buress", age: 36, birthplace: "Chicago, IL", thumb_url: "https://en.wikipedia.org/wiki/Hannibal_Buress#/media/File:7.29.12HannibalBuressByEzmosis.jpg")
comedian_2 = Comedian.create(name:"Jim Gaffigan", age: 52, birthplace: "Elgin, IL", thumb_url: "https://en.wikipedia.org/wiki/Jim_Gaffigan#/media/File:Jim_Gaffigan_making_a_goofy_excited_face,_Jan_2014,_NYC_(cropped).jpg")
comedian_3 = Comedian.create(name:"Gabriel Iglesias", age:, 42 birthplace:," San Diego, CA", thumb_url: "https://www.ecosia.org/images?q=gabriel+iglesias#id=76CA5A6C05BD5FAD85F1C733E5E044CC7B39807B")
comedian_4 = Comedian.create(name:"Maria Bamford", age: 49, birthplace: "Port Hueneme, CA", thumb_url: "http://pixel.nymag.com/imgs/daily/vulture/2016/02/23/23-maria-bamford.w1200.h630.jpg")
comedian_5 = Comedian.create(name:"Aziz Ansari", age: 36, birthplace: "Columbia, SC", thumb_url: "https://www.imdb.com/name/nm2106637/mediaviewer/rm545331712")
comedian_6 = Comedian.create(name:"Ali Wong", age: 37, birthplace: "San Francisco, CA", thumb_url: "https://en.wikipedia.org/wiki/Ali_Wong#/media/File:Ali_Wong_June_2012.jpg")
comedian_7 = Comedian.create(name:"Ellen degeneres", age: 61, birthplace:,"Metarie, LA", thumb_url: "https://www.ecosia.org/images?q=ellen+degeneres#id=BEE8B0E3912B6AFACBE02BAEA3B9E5C5677175F2")
comedian_8 = Comedian.create(name:"Joan Rivers", age: 81, birthplace: "Brooklyn, NY", thumb_url: "https://en.wikipedia.org/wiki/Joan_Rivers#/media/File:Joan_Rivers_2010_-_David_Shankbone.jpg ")
comedian_9 = Comedian.create(name:"Mindy Kaling", age: 39, birthplace: "Cambridge, MA", thumb_url: "https://en.wikipedia.org/wiki/Mindy_Kaling#/media/File:Mindy_Kaling_at_PaleyFest_2013_(cropped).jpg")
comedian_10 = Comedian.create(name: "Louis C.K.", age: 51, birthplace: "Washington, D.C.", thumb_url: "https://media1.fdncms.com/pittsburgh/imager/u/blog/13239255/louis_ck_kuwait_crop_cropped.jpg?cb=1548183367")
comedian_11 = Comedian.create(name: "Kevin Hart", age: 39, birthplace: "Philadelphia, PA", thumb_url: "http://www.philly.com/resizer/bHw4bvIexfBozzYo6gSgV1vpEXk=/1400x932/center/middle/arc-anglerfish-arc2-prod-pmn.s3.amazonaws.com/public/DBTWGCGWV5C7ZJBACNCBPOCUWE.jpg")
comedian_12 = Comedian.create(name: "Dave Chappelle", age: 45, birthplace: "Washington, D.C.", thumb_url: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTII3JGyHZiZx-tRsKYcDk8jotJ6kK6yGNiCof1mLfTw5DxekFZtg")
comedian_13 = Comedian.create(name: "Chris Rock", age: 53, birthplace: "Andrews, SC", thumb_url: "https://static.independent.co.uk/s3fs-public/thumbnails/image/2018/02/14/14/chris-rock-netflix.jpg?w968")
comedian_14 = Comedian.create(name: "Ari Shaffir", age: 44, birthplace: "New York City, NY", thumb_url: "https://i2.wp.com/www.foodrepublic.com/wp-content/uploads/2016/02/Ari-Shaffir-TINH-1.jpg?resize=1400%2C2100")
comedian_15 = Comedian.create(name: "Jerry Seinfeld", age: 64, birthplace: "Brooklyn, NY", thumb_url: "https://www.gannett-cdn.com/-mm-/aec403ad632f33650ec1aa7926a673a5a6b987b8/c=420-0-2149-1300/local/-/media/2015/09/17/Westchester/Westchester/635780965457520146--ASBBrd-07-27-2012-PressMon-1-A002-2012-07-26-IMG-People-Seinfeld-7-1-4U1UD.jpg?width=534&height=401&fit=crop")

special_1 = comedian_1.special.create(name: "Comedy Cosimado", runtime: 77, thumb_url: "https://www.ecosia.org/images?q=hannibal+buress+special#id=75CCC508A9B664B20B4A73292975FD7E8D5891FA")
special_2 = comedian_1.special.create(name: "I'm Sorry You Feel That Way", runtime: 80, thumb_url: "https://m.media-amazon.com/images/M/MV5BMTk0MzI5MjAxNV5BMl5BanBnXkFtZTgwNDY1NzA0NDE@._V1_SY1000_SX675_AL_.jpg")
special_3 = comedian_2.special.create(name: "You People Are All The Same", runtime: 69, thumb_url: "https://m.media-amazon.com/images/M/MV5BMjAyZTI1NjMtNjQ3OC00MDhhLTkxMDgtMDVmMThhNjE5M2NkXkEyXkFqcGdeQXVyMTMxODk2OTU@._V1_.jpg")
special_4 = comedian_2.special.create(name: "Strange Times", runtime: 63, thumb_url: "https://m.media-amazon.com/images/M/MV5BNzc2Mzg5YmMtMzM1NC00NDgwLTljYWQtZDdkNzBmNjZkNmJhXkEyXkFqcGdeQXVyMTMxODk2OTU@._V1_.jpg")
special_5 = comedian_3.special.create(name: "Triggered", runtime: 63, thumb_url: "https://m.media-amazon.com/images/M/MV5BYTE0M2FkNGMtYjYxNi00MDRkLWE0YWUtNWI4NWU3NWIzMWIzXkEyXkFqcGdeQXVyMzE5NzI0NjE@._V1_.jpg")
special_6 = comedian_3.special.create(name: "Rocky Mountain High", runtime: 63, thumb_url: "https://m.media-amazon.com/images/M/MV5BNjI4OGY5MTktZjNiNC00MTgyLTlhZGMtMzBhYzcyZTI5YTljXkEyXkFqcGdeQXVyMTk3NDAwMzI@._V1_SY1000_SX750_AL_.jpg")
special_7 = comedian_4.special.create(name: "Oh My God", runtime: 58, thumb_url: "https://m.media-amazon.com/images/M/MV5BMjQ4NjQwOTYzNl5BMl5BanBnXkFtZTcwNjU2NjczOQ@@._V1_.jpg")
special_8 = comedian_4.special.create(name: "Live At The Beacon Theater", runtime: 63, thumb_url: "https://m.media-amazon.com/images/M/MV5BNzIxMTUxMjYzMV5BMl5BanBnXkFtZTcwMDYwMjE0Nw@@._V1_.jpg")
special_9 = comedian_5.special.create(name: "Hilarious", runtime: 88, thumb_url: "https://m.media-amazon.com/images/M/MV5BNTQyODYyNzcxN15BMl5BanBnXkFtZTgwOTA3MzcwMzE@._V1_.jpg")
special_10 = comedian_5.special.create(name: "Sociably Unacceptable", runtime: 57, thumb_url: "https://m.media-amazon.com/images/M/MV5BZTAxNTViYmUtYWU0OC00YTNhLTg3YTYtMTkwMjgzOTFkZGFmL2ltYWdlXkEyXkFqcGdeQXVyMzcwMjcwNQ@@._V1_SY1000_CR0,0,666,1000_AL_.jpg")
special_11 = comedian_6.special.create(name: "As Is", runtime: 52, thumb_url: "https://m.media-amazon.com/images/M/MV5BODY2OWIxYzMtYjEwOS00ZjRiLWI3ZGEtMWFmYTQxOTFiY2E1L2ltYWdlXkEyXkFqcGdeQXVyNTM3MDMyMDQ@._V1_.jpg")
special_12 = comedian_6.special.create(name: "Hard Knock Wife", runtime: 73, thumb_url: "https://m.media-amazon.com/images/M/MV5BMWVkZDNjZTMtMTY0Yi00OGQ0LTliMDEtMWMxYzljYzZlYTY3XkEyXkFqcGdeQXVyMTEzNjA2NzM@._V1_.jpg")
special_13 = comedian_7.special.create(name: "Let Me Explain", runtime: 75, thumb_url: "https://m.media-amazon.com/images/M/MV5BMTg4MjM2MjAxOF5BMl5BanBnXkFtZTcwMTAzOTEyOQ@@._V1_SY1000_CR0,0,673,1000_AL_.jpg")
special_14 = comedian_7.special.create(name: "What Now?", runtime: 96, thumb_url: "https://m.media-amazon.com/images/M/MV5BNzI2MDk3OTA5N15BMl5BanBnXkFtZTgwMDU1MDgxMDI@._V1_SY1000_CR0,0,674,1000_AL_.jpg")
special_15 = comedian_8.special.create(name: "Equaniminity", runtime: 60, thumb_url: "https://m.media-amazon.com/images/M/MV5BODJkMTAxNmYtZDg4OS00NzA2LTlmZTUtMDc2MjIwMzE4ZDMxXkEyXkFqcGdeQXVyMTk3NDAwMzI@._V1_.jpg")
special_16 = comedian_8.special.create(name: "Killin' Them Softly", runtime: 57, thumb_url: "https://m.media-amazon.com/images/M/MV5BMTcyOGMxN2MtYzUwYy00YzQxLTgwZTItZjAxZTIzYWM1YzEyXkEyXkFqcGdeQXVyNjExODE1MDc@._V1_.jpg")
special_17 = comedian_9.special.create(name: "Kill The Messanger", runtime: 79, thumb_url: "https://m.media-amazon.com/images/M/MV5BMjAwMjQxNDA5OF5BMl5BanBnXkFtZTcwNTE3MzM5MQ@@._V1_.jpg")
special_18 = comedian_10.special.create(name: "Bigger & Blacker", runtime: 65, thumb_url: "https://m.media-amazon.com/images/M/MV5BODQzOWExYjktZDQ2OC00YTA5LWI3YzctMDFjNjc3ZTM5NTA0XkEyXkFqcGdeQXVyMTk3NDAwMzI@._V1_.jpg")
special_19 = comedian_11.special.create(name: "Never Scared", runtime: 80, thumb_url: "https://m.media-amazon.com/images/M/MV5BMTlhYzMzNzItNWMyYy00ZGRlLWI1N2UtOGI2YjIwOGEwYTViXkEyXkFqcGdeQXVyMTk3NDAwMzI@._V1_SY1000_CR0,0,666,1000_AL_.jpg")
special_20 = comedian_12.special.create(name: "Mostly Stories", runtime: 73, thumb_url: "https://m.media-amazon.com/images/M/MV5BZWE2Nzc5N2YtOWM0OS00ZWVmLThhOTctNjNlNGI0NTQzMTU5XkEyXkFqcGdeQXVyMzAzODY0NzE@._V1_.jpg")
special_21 = comedian_13.special.create(name: "Completely Normal", runtime: 74, thumb_url: "https://m.media-amazon.com/images/M/MV5BMTcyODE0Mzk1Nl5BMl5BanBnXkFtZTgwMDk4ODE0NDE@._V1_.jpg")
special_22 = comedian_14.special.create(name: "Paid Regular", runtime: 73, thumb_url: "https://m.media-amazon.com/images/M/MV5BMjBlMGE4ZWUtZmExOC00NzcxLWFkMjMtNDYwMzczOGQ0NzRlXkEyXkFqcGdeQXVyNTMxMjgxMzA@._V1_.jpg")
special_23 = comedian_15.special.create(name: "Passive Aggressive", runtime: 60, thumb_url: "https://m.media-amazon.com/images/M/MV5BMTYzNDUyMjE4M15BMl5BanBnXkFtZTcwMTQ3NzQxOQ@@._V1_SY1000_CR0,0,647,1000_AL_.jpg")
special_24 = comedian_10.special.create(name: "No Offense", runtime: 66, thumb_url: "https://m.media-amazon.com/images/M/MV5BODMyZjU2NWQtMTI2ZC00Y2ZkLTllYjItNjNiM2Y1NTIyMmIyXkEyXkFqcGdeQXVyNjYzMDA4MTI@._V1_.jpg")
special_25 = comedian_11.special.create(name: "Jerry Before Seinfeld", runtime: 62, thumb_url: "https://m.media-amazon.com/images/M/MV5BOTc2N2I0Y2UtOTgyYy00MTU3LTk1YzItZGIwMDcxY2JkMGQzXkEyXkFqcGdeQXVyMjQzNzk2ODk@._V1_.jpg")
41 changes: 41 additions & 0 deletions spec/features/comedians_form_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require 'rails_helper'

RSpec.describe "as a user on the new comedian page", type: :feature do
before :each do
@comedian_1 = Comedian.create(name:"Maria Bamford", age: 49, birthplace: "Port Hueneme, CA", thumb_url: "http://pixel.nymag.com/imgs/daily/vulture/2016/02/23/23-maria-bamford.w1200.h630.jpg")

@comedian_2 = Comedian.create(name: "Dave Chappelle", age: 49, birthplace: "Washington, D.C.", thumb_url: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTII3JGyHZiZx-tRsKYcDk8jotJ6kK6yGNiCof1mLfTw5DxekFZtg")

@comedian_3 = Comedian.create(name: "Louis C.K.", age: 51, birthplace: "Washington, D.C.", thumb_url: "https://media1.fdncms.com/pittsburgh/imager/u/blog/13239255/louis_ck_kuwait_crop_cropped.jpg?cb=1548183367")
end

describe "I see a form for a new comedian" do
it "shows the comedians name age and birthplace fields" do

visit '/comedians/new'

#expect to see place for name, age, city
expect(page).to have_content("Name")
expect(page).to have_content("Age")
expect(page).to have_content("Birthplace")
expect(page).to have_button("Create Comedian")
end

it "successfully accepts, saves, and redirects upon submission" do
visit '/comedians/new'

fill_in 'comedian[name]', with: "Mills"
fill_in 'comedian[age]', with: 36
fill_in 'comedian[birthplace]', with: "Pearl River, LA"

click_button "Create Comedian"

expect(current_path).to eq('/comedians')

@new_comedian = Comedian.last
within("#Comedian-#{@new_comedian.id}") do
expect(page).to have_content(@new_comedian.name)
end
end
end
end
Loading