Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
287b79ab17
3 changed files with 36 additions and 16 deletions
|
|
@ -53,7 +53,8 @@ class InvitationsController < Devise::InvitationsController
|
|||
flash[:notice] = I18n.t 'registrations.create.success'
|
||||
sign_in_and_redirect(:user, user)
|
||||
else
|
||||
redirect_to new_user_registration_path
|
||||
redirect_to accept_user_invitation_path(
|
||||
:invitation_token => params[:user][:invitation_token])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class Invitation
|
|||
|
||||
invitee.send(:generate_invitation_token)
|
||||
invitee.invite!
|
||||
Rails.logger.info("event=invitation_sent to=#{opts[:email]} #{"inviter=#{opts[:from].diaspora_handle}" if opts[:from]}")
|
||||
end
|
||||
invitee
|
||||
end
|
||||
|
|
|
|||
|
|
@ -80,25 +80,43 @@ describe InvitationsController do
|
|||
describe "#update" do
|
||||
before do
|
||||
user.invites = 5
|
||||
invited_user = user.invite_user(:email => "a@a.com", :aspect_id => user.aspects.first.id)
|
||||
@accept_params = {"user"=>{"password_confirmation"=>"password", "username"=>"josh",
|
||||
"password"=>"password", "invitation_token" => invited_user.invitation_token}}
|
||||
@invited_user = user.invite_user(:email => "a@a.com", :aspect_id => user.aspects.first.id)
|
||||
@accept_params = {:user=>
|
||||
{:password_confirmation =>"password",
|
||||
:username=>"josh",
|
||||
:password=>"password",
|
||||
:invitation_token => @invited_user.invitation_token}}
|
||||
|
||||
end
|
||||
|
||||
context 'success' do
|
||||
it 'creates user' do
|
||||
put :update, @accept_params
|
||||
User.find_by_username(@accept_params['user']['username']).should_not be_nil
|
||||
User.find_by_username(@accept_params[:user][:username]).should_not be_nil
|
||||
end
|
||||
|
||||
it 'seeds the aspects' do
|
||||
put :update, @accept_params
|
||||
User.find_by_username(@accept_params['user']['username']).aspects.count.should == 2
|
||||
User.find_by_username(@accept_params[:user][:username]).aspects.count.should == 2
|
||||
end
|
||||
|
||||
it 'adds a pending request' do
|
||||
put :update, @accept_params
|
||||
User.find_by_username(@accept_params['user']['username']).pending_requests.count.should == 1
|
||||
User.find_by_username(@accept_params[:user][:username]).pending_requests.count.should == 1
|
||||
end
|
||||
end
|
||||
context 'failure' do
|
||||
before do
|
||||
@fail_params = @accept_params
|
||||
@fail_params[:user][:username] = user.username
|
||||
end
|
||||
it 'stays on the invitation accept form' do
|
||||
put :update, @fail_params
|
||||
response.location.include?(accept_user_invitation_path).should be_true
|
||||
end
|
||||
it 'keeps the invitation token' do
|
||||
put :update, @fail_params
|
||||
response.location.include?("invitation_token=#{@invited_user.invitation_token}").should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue