summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-01-15 13:07:19 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-01-15 13:07:19 +0000
commit1fc42d9934fbf511db2a28e980b298c019a217a7 (patch)
tree81577800cca14a6232857a0177ca31dd4695b678
parent065d9c22faf4ae5cdc5dd17f6b655aa15433d5d8 (diff)
parent2e7abbd66c1e68eaf6cd227ce7e26e2d9a3d4180 (diff)
downloadgitlab-ce-1fc42d9934fbf511db2a28e980b298c019a217a7.tar.gz
Merge branch 'improve/notification' of /home/git/repositories/gitlab/gitlabhq
-rw-r--r--app/models/project.rb4
-rw-r--r--app/services/notification_service.rb9
-rw-r--r--spec/services/notification_service_spec.rb25
3 files changed, 35 insertions, 3 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index a55f7a65b0b..f322b5a2e25 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -270,9 +270,7 @@ class Project < ActiveRecord::Base
end
def send_move_instructions
- team.members.each do |user|
- Notify.delay.project_was_moved_email(self.id, user.id)
- end
+ NotificationService.new.project_was_moved(self)
end
def owner
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb
index eb42cac3f83..ebbb556b63c 100644
--- a/app/services/notification_service.rb
+++ b/app/services/notification_service.rb
@@ -157,6 +157,15 @@ class NotificationService
mailer.group_access_granted_email(users_group.id)
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
# Get project users with WATCH notification level
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb
index a112835d4d0..09a5debe1dc 100644
--- a/spec/services/notification_service_spec.rb
+++ b/spec/services/notification_service_spec.rb
@@ -233,6 +233,31 @@ describe NotificationService do
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)
@u_watcher = create(:user, notification_level: Notification::N_WATCH)
@u_participating = create(:user, notification_level: Notification::N_PARTICIPATING)