Change validation scope and Fix tests

This commit is contained in:
Kaustubh Nair 2019-04-06 00:09:20 +05:30
parent b9cb0804ef
commit 9fdd372f18
2 changed files with 3 additions and 5 deletions

View file

@ -8,12 +8,10 @@ describe Vote do
let(:vote) { create(:vote, event: event, user: user) }
describe 'validation' do
it { is_expected.to validate_uniqueness_of(:user_id).scoped_to(:event_id) }
it 'has a valid factory' do
expect(build(:vote)).to be_valid
end
it 'validates uniqueness of event in scope of user' do
expect(build(:vote, event: vote.event, user: vote.user)).not_to be_valid
end
end
end