Sha256: 32e3d4c812d7172aec6cff927f4397ec9d5ae56a158fbbc68b29b0a5c3be152d

Contents?: true

Size: 846 Bytes

Versions: 1

Compression:

Stored size: 846 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Rating::Extension, ':rates' do
  let!(:user)    { create :user }
  let!(:article) { create :article }

  before { user.rate article, 3 }

  it 'returns rates record' do
    expect(article.rates).to eq [Rating::Rate.last]
  end

  context 'when destroy author' do
    before do
      expect(Rating::Rate.where(resource: article).count).to eq 1

      user.destroy!
    end

    it 'destroys rates of that resource' do
      expect(Rating::Rate.where(resource: article).count).to eq 0
    end
  end

  context 'when destroy resource' do
    before do
      expect(Rating::Rate.where(resource: article).count).to eq 1

      article.destroy!
    end

    it 'destroys rates of that resource' do
      expect(Rating::Rate.where(resource: article).count).to eq 0
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rating-0.1.0 spec/models/extension/rates_spec.rb