spec/models/rating/update_rating_spec.rb in rating-0.2.0 vs spec/models/rating/update_rating_spec.rb in rating-0.3.0
- old
+ new
@@ -1,27 +1,11 @@
# frozen_string_literal: true
require 'rails_helper'
+require 'support/shared_context/with_database_records'
RSpec.describe Rating::Rating, ':update_rating' 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 }
-
- before do
- create :rating_rate, author: user_1, resource: article_1, value: 100
- create :rating_rate, author: user_1, resource: article_2, value: 11
- create :rating_rate, author: user_1, resource: article_3, value: 10
- create :rating_rate, author: user_2, resource: article_1, value: 1
-
- create :rating_rate, author: user_1, resource: article_1, scopeable: category, value: 1
- create :rating_rate, author: user_2, resource: article_1, scopeable: category, value: 2
- end
+ include_context 'with_database_records'
context 'with no scopeable' do
it 'updates the rating data of the given resource' do
record = described_class.find_by(resource: article_1)