From 0ef66f7c27ba051b45be1645e04ab57cf377aa23 Mon Sep 17 00:00:00 2001 From: Matt Levy Date: Sat, 23 Mar 2019 12:45:07 -0600 Subject: [PATCH 1/5] Revised book show page statistics. It had a typo for Bottom and the each statement was displaying with <%= > instead of <% > --- app/views/books/show.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb index a930c84..14f9f58 100644 --- a/app/views/books/show.html.erb +++ b/app/views/books/show.html.erb @@ -14,14 +14,14 @@ <% unless @book.reviews.empty? %>

Top Reviews

- <%= @book.grab_reviews('top', 3).each do |review| %> + <% @book.grab_reviews('top', 3).each do |review| %>

Title: <%= review.title %>, Rating: <%= review.rating %>, User: <%= link_to review.username %>

<% end %>
-

Bottome Reviews

- <%= @book.grab_reviews('bottom', 3).each do |review| %> +

Bottom Reviews

+ <% @book.grab_reviews('bottom', 3).each do |review| %>

Title: <%= review.title %>, Rating: <%= review.rating %>, User: <%= link_to review.username %>

<% end %> <% else %> From 3f36312320241e9559e69073a62e6111c571fb82 Mon Sep 17 00:00:00 2001 From: Matt Levy Date: Sat, 23 Mar 2019 12:52:15 -0600 Subject: [PATCH 2/5] Added author show page spec for the co authors names to be links to their author show page --- spec/features/author_show_spec.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/spec/features/author_show_spec.rb b/spec/features/author_show_spec.rb index a971f89..dee70da 100644 --- a/spec/features/author_show_spec.rb +++ b/spec/features/author_show_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe 'As a visitor', type: :feature do +RSpec.describe 'As a visitor to an author show page', type: :feature do it 'shows all books by that author' do author = Author.create(name: 'Bob') book_1 = author.books.create(thumbnail: 'steve.jpg', title: 'book title 1', pages: 40, year_published: 1987) @@ -60,4 +60,19 @@ expect(page).to have_link("Steve") end end + + it 'shows co authors as links to their author show page' do + author = Author.create(name: 'Bob') + author_2 = Author.create(name: 'Monkey') + author_3 = Author.create(name: 'Steve') + book_1 = author.books.create(thumbnail: 'steve.jpg', title: 'book title 1', pages: 40, year_published: 1987) + book_2 = Book.create(thumbnail: 'andrew.jpg', title: 'book title 2', pages: 456, year_published: 1978, authors: [author, author_2, author_3]) + + visit author_path(author) + + within "#book-#{book_2.id}" do + expect(page).to have_link("Monkey", href: author_path(author_2)) + expect(page).to have_link("Steve", href: author_path(author_3)) + end + end end From cab9ba3720c69b4626a852caf44aaddaf3a63649 Mon Sep 17 00:00:00 2001 From: Matt Levy Date: Sat, 23 Mar 2019 12:56:45 -0600 Subject: [PATCH 3/5] Added book index spec for author names to be links to their author show page --- spec/features/book_index_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/features/book_index_spec.rb b/spec/features/book_index_spec.rb index f8ab550..d81e7b9 100644 --- a/spec/features/book_index_spec.rb +++ b/spec/features/book_index_spec.rb @@ -15,7 +15,7 @@ expect(page).to have_link("where the wild things are", href: book_path(book_1)) expect(page).to have_content("Page Count: #{book_1.pages}") expect(page).to have_content("Year Published: 1987") - expect(page).to have_link(author.name) + expect(page).to have_link(author.name, href: author_path(author)) end within "#book-#{book_2.id}" do @@ -23,7 +23,7 @@ expect(page).to have_link("Whatever", href: book_path(book_2)) expect(page).to have_content("Page Count: 230") expect(page).to have_content("Year Published: 2019") - expect(page).to have_link("bob") + expect(page).to have_link("bob", href: author_path(author)) end within "#book-#{book_3.id}" do @@ -31,8 +31,8 @@ expect(page).to have_link("meh", href: book_path(book_3)) expect(page).to have_content("Page Count: 456") expect(page).to have_content("Year Published: 1978") - expect(page).to have_link("bob") - expect(page).to have_link("monkey") + expect(page).to have_link("bob", href: author_path(author)) + expect(page).to have_link("monkey", href: author_path(author_2)) end end From 31f8a0549a3a3cf667e7ba51218f6f3b1b2a5fe9 Mon Sep 17 00:00:00 2001 From: Matt Levy Date: Sat, 23 Mar 2019 12:57:03 -0600 Subject: [PATCH 4/5] Added author show page links to book index view --- app/views/books/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/books/index.html.erb b/app/views/books/index.html.erb index f14485a..73026d9 100644 --- a/app/views/books/index.html.erb +++ b/app/views/books/index.html.erb @@ -10,7 +10,7 @@

Author(s):

    <% book.authors.each do |author| %> -
  • <%= link_to author.name %>
  • +
  • <%= link_to author.name, author_path(author) %>
  • <% end %>

Average rating: <%= book.average_rating %> out of 5

From 03903a7dbaff3171b89baaf9d018b5fe9d6aea74 Mon Sep 17 00:00:00 2001 From: Matt Levy Date: Sat, 23 Mar 2019 12:59:20 -0600 Subject: [PATCH 5/5] Added spec and view for author names to be links on the book show page view --- app/views/books/show.html.erb | 2 +- spec/features/book_show_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb index 14f9f58..1317faa 100644 --- a/app/views/books/show.html.erb +++ b/app/views/books/show.html.erb @@ -7,7 +7,7 @@

Author(s):

    <% @book.authors.each do |author| %> -
  • <%= link_to author.name %>
  • +
  • <%= link_to author.name, author_path(author) %>
  • <% end %>
diff --git a/spec/features/book_show_spec.rb b/spec/features/book_show_spec.rb index 6264c07..d4ce0fa 100644 --- a/spec/features/book_show_spec.rb +++ b/spec/features/book_show_spec.rb @@ -16,8 +16,8 @@ expect(page).to have_content("Title: Where The Wild Things Are") expect(page).to have_content("Page Count: 40") expect(page).to have_content("Year Published: 1987") - expect(page).to have_content("Author 1 name") - expect(page).to have_content("Author 2 name") + expect(page).to have_link("Author 1 name", href: author_path(author_1)) + expect(page).to have_link("Author 2 name", href: author_path(author_2)) end end @@ -115,7 +115,7 @@ book = author.books.create(thumbnail: 'steve.jpg', title: 'where the wild things are', pages: 40, year_published: 1987) visit book_path(book) - + expect(page).to_not have_content("Top Reviews") expect(page).to_not have_content("Bottom Reviews") expect(page).to have_link("Be the first to review this book")