diff --git a/app/models/notification_type.rb b/app/models/notification_type.rb index dfe17d457e1..ffb4e97be5b 100644 --- a/app/models/notification_type.rb +++ b/app/models/notification_type.rb @@ -11,7 +11,7 @@ class NotificationType < ApplicationRecord validates :level, :inclusion => { :in => %w(success error warning info) } validates :link_to, :inclusion => { :in => %w(subject initiator cause) }, :allow_blank => true validates :audience, :inclusion => { - :in => [AUDIENCE_USER, AUDIENCE_GROUP, AUDIENCE_TENANT, AUDIENCE_GLOBAL, AUDIENCE_SUPERADMIN] + :in => [AUDIENCE_USER, AUDIENCE_GROUP, AUDIENCE_TENANT, AUDIENCE_GLOBAL, AUDIENCE_SUPERADMIN, AUDIENCE_NONE] } def subscriber_ids(subject, initiator) diff --git a/spec/models/notification_type_spec.rb b/spec/models/notification_type_spec.rb index 114d4a7b9e6..bb084d69151 100644 --- a/spec/models/notification_type_spec.rb +++ b/spec/models/notification_type_spec.rb @@ -44,4 +44,12 @@ end end end + + describe "#enabled?" do + it "detects properly" do + expect(FactoryGirl.build(:notification_type, :audience => NotificationType::AUDIENCE_USER)).to be_enabled + expect(FactoryGirl.build(:notification_type, :audience => NotificationType::AUDIENCE_NONE)).not_to be_enabled + expect(FactoryGirl.build(:notification_type, :audience => NotificationType::AUDIENCE_NONE)).to be_valid + end + end end