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):
Average rating: <%= book.average_rating %> out of 5
diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb index a930c84..1317faa 100644 --- a/app/views/books/show.html.erb +++ b/app/views/books/show.html.erb @@ -7,21 +7,21 @@Author(s):
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 %> 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 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 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")