mirror of
https://github.com/iritmaximus/brewery.git
synced 2026-10-12 19:13:49 +03:00
4.7 test that user ratings are shown on the user's page
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<h2>List of ratings</h2>
|
||||
<p>There is <%= pluralize @ratings.count, "rating" %></p>
|
||||
|
||||
<ul>
|
||||
<% @ratings.each do |rating| %>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
FactoryBot.define do
|
||||
factory :user do
|
||||
username { "Möötti" }
|
||||
username { "MööttiTesti" }
|
||||
password { "Unsecure1" }
|
||||
password_confirmation { "Unsecure1" }
|
||||
end
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Ratings Page" do
|
||||
it "should not contain anything in the beginning" do
|
||||
visit ratings_path
|
||||
expect(page).to have_content "List of ratings"
|
||||
expect(page).to have_content "There is 0 ratings"
|
||||
|
||||
FactoryBot.create :rating
|
||||
|
||||
visit ratings_path
|
||||
expect(page).to have_content "There is 1 rating"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,21 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "User Page" do
|
||||
let(:user) { FactoryBot.create :user }
|
||||
let(:rating1) { Rating.create score: 20, user_id: user.id, beer_id: Beer.first.id }
|
||||
let(:rating2) { Rating.create score: 30, user_id: user.id, beer_id: Beer.first.id }
|
||||
|
||||
it "should display only user's ratings" do
|
||||
# this took over an hour to remember to do... :D
|
||||
rating1.save()
|
||||
rating2.save()
|
||||
|
||||
visit user_path(user.id)
|
||||
|
||||
expect(page).to have_content "Username: MööttiTesti"
|
||||
expect(page).to have_content "Has made 2 ratings"
|
||||
|
||||
expect(page).to have_content "Iso 3 20"
|
||||
expect(page).to have_content "Iso 3 30"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user