From 630c86a7a36cee36ed6b9c93644a6cb51e2b3b23 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 29 Mar 2016 13:42:48 +0200 Subject: Add spec for user_id uniq in NotificationSetting model Signed-off-by: Dmitriy Zaporozhets --- spec/models/notification_setting_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/models/notification_setting_spec.rb b/spec/models/notification_setting_spec.rb index f31b2a3cd6f..295081e9da1 100644 --- a/spec/models/notification_setting_spec.rb +++ b/spec/models/notification_setting_spec.rb @@ -7,10 +7,11 @@ RSpec.describe NotificationSetting, type: :model do end describe "Validation" do - subject { NotificationSetting.new } + subject { NotificationSetting.new(source_id: 1, source_type: 'Project') } it { is_expected.to validate_presence_of(:user) } it { is_expected.to validate_presence_of(:source) } it { is_expected.to validate_presence_of(:level) } + it { is_expected.to validate_uniqueness_of(:user_id).scoped_to([:source_id, :source_type]).with_message(/already exists in source/) } end end -- cgit v1.2.1