fixed tests after migration

This commit is contained in:
Aaro Koivukangas
2023-11-29 20:41:23 +02:00
parent 10fee9e695
commit 365dc892f8
9 changed files with 37 additions and 24 deletions
+1
View File
@@ -2,6 +2,7 @@ class Beer < ApplicationRecord
include RatingAverage
belongs_to :brewery
belongs_to :style
has_many :ratings, dependent: :destroy
has_many :users, through: :ratings
+2 -1
View File
@@ -36,9 +36,10 @@ class User < ApplicationRecord
items = {}
ratings.each do |rating|
style = Style.find_by_id rating.beer.style_id
attributes = {
# create hash with key being style name and value first 0 and then the score
"styles" => rating.beer.style,
"styles" => style.name,
# iterate through ratings and add scores depending on
# which brewery the beer that was rated was made in
"breweries" => rating.beer.brewery.name