2017-10-30 01:44:23 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe Rating::Extension, ':after_create' do
|
2017-11-03 02:02:23 +00:00
|
|
|
context 'with :as as nil' do
|
2017-10-30 01:44:23 +00:00
|
|
|
let!(:user) { create :user }
|
|
|
|
|
2017-11-03 02:02:23 +00:00
|
|
|
it 'creates a rating record with zero values just to be easy to make the count' do
|
2017-10-30 01:44:23 +00:00
|
|
|
rating = Rating::Rating.find_by(resource: user)
|
|
|
|
|
2017-11-02 18:55:46 +00:00
|
|
|
expect(rating.average).to eq 0
|
|
|
|
expect(rating.estimate).to eq 0
|
|
|
|
expect(rating.resource).to eq user
|
|
|
|
expect(rating.scopeable).to eq nil
|
|
|
|
expect(rating.sum).to eq 0
|
|
|
|
expect(rating.total).to eq 0
|
2017-10-30 01:44:23 +00:00
|
|
|
end
|
|
|
|
end
|
2017-11-03 02:02:23 +00:00
|
|
|
|
|
|
|
context 'with :as as :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
|
2017-10-30 01:44:23 +00:00
|
|
|
end
|