Merge pull request #2624 from techAPJ/patch-2

convert space to plus for invite email parameter
This commit is contained in:
Régis Hanol 2014-08-06 17:19:52 +02:00
commit 4bd6261fcc
2 changed files with 6 additions and 0 deletions

View File

@ -63,6 +63,7 @@ class InvitesController < ApplicationController
def redeem_disposable_invite def redeem_disposable_invite
params.require(:email) params.require(:email)
params.permit(:username, :name, :topic) params.permit(:username, :name, :topic)
params[:email] = params[:email].split(' ').join('+')
invite = Invite.find_by(invite_key: params[:token]) invite = Invite.find_by(invite_key: params[:token])

View File

@ -252,6 +252,11 @@ describe InvitesController do
let(:invitee) { Fabricate(:user) } let(:invitee) { Fabricate(:user) }
let(:invite) { Invite.create!(invited_by: invitee) } let(:invite) { Invite.create!(invited_by: invitee) }
it 'converts "space" to "+" in email parameter' do
Invite.expects(:redeem_from_token).with(invite.invite_key, "fname+lname@example.com", nil, nil, topic.id)
get :redeem_disposable_invite, email: "fname lname@example.com", token: invite.invite_key, topic: topic.id
end
it 'redeems the invite' do it 'redeems the invite' do
Invite.expects(:redeem_from_token).with(invite.invite_key, "name@example.com", nil, nil, topic.id) Invite.expects(:redeem_from_token).with(invite.invite_key, "name@example.com", nil, nil, topic.id)
get :redeem_disposable_invite, email: "name@example.com", token: invite.invite_key, topic: topic.id get :redeem_disposable_invite, email: "name@example.com", token: invite.invite_key, topic: topic.id