Commit 630c86a7 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add spec for user_id uniq in NotificationSetting model

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 86418c47
...@@ -7,10 +7,11 @@ RSpec.describe NotificationSetting, type: :model do ...@@ -7,10 +7,11 @@ RSpec.describe NotificationSetting, type: :model do
end end
describe "Validation" do 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(:user) }
it { is_expected.to validate_presence_of(:source) } it { is_expected.to validate_presence_of(:source) }
it { is_expected.to validate_presence_of(:level) } 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
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment