Sha256: 881d5779e48cdcca167065488081b167ba396826868ae30fdc796231a11f1cea

Contents?: true

Size: 842 Bytes

Versions: 5

Compression:

Stored size: 842 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'
require 'support/shared_context/with_database_records'

RSpec.describe Voting::Voting, ':update_voting' do
  include_context 'with_database_records'

  context 'with no scopeable' do
    it 'updates the voting data of the given resource' do
      record = described_class.find_by(resource: comment_1)

      expect(record.estimate).to eq 0.2923292797006548
      expect(record.negative).to eq 1
      expect(record.positive).to eq 2
    end
  end

  context 'with scopeable' do
    it 'updates the voting data of the given resource respecting the scope' do
      record = described_class.find_by(resource: comment_1, scopeable: category)

      expect(record.estimate).to eq 0.1711859764448097
      expect(record.negative).to eq 1
      expect(record.positive).to eq 1
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
voting-0.5.0 spec/models/voting/update_voting_spec.rb
voting-0.4.0 spec/models/voting/update_voting_spec.rb
voting-0.3.0 spec/models/voting/update_voting_spec.rb
voting-0.2.0 spec/models/voting/update_voting_spec.rb
voting-0.1.0 spec/models/voting/update_voting_spec.rb