summaryrefslogtreecommitdiff
path: root/spec/models/notification_setting_spec.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-03-29 13:42:48 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-03-30 10:44:20 +0200
commit630c86a7a36cee36ed6b9c93644a6cb51e2b3b23 (patch)
tree4d2be6c3072abf596fae06a4479c096613af7a53 /spec/models/notification_setting_spec.rb
parent86418c475be1b2a37e89682bc87055b7372bbcfb (diff)
downloadgitlab-ce-630c86a7a36cee36ed6b9c93644a6cb51e2b3b23.tar.gz
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.rb3
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