Sha256: 9f4297cba66e171bd9b14f6d43654b0f9e8e40608488fa0e5da6fc78c2898de5

Contents?: true

Size: 681 Bytes

Versions: 1

Compression:

Stored size: 681 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

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

  context 'with no scopeable' do
    it 'delegates to rate object' do
      expect(Rating::Rate).to receive(:create).with author: user, resource: article, scopeable: nil, value: 3

      user.rate article, 3
    end
  end

  context 'with scopeable' do
    let!(:category) { build :category }

    it 'delegates to rate object' do
      expect(Rating::Rate).to receive(:create).with author: user, resource: article, scopeable: category, value: 3

      user.rate article, 3, scope: category
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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