Commit 1dd66061 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Send project transfer email to all members. Added specs for project move email

parent dc0f08f8
...@@ -8,10 +8,10 @@ module Emails ...@@ -8,10 +8,10 @@ module Emails
end end
def project_was_moved_email(user_project_id) def project_was_moved_email(project_id, user_id)
@users_project = UsersProject.find user_project_id @user = User.find user_id
@project = @users_project.project @project = Project.find project_id
mail(to: @users_project.user.email, mail(to: @user.email,
subject: subject("project was moved")) subject: subject("project was moved"))
end end
end end
......
...@@ -246,8 +246,8 @@ class Project < ActiveRecord::Base ...@@ -246,8 +246,8 @@ class Project < ActiveRecord::Base
end end
def send_move_instructions def send_move_instructions
self.users_projects.each do |member| team.members.each do |user|
Notify.delay.project_was_moved_email(member.id) Notify.delay.project_was_moved_email(self.id, user.id)
end end
end end
......
...@@ -218,6 +218,24 @@ describe Notify do ...@@ -218,6 +218,24 @@ describe Notify do
end end
end end
describe 'project was moved' do
let(:project) { create(:project) }
let(:user) { create(:user) }
subject { Notify.project_was_moved_email(project.id, user.id) }
it 'has the correct subject' do
should have_subject /project was moved/
end
it 'contains name of project' do
should have_body_text /#{project.name_with_namespace}/
end
it 'contains new user role' do
should have_body_text /#{project.ssh_url_to_repo}/
end
end
describe 'project access changed' do describe 'project access changed' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
......
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