Sha256: b53570e13e8e35b934dc50320fd19e73787d683b9c9295f898feb67fc3d7e6b6

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

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

  context 'with no scopeable' do
    it 'delegates to rate object' do
      expect(Rating::Rate).to receive(:rate_for).with author: author, extra_scopes: {}, resource: article, scopeable: nil

      author.rate_for article
    end
  end

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

    it 'delegates to rate object' do
      expect(Rating::Rate).to receive(:rate_for).with author: author, extra_scopes: {}, resource: article, scopeable: category

      author.rate_for article, scope: category
    end
  end

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

    it 'delegates to rate object' do
      expect(Rating::Rate).to receive(:rate_for).with(
        author:       author,
        extra_scopes: { scope_1: 'scope_1' },
        resource:     article,
        scopeable:    category
      )

      author.rate_for article, extra_scopes: { scope_1: 'scope_1' }, scope: category
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rating-0.11.0 spec/models/extension/rate_for_spec.rb
rating-0.10.0 spec/models/extension/rate_for_spec.rb
rating-0.9.0 spec/models/extension/rate_for_spec.rb
rating-0.8.0 spec/models/extension/rate_for_spec.rb
rating-0.7.0 spec/models/extension/rate_for_spec.rb