diff --git a/spec/factories/notifications.rb b/spec/factories/notifications.rb index 9df711663..9776c1f97 100644 --- a/spec/factories/notifications.rb +++ b/spec/factories/notifications.rb @@ -2,11 +2,8 @@ FactoryBot.define do factory :notification do - title do - 'Admin was added as Owner to project ' \ - 'Demo project - qPCR by User.' - end - message { 'Project: Demo project - qPCR' } - type_of { 'assignment' } + recipient_type { 'User' } + recipient_id { 1 } + read_at { Time.now } end end diff --git a/spec/factories/user_notifications.rb b/spec/factories/user_notifications.rb deleted file mode 100644 index 4e2f98e09..000000000 --- a/spec/factories/user_notifications.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -FactoryBot.define do - factory :user_notification do - checked { false } - end -end diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index a37c941ce..b1d6afbd7 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -15,17 +15,11 @@ describe Notification, type: :model do describe 'Database table' do it { should have_db_column :id } - it { should have_db_column :title } - it { should have_db_column :message } - it { should have_db_column :type_of } - it { should have_db_column :generator_user_id } it { should have_db_column :created_at } it { should have_db_column :updated_at } end describe 'Relations' do - it { should belong_to(:generator_user).class_name('User').optional } - it { should have_many :users } - it { should have_many :user_notifications } + it { should belong_to(:recipient) } end end diff --git a/spec/models/user_notification_spec.rb b/spec/models/user_notification_spec.rb deleted file mode 100644 index 11a277d3c..000000000 --- a/spec/models/user_notification_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -describe UserNotification, type: :model do - let(:user) { create :user } - let(:user_notification) { build :user_notification } - - it 'is valid' do - expect(user_notification).to be_valid - end - - it 'should be of class UserNotification' do - expect(subject.class).to eq UserNotification - end - - describe 'Database table' do - it { should have_db_column :user_id } - it { should have_db_column :notification_id } - it { should have_db_column :checked } - it { should have_db_column :created_at } - it { should have_db_column :updated_at } - end - - describe 'Relations' do - it { should belong_to(:user).optional } - it { should belong_to(:notification).optional } - end - - describe '#unseen_notification_count ' do - let(:notifcation) { create :notification } - it 'returns a number of unseen notifications' do - create :user_notification, user: user, notification: notifcation - expect(UserNotification.unseen_notification_count(user)).to eq 1 - end - end - - describe '#seen_by_user' do - let!(:notification) { create :notification } - let!(:user_notification_one) do - create :user_notification, user: user, notification: notification - end - - it 'set the check status to false' do - expect do - UserNotification.seen_by_user(user) - end.to change { user_notification_one.reload.checked }.from(false).to(true) - end - end -end