Skip to content
Extraits de code Groupes Projets
Valider cf847d61 rédigé par Dan Hansen's avatar Dan Hansen
Parcourir les fichiers

bug mash #5

fix NoMethodError on InvitationsController
parent 0e1c66f5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -26,27 +26,37 @@ class InvitationsController < ApplicationController
end
def email
if params[:invitation_token]
# this is for legacy invites.
user = User.find_by_invitation_token(params[:invitation_token])
@invitation_code = user.ugly_accept_invitation_code
@invitation_code =
if params[:invitation_token]
# this is for legacy invites.
user = User.find_by_invitation_token(params[:invitation_token])
user.ugly_accept_invitation_code if user
else
params[:invitation_code]
end
if @invitation_code.present?
render 'notifier/invite', :layout => false
else
@invitation_code = params[:invitation_code]
flash[:error] = t('invitations.check_token.not_found')
redirect_to root_url
end
render 'notifier/invite', :layout => false
end
def create
inviter = EmailInviter.new(params[:email_inviter][:emails], current_user, params[:email_inviter])
inviter.send!
redirect_to :back, :notice => "Great! Invites were sent off to #{inviter.emails.join(', ')}"
end
def check_if_invites_open
unless AppConfig[:open_invitations]
flash[:error] = I18n.t 'invitations.create.no_more'
redirect_to :back
return
end
end
end
\ No newline at end of file
......@@ -42,10 +42,34 @@ describe InvitationsController do
end
describe '#email' do
it 'succeeds' do
get :email, :invitation_code => "anycode"
response.should be_success
end
context 'legacy invite tokens' do
def get_email
get :email, :invitation_token => @invitation_token
end
context 'invalid token' do
@invitation_token = "invalidtoken"
it 'redirects and flashes if the invitation token is invalid' do
get_email
response.should be_redirect
response.should redirect_to root_url
end
it 'flashes an error if the invitation token is invalid' do
get_email
flash[:error].should == I18n.t("invitations.check_token.not_found")
end
end
end
end
describe '#new' do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter