Browse files

add publish test

  • Loading branch information...
1 parent 925bbf4 commit d3ead0c7ee2c0e50fae6a6ec2a3cbff132460d4f @nsanta committed May 12, 2010
View
0 README → README.textile
File renamed without changes.
View
4 app/controllers/application_controller.rb
@@ -5,9 +5,9 @@ class ApplicationController < ActionController::Base
protected
- def client(token = nil)
+ def client
@client ||= FBGraph::Client.new(:client_id => '114709451898747',
:secret_id => '7c87164749a02552e3d204142e3af16b' ,
- :token => token)
+ :token => session[:access_token])
end
end
View
4 app/controllers/oauth_controller.rb
@@ -1,13 +1,13 @@
class OauthController < ApplicationController
def start
- redirect_to client.authorization.authorize_url(:redirect_uri => callback_oauths_url , :scope => 'email,user_photos,friends_photos')
+ redirect_to client.authorization.authorize_url(:redirect_uri => callback_oauths_url , :scope => 'email,user_photos,friends_photos,publish_stream')
end
def callback
access_token = client.authorization.process_callback(params[:code], :redirect_uri => callback_oauths_url)
session[:access_token] = access_token
- user_json = client.selection.me.home.info
+ user_json = client.selection.me.info!
# in reality you would at this point store the access_token.token value as well as
# any user info you wanted
render :json => user_json
View
2 app/controllers/pictures_controller.rb
@@ -3,7 +3,7 @@ def index
end
def create
- selection = client(session[:access_token]).selection
+ selection = client.selection
selection.send(params[:type], params[:object])
redirect_to selection.picture
end
View
7 app/controllers/publish_feeds_controller.rb
@@ -0,0 +1,7 @@
+class PublishFeedsController < ApplicationController
+
+ def index
+ user = client.selection.me.info!
+ client.selection.user(user[:id]).feed.publish!(:message => 'test message []FBGraph[]' , :name => 'test name')
+ end
+end
View
2 app/controllers/search_controller.rb
@@ -4,7 +4,7 @@ def show
end
def create
- result = client(session[:access_token]).search.query(params[:q]).on(params[:on]).info
+ result = client.search.query(params[:q]).on(params[:on]).info!
render :json => result
end
View
4 app/controllers/selections_controller.rb
@@ -4,10 +4,10 @@ def index
end
def create
- selection = client(session[:access_token]).selection
+ selection = client.selection
selection.send(params[:type], params[:object])
selection.send(params[:connection_type]) unless params[:connection_type].blank?
- render :json => selection.info
+ render :json => selection.info!
end
end
View
2 app/helpers/publish_feeds_helper.rb
@@ -0,0 +1,2 @@
+module PublishFeedsHelper
+end
View
2 config/routes.rb
@@ -10,7 +10,7 @@
resources :selections
resources :pictures
resource :search , :controller => 'search'
-
+ resources :publish_feeds
root :to => 'oauth#start'
View
8 test/functional/publish_feeds_controller_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class PublishFeedsControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
View
4 test/unit/helpers/publish_feeds_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class PublishFeedsHelperTest < ActionView::TestCase
+end

0 comments on commit d3ead0c

Please sign in to comment.