Fixed specs
This commit is contained in:
parent
123c943637
commit
bea495cd8a
@ -127,8 +127,14 @@ class Recipe < Ingredient
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_rating!
|
def update_rating!
|
||||||
self.rating = Log.for_recipe(self).for_user(self.user_id).where('rating IS NOT NULL').average(:rating)
|
logs = Log.for_recipe(self).for_user(self.user_id).where('rating IS NOT NULL')
|
||||||
save(validate: false)
|
if logs.count > 0
|
||||||
|
self.rating = logs.average(:rating)
|
||||||
|
save(validate: false)
|
||||||
|
else
|
||||||
|
self.rating = nil
|
||||||
|
end
|
||||||
|
self.rating
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates a copy of this recipe suitable for associating to a log
|
# Creates a copy of this recipe suitable for associating to a log
|
||||||
|
@ -11,11 +11,11 @@ RSpec.describe UnitConversion::ParsedNumber do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'converts decimal numbers' do
|
it 'converts decimal numbers' do
|
||||||
expect(UnitConversion::ParsedNumber.new('1.0').value).to eq BigDecimal.new("1")
|
expect(UnitConversion::ParsedNumber.new('1.0').value).to eq BigDecimal("1")
|
||||||
expect(UnitConversion::ParsedNumber.new('-1.0').value).to eq BigDecimal.new("-1")
|
expect(UnitConversion::ParsedNumber.new('-1.0').value).to eq BigDecimal("-1")
|
||||||
expect(UnitConversion::ParsedNumber.new('54.33').value).to eq BigDecimal.new("54.33")
|
expect(UnitConversion::ParsedNumber.new('54.33').value).to eq BigDecimal("54.33")
|
||||||
expect(UnitConversion::ParsedNumber.new('-54.33').value).to eq BigDecimal.new("-54.33")
|
expect(UnitConversion::ParsedNumber.new('-54.33').value).to eq BigDecimal("-54.33")
|
||||||
expect(UnitConversion::ParsedNumber.new('.33').value).to eq BigDecimal.new("0.33")
|
expect(UnitConversion::ParsedNumber.new('.33').value).to eq BigDecimal("0.33")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'converts simple fractions' do
|
it 'converts simple fractions' do
|
||||||
|
Loading…
Reference in New Issue
Block a user