2016-03-28 07:41:00 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe NotificationSetting, type: :model do
|
|
|
|
describe "Associations" do
|
|
|
|
it { is_expected.to belong_to(:user) }
|
2016-03-28 17:22:28 -04:00
|
|
|
it { is_expected.to belong_to(:source) }
|
2016-03-28 07:41:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "Validation" do
|
2016-03-29 07:42:48 -04:00
|
|
|
subject { NotificationSetting.new(source_id: 1, source_type: 'Project') }
|
2016-03-28 07:41:00 -04:00
|
|
|
|
|
|
|
it { is_expected.to validate_presence_of(:user) }
|
|
|
|
it { is_expected.to validate_presence_of(:source) }
|
|
|
|
it { is_expected.to validate_presence_of(:level) }
|
2016-03-29 07:42:48 -04:00
|
|
|
it { is_expected.to validate_uniqueness_of(:user_id).scoped_to([:source_id, :source_type]).with_message(/already exists in source/) }
|
2016-03-28 07:41:00 -04:00
|
|
|
end
|
|
|
|
end
|