started the new invitation email
This commit is contained in:
parent
645685a8fb
commit
80cd4761f3
5 changed files with 108 additions and 1 deletions
14
app/mailers/notifier.rb
Normal file
14
app/mailers/notifier.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
class Notifier < ActionMailer::Base
|
||||||
|
default :from => "no-reply@joindiaspora.com"
|
||||||
|
|
||||||
|
def new_request(recipient, sender)
|
||||||
|
@receiver = recipient
|
||||||
|
@sender = sender
|
||||||
|
mail(:to => recipient.email) do |format|
|
||||||
|
format.text { render :text => "This is text!" }
|
||||||
|
format.html { render :text => "<h1>#{@receiver.person.profile.first_name}This is HTML</h1>" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
61
app/views/notifier/new_request.html.haml
Normal file
61
app/views/notifier/new_request.html.haml
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
!!!
|
||||||
|
%html
|
||||||
|
%head
|
||||||
|
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
|
||||||
|
:css
|
||||||
|
body{
|
||||||
|
width:600px;
|
||||||
|
font-family:'Arial','Helvetica',sans-serif;
|
||||||
|
font-size:14px;
|
||||||
|
color:#333;
|
||||||
|
}
|
||||||
|
#container{
|
||||||
|
margin-bottom:25px
|
||||||
|
min-height:400px;
|
||||||
|
padding-left:15px;
|
||||||
|
}
|
||||||
|
header{
|
||||||
|
background-color:#333;
|
||||||
|
padding: 15px;
|
||||||
|
margin-bottom: 25px;
|
||||||
|
}
|
||||||
|
p{
|
||||||
|
padding:5px;
|
||||||
|
}
|
||||||
|
p.small{
|
||||||
|
font-size:smaller;
|
||||||
|
color:#999;
|
||||||
|
font-style:italic;
|
||||||
|
}
|
||||||
|
a{
|
||||||
|
color:#107FC9;
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
a:hover{
|
||||||
|
color: #22AAE0;
|
||||||
|
}
|
||||||
|
a:active{
|
||||||
|
color: #005D9C;
|
||||||
|
}
|
||||||
|
.large_text{
|
||||||
|
font-size:21px;
|
||||||
|
font-family:"Helvetica Neue",Arial,Helvetica,sans-serif;
|
||||||
|
}
|
||||||
|
%body
|
||||||
|
%header
|
||||||
|
= image_tag '/images/diaspora_white.png'
|
||||||
|
#container
|
||||||
|
%p
|
||||||
|
Hello #{@receiver.first_name}!
|
||||||
|
%p
|
||||||
|
#{(@resource.inviters.count == 1)? ( @resource.inviters.first.real_name + " (#{@resource.inviters.first.diaspora_handle})" + " has") : (@resource.inviters.map{|inv| inv.real_name + " (#{inv.diaspora_handle})"}.join(",") + " have")} invited you to join Diaspora at #{root_url}, you can accept it through the link below.
|
||||||
|
- @resource.inviters.each do |inv|
|
||||||
|
- if @resource.invite_messages[inv.id.to_s]
|
||||||
|
= "#{inv.real_name}:"
|
||||||
|
= @resource.invite_messages[inv.id.to_s]
|
||||||
|
%p
|
||||||
|
%p= link_to 'Accept invitation', accept_invitation_url(@resource, :invitation_token => @resource.invitation_token), :class => "large_text"
|
||||||
|
%p.small
|
||||||
|
If you don't want to accept the invitation, please ignore this email.
|
||||||
|
%br/
|
||||||
|
Your account won't be created until you access the link above and sign up.
|
||||||
|
|
@ -74,6 +74,7 @@ module Diaspora
|
||||||
else
|
else
|
||||||
self.pending_requests << friend_request
|
self.pending_requests << friend_request
|
||||||
self.save
|
self.save
|
||||||
|
Notifier.new_request(self, friend_request.person)
|
||||||
Rails.logger.info("#{self.real_name} has received a friend request")
|
Rails.logger.info("#{self.real_name} has received a friend request")
|
||||||
friend_request.save
|
friend_request.save
|
||||||
end
|
end
|
||||||
|
|
|
||||||
19
spec/mailers/notifier_spec.rb
Normal file
19
spec/mailers/notifier_spec.rb
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Notifier do
|
||||||
|
|
||||||
|
let(:user) {Factory.create :user}
|
||||||
|
let(:person) {Factory.create :person}
|
||||||
|
let(:request_mail) {Notifier.new_request(user, person)}
|
||||||
|
|
||||||
|
describe "#new_request" do
|
||||||
|
it 'goes to the right person' do
|
||||||
|
request_mail.to.should == [user.email]
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has the receivers name in the body' do
|
||||||
|
request_mail.body.encoded.includes?(user.first_name).should be true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -93,6 +93,16 @@ describe User do
|
||||||
}.should_not change(Person, :count)
|
}.should_not change(Person, :count)
|
||||||
user2.friends.include?(user.person).should be false
|
user2.friends.include?(user.person).should be false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'sends an email to the receiving user' do
|
||||||
|
Notifier.should_receive(:new_request)
|
||||||
|
user.receive @req_xml, person_one
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
it 'should send a an email saying your friend request was confirmed' do
|
||||||
|
pending
|
||||||
|
end
|
||||||
end
|
end
|
||||||
context 'Two users receiving requests from one person' do
|
context 'Two users receiving requests from one person' do
|
||||||
before do
|
before do
|
||||||
|
|
@ -124,6 +134,8 @@ describe User do
|
||||||
user2.friends.include?(person_one).should be false
|
user2.friends.include?(person_one).should be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'a user accepting rejecting multiple people' do
|
describe 'a user accepting rejecting multiple people' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue