rating/spec/models/rating_spec.rb

25 lines
721 B
Ruby
Raw Normal View History

2017-10-30 01:44:23 +00:00
# frozen_string_literal: true
2022-05-18 02:42:51 +00:00
require 'support/shoulda'
2017-10-30 01:44:23 +00:00
2022-05-18 02:42:51 +00:00
RSpec.describe Rating::Rating, type: :model do
let!(:object) { build(:rating_rating) }
2017-10-30 01:44:23 +00:00
2022-05-18 02:42:51 +00:00
it { expect(object.valid?).to be(true) }
2017-10-30 01:44:23 +00:00
2022-05-18 02:42:51 +00:00
it { is_expected.to belong_to(:resource) }
it { is_expected.to belong_to(:scopeable) }
2017-10-30 01:44:23 +00:00
2022-05-18 02:42:51 +00:00
it { is_expected.to validate_presence_of(:average) }
it { is_expected.to validate_presence_of(:estimate) }
it { is_expected.to validate_presence_of(:resource) }
it { is_expected.to validate_presence_of(:sum) }
it { is_expected.to validate_presence_of(:total) }
it do
expect(object).to validate_uniqueness_of(:resource_id)
.scoped_to(%i[resource_type scopeable_id scopeable_type])
.case_insensitive
end
2017-10-30 01:44:23 +00:00
end