set the user email if inviting by email
This commit is contained in:
parent
4ed684491d
commit
e0fb8a08cb
3 changed files with 24 additions and 2 deletions
|
|
@ -71,6 +71,7 @@ class Invitation < ActiveRecord::Base
|
|||
# @return [Invitation] self
|
||||
def send!
|
||||
self.attach_recipient!
|
||||
puts self.recipient.inspect
|
||||
|
||||
# Sets an instance variable in User (set by devise invitable)
|
||||
# This determines whether an email should be sent to the recipient.
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class User < ActiveRecord::Base
|
|||
user = User.new
|
||||
user.generate_keys
|
||||
user.send(:generate_invitation_token)
|
||||
#user.invitations_to_me << invitation
|
||||
user.email = invitation.identifier if invitation.service == 'email'
|
||||
# we need to make a custom validator here to make this safer
|
||||
user.save(:validate => false)
|
||||
user
|
||||
|
|
|
|||
|
|
@ -367,6 +367,27 @@ describe User do
|
|||
end
|
||||
end
|
||||
|
||||
describe '.find_or_create_by_invitation' do
|
||||
|
||||
end
|
||||
|
||||
describe '.create_from_invitation!' do
|
||||
before do
|
||||
@identifier = 'max@foobar.com'
|
||||
@inv = Factory.build(:invitation, :admin => true, :service => 'email', :identifier => @identifier)
|
||||
@user = User.create_from_invitation!(@inv)
|
||||
end
|
||||
|
||||
it 'creates a persisted user' do
|
||||
@user.should be_persisted
|
||||
end
|
||||
|
||||
it 'sets the email if the service is email' do
|
||||
@user.email.should == @inv.identifier
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'update_user_preferences' do
|
||||
before do
|
||||
@pref_count = UserPreference::VALID_EMAIL_TYPES.count
|
||||
|
|
|
|||
Loading…
Reference in a new issue