made service#invite redirect to the right place
This commit is contained in:
parent
3392f11b64
commit
89a8817ce6
3 changed files with 13 additions and 11 deletions
|
|
@ -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 "http://facebook.com"
|
||||
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)}
|
||||
MSG
|
||||
redirect_to "https://www.facebook.com/?compose=1&id=#{@uid}&subject=#{@subject}&message=#{@message}&sk=messages"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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?
|
||||
invitee.errors.clear
|
||||
|
|
|
|||
|
|
@ -96,7 +96,6 @@ describe ServicesController do
|
|||
describe '#invite' do
|
||||
|
||||
before do
|
||||
pending
|
||||
@service1 = Services::Facebook.create(:provider => 'facebook')
|
||||
@uid = "abc"
|
||||
@invite_params = {:provider => @service1.provider, :uid => @uid, :aspect_id => @user.aspects.first.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
|
||||
end
|
||||
|
||||
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)
|
||||
end
|
||||
|
||||
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/)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue