Bad solution for making sure that an invited facebook user is marked immediately as having been invited
This commit is contained in:
parent
75f3accd37
commit
565d71a0cd
2 changed files with 15 additions and 2 deletions
|
|
@ -70,6 +70,11 @@ class ServicesController < ApplicationController
|
|||
#{accept_invitation_url(invited_user, :invitation_token => invited_user.invitation_token)}
|
||||
MSG
|
||||
|
||||
service = current_user.services.where(:type => "Services::Facebook").first
|
||||
su = ServiceUser.where(:service_id => service.id, :uid => @uid).first
|
||||
su.attach_local_models
|
||||
su.save
|
||||
|
||||
url = "https://www.facebook.com/?compose=1&id=#{@uid}&subject=#{@subject}&message=#{@message}&sk=messages"
|
||||
respond_to do |format|
|
||||
format.html{ redirect_to url }
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ describe ServicesController do
|
|||
end
|
||||
|
||||
describe '#create' do
|
||||
it 'creates a new OmniauthService' do
|
||||
it 'creates a new OmniauthService' do
|
||||
request.env['omniauth.auth'] = omniauth_auth
|
||||
lambda{
|
||||
post :create, :provider => 'twitter'
|
||||
|
|
@ -105,9 +105,12 @@ describe ServicesController do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#invite' do
|
||||
describe '#inviter' do
|
||||
before do
|
||||
@uid = "abc"
|
||||
fb = Factory(:service, :type => "Services::Facebook", :user => @user)
|
||||
fb = Services::Facebook.find(fb.id)
|
||||
@su = Factory(:service_user, :service => fb, :uid => @uid)
|
||||
@invite_params = {:provider => 'facebook', :uid => @uid, :aspect_id => @user.aspects.first.id}
|
||||
end
|
||||
|
||||
|
|
@ -132,6 +135,11 @@ describe ServicesController do
|
|||
}.should change(Invitation, :count).by(1)
|
||||
end
|
||||
|
||||
it 'sets the invitation_id on the service_user' do
|
||||
post :inviter, @invite_params
|
||||
@su.reload.invitation.should_not be_nil
|
||||
end
|
||||
|
||||
it 'does not create a duplicate invitation' do
|
||||
inv = Invitation.create!(:sender_id => @user.id, :recipient_id => eve.id, :aspect_id => @user.aspects.first.id)
|
||||
@invite_params[:invitation_id] = inv.id
|
||||
|
|
|
|||
Loading…
Reference in a new issue