WIP
This commit is contained in:
parent
8039ab312a
commit
da6e16b3a4
4 changed files with 46 additions and 0 deletions
|
|
@ -57,6 +57,12 @@ class InvitationsController < Devise::InvitationsController
|
|||
end
|
||||
end
|
||||
|
||||
def resend
|
||||
invitation = current_user.invitations_from_me.where(:id => params[:id]).first
|
||||
Resque.enqueue(Job::ResendInvitation, invitation.id) if invitation
|
||||
redirect_to :back
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def check_token
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ Diaspora::Application.routes.draw do
|
|||
match 'photos/make_profile_photo' => 'photos#make_profile_photo'
|
||||
resources :photos, :except => [:index]
|
||||
|
||||
match 'invitations/resend/:id' => 'invitations#resend'
|
||||
devise_for :users, :controllers => {:registrations => "registrations",
|
||||
:password => "devise/passwords",
|
||||
:invitations => "invitations"}
|
||||
|
|
|
|||
|
|
@ -117,5 +117,33 @@ describe InvitationsController do
|
|||
get :new
|
||||
end
|
||||
end
|
||||
|
||||
describe '#resend' do
|
||||
before do
|
||||
@user.invites = 5
|
||||
|
||||
sign_in :user, @user
|
||||
@controller.stub!(:current_user).and_return(@user)
|
||||
request.env["HTTP_REFERER"]= 'http://test.host/cats/foo'
|
||||
|
||||
@invited_user = @user.invite_user("a@a.com", @aspect.id)
|
||||
end
|
||||
|
||||
it 'calls resend invitation if one exists' do
|
||||
@user.reload.invitations_from_me.count.should == 1
|
||||
invitation = @user.invitations_from_me.first
|
||||
Resque.should_receive(:enqueue)
|
||||
put :resend, :id => invitation.id
|
||||
end
|
||||
|
||||
it 'does not send an invitation for a different user' do
|
||||
@user2 = bob
|
||||
@aspect2 = @user2.aspects.create(:name => "cats")
|
||||
@user2.invite_user("b@b.com", @aspect2.id)
|
||||
invitation2 = @user2.reload.invitations_from_me.first
|
||||
Resque.should_not_receive(:enqueue)
|
||||
put :resend, :id => invitation2.id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -298,6 +298,17 @@ describe Invitation do
|
|||
end
|
||||
end
|
||||
|
||||
describe '.resend' do
|
||||
before do
|
||||
aspect
|
||||
@invitation = Invitation.new(:sender => user, :recipient => user2, :aspect => aspect)
|
||||
end
|
||||
|
||||
it 'sends another email' do
|
||||
lambda{@invitation.resend}.should change(Devise.mailer.deliveries, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#to_request!' do
|
||||
before do
|
||||
@new_user = Invitation.invite(:from => user, :service => 'email', :identifier => @email, :into => aspect)
|
||||
|
|
|
|||
Loading…
Reference in a new issue