Commit b3467b5d authored by zhitomirskiyi's avatar zhitomirskiyi

pending specs for facebook inviter

parent e56ba840
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
# licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file.
class ServicesController < ApplicationController
before_filter :authenticate_user!
......@@ -51,4 +49,12 @@ class ServicesController < ApplicationController
service = current_user.services.where(:provider => params[:provider]).first
@friends = service ? service.finder : {}
end
def inviter
@uid = params[:uid]
@subject = "Join me on DIASPORA*"
@message = ""
redirect_to "http://facebook.com"
end
end
......@@ -25,8 +25,6 @@ class Services::Facebook < Service
data_h[d['id']] = {:name => d['name']}
end
service_objects = Services::Facebook.where(:uid => data_h.keys).includes(:user => :person)
service_objects.each do |s|
data_h[s.uid][:person] = s.user.person
......
......@@ -7,6 +7,7 @@ Diaspora::Application.routes.draw do
resources :comments, :only => [:create]
resources :requests, :only => [:destroy, :create]
match 'services/inviter/:provider' => 'services#inviter', :as => 'service_inviter'
match 'services/finder/:provider' => 'services#finder', :as => 'friend_finder'
resources :services
......
......@@ -92,4 +92,38 @@ describe ServicesController do
get :finder, :provider => @service1.provider
end
end
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}
end
it 'creates an invitation' do
lambda {
put :inviter, @invite_params
}.should change(Invitation, :count).by(1)
end
it 'sets the subject' do
put :inviter, @invite_params
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)
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/)
end
end
end
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