diff --git a/app/models/system_notification.rb b/app/models/system_notification.rb index 310d5542f..717f51464 100644 --- a/app/models/system_notification.rb +++ b/app/models/system_notification.rb @@ -16,15 +16,10 @@ class SystemNotification < ApplicationRecord has_many :user_system_notifications has_many :users, through: :user_system_notifications - validates :title, :modal_title, :modal_body, :description, - :source_created_at, :source_id, :last_time_changed_at, + validates :title, :modal_title, :modal_body, :description, :source_created_at, :source_id, :last_time_changed_at, presence: true - - validates :title, :description, :modal_title, - length: { maximum: Constants::NAME_MAX_LENGTH } - - validates :modal_body, - length: { maximum: Constants::RICH_TEXT_MAX_LENGTH } + validates :title, :description, :modal_title, length: { maximum: Constants::NAME_MAX_LENGTH } + validates :modal_body, length: { maximum: Constants::RICH_TEXT_MAX_LENGTH } def self.last_notifications( user, diff --git a/spec/models/system_notification_spec.rb b/spec/models/system_notification_spec.rb index cd72ee6f4..d309ed03f 100644 --- a/spec/models/system_notification_spec.rb +++ b/spec/models/system_notification_spec.rb @@ -3,8 +3,7 @@ require 'rails_helper' describe SystemNotification do - let(:user) { create :user } - subject(:system_notification) { build :system_notification } + let(:system_notification) { build :system_notification } it 'is valid' do expect(system_notification).to be_valid @@ -77,6 +76,7 @@ describe SystemNotification do end describe 'Methods' do + let(:user) { create :user } let(:notifcation_one) { create :system_notification } let(:notifcation_two) { create :system_notification, title: 'Special one' } before do diff --git a/spec/models/user_system_notification_spec.rb b/spec/models/user_system_notification_spec.rb index 557291273..1a0da2600 100644 --- a/spec/models/user_system_notification_spec.rb +++ b/spec/models/user_system_notification_spec.rb @@ -3,8 +3,7 @@ require 'rails_helper' describe UserSystemNotification do - let(:user) { create :user } - subject(:user_system_notification) { build :user_system_notification } + let(:user_system_notification) { build :user_system_notification } it 'is valid' do expect(user_system_notification).to be_valid @@ -16,6 +15,7 @@ describe UserSystemNotification do end describe 'Methods' do + let(:user) { create :user } let(:notifcation_one) { create :system_notification } let(:notifcation_two) { create :system_notification } let(:notifcation_three) { create :system_notification, :show_on_login }