Sha256: 5d41637a85ad799571783f71126c8e2d101a6152206d6eb93c493a1c6fc5938e

Contents?: true

Size: 772 Bytes

Versions: 1

Compression:

Stored size: 772 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Rating::Extension, ':after_create' do
  context 'with :as as nil' do
    let!(:user) { create :user }

    it 'creates a rating record with zero values just to be easy to make the count' do
      rating = Rating::Rating.find_by(resource: user)

      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
    end
  end

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rating-0.2.0 spec/models/extension/after_create_spec.rb