Commit 89a8817c authored by zhitomirskiyi's avatar zhitomirskiyi

made service#invite redirect to the right place

parent 3392f11b
......@@ -53,11 +53,15 @@ class ServicesController < ApplicationController
def inviter
@uid = params[:uid]
@subject = "Join me on DIASPORA*"
@message = ""
current_user.invite_user(aspect_id, :service => params[:provider],
:identifier => params[:uid])
redirect_to ""
invited_user = current_user.invite_user(params[:aspect_id], params[:provider], params[:uid])
@message = <<MSG
Diaspora* is the social network that puts you in control of your information. You decide what you'd like to share, and with whom. You retain full ownership of all your information, including friend lists, messages, photos, and profile details.
Click here to accept your invitation:
#{accept_invitation_url(invited_user, :invitation_token => invited_user.invitation_token)}
redirect_to "{@uid}&subject=#{@subject}&message=#{@message}&sk=messages"
......@@ -50,7 +50,7 @@ class Invitation < ActiveRecord::Base
def self.create_invitee(opts = {})
invitee = new_or_existing_user_by_service_and_identifier(opts[:service], opts[:identifier])
return invitee unless opts[:service] == 'email' && opts[:identifier].match(Devise.email_regexp)
return invitee if opts[:service] == 'email' && !opts[:identifier].match(Devise.email_regexp)
invitee.invites = opts[:invites] || 0
if invitee.new_record?
......@@ -96,7 +96,6 @@ describe ServicesController do
describe '#invite' do
before do
@service1 = Services::Facebook.create(:provider => 'facebook')
@uid = "abc"
@invite_params = {:provider => @service1.provider, :uid => @uid, :aspect_id =>}
......@@ -110,18 +109,17 @@ describe ServicesController do
it 'sets the subject' do
put :inviter, @invite_params
assigns[:@subject].should_not be_nil
assigns[:subject].should_not be_nil
it 'sets a message containing the invitation link' do
put :inviter, @invite_params
assigns[:@message].should include(User.last.invitation_token)
assigns[:message].should include(User.last.invitation_token)
it 'redirects to a prefilled facebook message url' do
put :inviter, @invite_params
response.should be_redirect
response.should have_text(/http:\/\/www\.facebook\.com\/\?compose=1&id=.*&subject=.*&message=.*&sk=messages/)
response.location.should match(/https:\/\/www\.facebook\.com\/\?compose=1&id=.*&subject=.*&message=.*&sk=messages/)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment