rating/spec/models/extension/rate_for_spec.rb

42 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

2017-10-30 01:44:23 +00:00
# frozen_string_literal: true
RSpec.describe Rating::Extension, ':rate_for' do
let!(:author) { create :author }
2017-10-30 01:44:23 +00:00
let!(:article) { create :article }
2017-11-02 18:55:46 +00:00
context 'with no scopeable' do
it 'delegates to rate object' do
2022-04-21 22:57:48 +00:00
expect(Rating::Rate).to receive(:rate_for).with author: author, extra_scopes: {}, resource: article,
scopeable: nil
2017-10-30 01:44:23 +00:00
author.rate_for article
2017-11-02 18:55:46 +00:00
end
end
context 'with scopeable' do
let!(:category) { build :category }
it 'delegates to rate object' do
2022-04-21 22:57:48 +00:00
expect(Rating::Rate).to receive(:rate_for).with author: author, extra_scopes: {}, resource: article,
scopeable: category
2017-11-02 18:55:46 +00:00
author.rate_for article, scope: category
2017-11-02 18:55:46 +00:00
end
2017-10-30 01:44:23 +00:00
end
2018-03-01 20:50:28 +00:00
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
2017-10-30 01:44:23 +00:00
end