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

This commit is contained in:
Dmitriy Zaporozhets 2013-06-22 10:56:51 +03:00
parent dc0f08f8d8
commit 1dd6606161
3 changed files with 24 additions and 6 deletions

View file

@ -8,10 +8,10 @@ module Emails
end
def project_was_moved_email(user_project_id)
@users_project = UsersProject.find user_project_id
@project = @users_project.project
mail(to: @users_project.user.email,
def project_was_moved_email(project_id, user_id)
@user = User.find user_id
@project = Project.find project_id
mail(to: @user.email,
subject: subject("project was moved"))
end
end

View file

@ -246,8 +246,8 @@ class Project < ActiveRecord::Base
end
def send_move_instructions
self.users_projects.each do |member|
Notify.delay.project_was_moved_email(member.id)
team.members.each do |user|
Notify.delay.project_was_moved_email(self.id, user.id)
end
end

View file

@ -218,6 +218,24 @@ describe Notify do
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
let(:project) { create(:project) }
let(:user) { create(:user) }