Sha256: 7eed8296d9cc5634f60b86cd1dcb681ba6928d30ecbf63b22d7ba56426809e76
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true require 'rails_helper' RSpec.describe Rating::Rate, ':rate_for' do let!(:user) { create :user } let!(:article) { create :article } context 'with no scopeable' do context 'when rate does not exist' do specify { expect(described_class.rate_for(author: user, resource: article)).to eq nil } end context 'when rate does not exist' do before { described_class.create author: user, resource: article, value: 3 } it 'returns the record' do expect(described_class.rate_for(author: user, resource: article)).to eq described_class.last end end end context 'with scopeable' do let!(:category) { create :category } context 'when rate does not exist' do specify { expect(described_class.rate_for(author: user, resource: article, scopeable: category)).to eq nil } end context 'when rate does not exist' do before { described_class.create author: user, resource: article, scopeable: category, value: 3 } it 'returns the record' do query = described_class.rate_for(author: user, resource: article, scopeable: category) expect(query).to eq described_class.last end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rating-0.2.0 | spec/models/rate/rate_for_spec.rb |