Sha256: 856d797183d5b0b7492970344929e304f557aed3df1103bc141a0b8ec7adde8f

Contents?: true

Size: 784 Bytes

Versions: 2

Compression:

Stored size: 784 Bytes

Contents

# 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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rating-0.4.0 spec/models/extension/after_create_spec.rb
rating-0.3.0 spec/models/extension/after_create_spec.rb