diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-03-29 14:42:48 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-03-30 11:44:20 +0300 |
commit | 630c86a7a36cee36ed6b9c93644a6cb51e2b3b23 (patch) | |
tree | 4d2be6c3072abf596fae06a4479c096613af7a53 /spec/models/notification_setting_spec.rb | |
parent | 86418c475be1b2a37e89682bc87055b7372bbcfb (diff) |
Add spec for user_id uniq in NotificationSetting model
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec/models/notification_setting_spec.rb')
-rw-r--r-- | spec/models/notification_setting_spec.rb | 3 |
1 files changed, 2 insertions, 1 deletions
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 |