rating/spec/models/extension/after_create_spec.rb

29 lines
784 B
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Rating::Extension, ':after_create' do
context 'when :as is nil' do
let!(:article) { create :article }
it 'creates a rating record with zero values just to be easy to make the count' do
rating = Rating::Rating.find_by(resource: article)
expect(rating.average).to eq 0
expect(rating.estimate).to eq 0
expect(rating.resource).to eq article
expect(rating.scopeable).to eq nil
expect(rating.sum).to eq 0
expect(rating.total).to eq 0
end
end
context 'when :as is :author' do
let!(:author) { create :author }
it 'does not creates a rating record' do
expect(Rating::Rating.exists?(resource: author)).to eq false
end
end
end