Commit 2e7abbd6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Move repo rename email to notification service

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 065d9c22
...@@ -270,9 +270,7 @@ class Project < ActiveRecord::Base ...@@ -270,9 +270,7 @@ class Project < ActiveRecord::Base
end end
def send_move_instructions def send_move_instructions
team.members.each do |user| NotificationService.new.project_was_moved(self)
Notify.delay.project_was_moved_email(self.id, user.id)
end
end end
def owner def owner
......
...@@ -157,6 +157,15 @@ class NotificationService ...@@ -157,6 +157,15 @@ class NotificationService
mailer.group_access_granted_email(users_group.id) mailer.group_access_granted_email(users_group.id)
end end
def project_was_moved(project)
recipients = project.team.members
recipients = reject_muted_users(recipients, project)
recipients.each do |recipient|
mailer.project_was_moved_email(project.id, recipient.id)
end
end
protected protected
# Get project users with WATCH notification level # Get project users with WATCH notification level
......
...@@ -233,6 +233,31 @@ describe NotificationService do ...@@ -233,6 +233,31 @@ describe NotificationService do
end end
end end
describe 'Projects' do
let(:project) { create :project }
before do
build_team(project)
end
describe :project_was_moved do
it do
should_email(@u_watcher.id)
should_email(@u_participating.id)
should_not_email(@u_disabled.id)
notification.project_was_moved(project)
end
def should_email(user_id)
Notify.should_receive(:project_was_moved_email).with(project.id, user_id)
end
def should_not_email(user_id)
Notify.should_not_receive(:project_was_moved_email).with(project.id, user_id)
end
end
end
def build_team(project) def build_team(project)
@u_watcher = create(:user, notification_level: Notification::N_WATCH) @u_watcher = create(:user, notification_level: Notification::N_WATCH)
@u_participating = create(:user, notification_level: Notification::N_PARTICIPATING) @u_participating = create(:user, notification_level: Notification::N_PARTICIPATING)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment