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'
|
flash[:notice] = I18n.t 'registrations.create.success'
|
||||||
sign_in_and_redirect(:user, user)
|
sign_in_and_redirect(:user, user)
|
||||||
else
|
else
|
||||||
redirect_to new_user_registration_path
|
redirect_to accept_user_invitation_path(
|
||||||
|
:invitation_token => params[:user][:invitation_token])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ class Invitation
|
||||||
|
|
||||||
invitee.send(:generate_invitation_token)
|
invitee.send(:generate_invitation_token)
|
||||||
invitee.invite!
|
invitee.invite!
|
||||||
|
Rails.logger.info("event=invitation_sent to=#{opts[:email]} #{"inviter=#{opts[:from].diaspora_handle}" if opts[:from]}")
|
||||||
end
|
end
|
||||||
invitee
|
invitee
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -80,25 +80,43 @@ describe InvitationsController do
|
||||||
describe "#update" do
|
describe "#update" do
|
||||||
before do
|
before do
|
||||||
user.invites = 5
|
user.invites = 5
|
||||||
invited_user = user.invite_user(:email => "a@a.com", :aspect_id => user.aspects.first.id)
|
@invited_user = user.invite_user(:email => "a@a.com", :aspect_id => user.aspects.first.id)
|
||||||
@accept_params = {"user"=>{"password_confirmation"=>"password", "username"=>"josh",
|
@accept_params = {:user=>
|
||||||
"password"=>"password", "invitation_token" => invited_user.invitation_token}}
|
{:password_confirmation =>"password",
|
||||||
|
:username=>"josh",
|
||||||
|
:password=>"password",
|
||||||
|
:invitation_token => @invited_user.invitation_token}}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
context 'success' do
|
||||||
it 'creates user' do
|
it 'creates user' do
|
||||||
put :update, @accept_params
|
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
|
end
|
||||||
|
|
||||||
it 'seeds the aspects' do
|
it 'seeds the aspects' do
|
||||||
put :update, @accept_params
|
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
|
end
|
||||||
|
|
||||||
it 'adds a pending request' do
|
it 'adds a pending request' do
|
||||||
put :update, @accept_params
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue