From 4ca73f56cb59b86f25b55ff02800571fb82c742f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 28 Mar 2016 23:22:28 +0200 Subject: Small refactoring and cleanup of notification logic Signed-off-by: Dmitriy Zaporozhets --- spec/models/notification_setting_spec.rb | 1 + spec/services/notification_service_spec.rb | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'spec') diff --git a/spec/models/notification_setting_spec.rb b/spec/models/notification_setting_spec.rb index f9d668ed75b..f31b2a3cd6f 100644 --- a/spec/models/notification_setting_spec.rb +++ b/spec/models/notification_setting_spec.rb @@ -3,6 +3,7 @@ require 'rails_helper' RSpec.describe NotificationSetting, type: :model do describe "Associations" do it { is_expected.to belong_to(:user) } + it { is_expected.to belong_to(:source) } end describe "Validation" do diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index c01851a8a24..c4d52584a4b 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -88,12 +88,9 @@ describe NotificationService, services: true do note.project.namespace_id = group.id note.project.group.add_user(@u_watcher, GroupMember::MASTER) note.project.save - user_project = note.project.project_members.find_by_user_id(@u_watcher.id) - user_project.notification.level = :participating - user_project.save - group_member = note.project.group.group_members.find_by_user_id(@u_watcher.id) - group_member.notification.level = :global - group_member.notification.save + + @u_watcher.notification_settings.find_by(source: note.project).participating! + @u_watcher.notification_settings.find_by(source: note.project.group).global! ActionMailer::Base.deliveries.clear end -- cgit v1.2.1