Sha256: f3882af46c2c88c6e1e428a37b6985dfaabecafdb2770953b886d57cf422d524

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Voting::Extension, 'after_create' do
  context 'when record is author' do
    let!(:record) { build :author }

    it 'does warm up the cache' do
      expect(record).not_to receive(:voting_warm_up)

      record.save
    end
  end

  context 'when record is not author' do
    context 'when record has scoping' do
      let!(:record) { build :article }

      it 'warms up the cache' do
        expect(record).to receive(:voting_warm_up).with(scoping: :categories)

        record.save
      end
    end

    context 'when record has no scoping' do
      let!(:record) { build :comment }

      it 'warms up the cache' do
        expect(record).to receive(:voting_warm_up).with(scoping: nil)

        record.save
      end
    end

    context 'when update is made' do
      let!(:record) { create :comment }

      it 'does not warm up the cache' do
        expect(record).not_to receive(:voting_warm_up)

        record.save
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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