Sha256: 2dc4e7fd5bcdd1af7aea05e17732177772d221cab146c8256f1278f57379f504
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
# frozen_string_literal: true require 'rails_helper' RSpec.describe Rating::Extension, ':rated?' do let!(:author) { create :author } let!(:resource) { create :article } context 'with no scopeable' do before { author.rate resource, 1 } context 'when has no rate for the given resource' do specify { expect(author.rated?(create(:article))).to eq false } end context 'when has rate for the given resource' do specify { expect(author.rated?(resource)).to eq true } end end context 'with scopeable' do let!(:category) { create :category } before { author.rate resource, 1, scope: category } context 'when has no rate for the given resource' do specify { expect(author.rated?(resource, scope: create(:category))).to eq false } end context 'when has rate for the given resource' do specify { expect(author.rated?(resource, scope: category)).to eq true } end end context 'with extra scopes' do before { author.rate resource, 1, extra_scopes: { scope_1: 'scope_1' } } context 'when has no rate for the given resource with given extra scopes' do specify { expect(author.rated?(resource, extra_scopes: { scope_1: 'missing' })).to eq false } end context 'when has rate for the given resource with given extra scopes' do specify { expect(author.rated?(resource, extra_scopes: { scope_1: 'scope_1' })).to eq true } end end if ENV['CONFIG_ENABLED_WITH_EXTRA_SCOPES'] == 'true' end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rating-0.8.0 | spec/models/extension/rated_question_spec.rb |
rating-0.7.0 | spec/models/extension/rated_question_spec.rb |