spec/models/rate/rate_for_spec.rb in rating-0.8.0 vs spec/models/rate/rate_for_spec.rb in rating-0.9.0
- old
+ new
@@ -49,57 +49,59 @@
expect(query).to eq record
end
end
end
- context 'with extra scopes' do
- let!(:category) { create :category }
+ if ENV['CONFIG_ENABLED_WITH_EXTRA_SCOPES'] == 'true'
+ context 'with extra scopes' do
+ let!(:category) { create :category }
- context 'when matches all attributes including the extra scopes' do
- let!(:record) do
- described_class.create(
- author: author,
- extra_scopes: { scope_1: 'scope_1', scope_2: 'scope_2' },
- metadata: {},
- resource: article,
- scopeable: category,
- value: 1
- )
- end
+ context 'when matches all attributes including the extra scopes' do
+ let!(:record) do
+ described_class.create(
+ author: author,
+ extra_scopes: { scope_1: 'scope_1', scope_2: 'scope_2' },
+ metadata: {},
+ resource: article,
+ scopeable: category,
+ value: 1
+ )
+ end
- it 'returns the record' do
- result = described_class.rate_for(
- author: author,
- extra_scopes: { scope_1: 'scope_1', scope_2: 'scope_2' },
- resource: article,
- scopeable: category
- )
+ it 'returns the record' do
+ result = described_class.rate_for(
+ author: author,
+ extra_scopes: { scope_1: 'scope_1', scope_2: 'scope_2' },
+ resource: article,
+ scopeable: category
+ )
- expect(result).to eq record
+ expect(result).to eq record
+ end
end
- end
- context 'when matches all attributes but at least one extra scopes' do
- before do
- described_class.create(
- author: author,
- extra_scopes: { scope_1: 'scope_1', scope_2: 'scope_2' },
- metadata: {},
- resource: article,
- scopeable: category,
- value: 1
- )
- end
+ context 'when matches all attributes but at least one extra scopes' do
+ before do
+ described_class.create(
+ author: author,
+ extra_scopes: { scope_1: 'scope_1', scope_2: 'scope_2' },
+ metadata: {},
+ resource: article,
+ scopeable: category,
+ value: 1
+ )
+ end
- it 'does not return the record' do
- result = described_class.rate_for(
- author: author,
- extra_scopes: { scope_1: 'scope_1', scope_2: 'scope_missing' },
- resource: article,
- scopeable: category
- )
+ it 'does not return the record' do
+ result = described_class.rate_for(
+ author: author,
+ extra_scopes: { scope_1: 'scope_1', scope_2: 'scope_missing' },
+ resource: article,
+ scopeable: category
+ )
- expect(result).to eq nil
+ expect(result).to eq nil
+ end
end
end
- end if ENV['CONFIG_ENABLED_WITH_EXTRA_SCOPES'] == 'true'
+ end
end