Sha256: 0c9d0c238256d6876d592166a5e7e3cc9593f43bcd0cc74f7418cc18abeebbf5

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Rating::Extension, '.rated_records' do
  let!(:category) { create :category }

  let!(:user_1) { create :user }
  let!(:user_2) { create :user }

  let!(:article_1) { create :article }
  let!(:article_2) { create :article }
  let!(:article_3) { create :article }

  let!(:rate_1) { create :rating_rate, author: user_1, resource: article_1, value: 100 }
  let!(:rate_2) { create :rating_rate, author: user_1, resource: article_2, value: 11 }
  let!(:rate_3) { create :rating_rate, author: user_1, resource: article_3, value: 10 }
  let!(:rate_4) { create :rating_rate, author: user_2, resource: article_1, value: 1 }

  let!(:rate_5) { create :rating_rate, author: user_1, resource: article_1, scopeable: category, value: 1 }
  let!(:rate_6) { create :rating_rate, author: user_2, resource: article_1, scopeable: category, value: 2 }

  it 'returns all rates that this author gave' do
    expect(user_1.rated_records).to match_array [rate_1, rate_2, rate_3, rate_5]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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