fb_graph 1.8.5 → 1.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +3 -3
- data/VERSION +1 -1
- data/lib/fb_graph/application.rb +6 -0
- data/lib/fb_graph/connections/insights.rb +0 -1
- data/lib/fb_graph/connections/payments.rb +0 -1
- data/lib/fb_graph/connections/subscriptions.rb +3 -3
- data/lib/fb_graph/connections/test_users.rb +2 -2
- data/lib/fb_graph/connections/videos.rb +7 -0
- data/lib/fb_graph/group.rb +1 -0
- data/spec/fb_graph/application_spec.rb +57 -26
- data/spec/fb_graph/connections/videos_spec.rb +21 -6
- data/spec/mock_json/users/videos/posted.json +1 -0
- metadata +4 -2
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,21 +1,21 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                fb_graph (1.8. | 
| 4 | 
            +
                fb_graph (1.8.6)
         | 
| 5 5 | 
             
                  httpclient (>= 2.2.0.2)
         | 
| 6 6 | 
             
                  rack-oauth2 (>= 0.8.0)
         | 
| 7 7 |  | 
| 8 8 | 
             
            GEM
         | 
| 9 9 | 
             
              remote: http://rubygems.org/
         | 
| 10 10 | 
             
              specs:
         | 
| 11 | 
            -
                activesupport (3.0. | 
| 11 | 
            +
                activesupport (3.0.9)
         | 
| 12 12 | 
             
                addressable (2.2.6)
         | 
| 13 13 | 
             
                attr_required (0.0.3)
         | 
| 14 14 | 
             
                crack (0.1.8)
         | 
| 15 15 | 
             
                diff-lcs (1.1.2)
         | 
| 16 16 | 
             
                httpclient (2.2.1)
         | 
| 17 17 | 
             
                i18n (0.6.0)
         | 
| 18 | 
            -
                json (1.5. | 
| 18 | 
            +
                json (1.5.2)
         | 
| 19 19 | 
             
                rack (1.3.0)
         | 
| 20 20 | 
             
                rack-oauth2 (0.8.1)
         | 
| 21 21 | 
             
                  activesupport (>= 2.3)
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            1.8. | 
| 1 | 
            +
            1.8.6
         | 
    
        data/lib/fb_graph/application.rb
    CHANGED
    
    | @@ -33,5 +33,11 @@ module FbGraph | |
| 33 33 | 
             
                  self.access_token = auth.client.access_token!
         | 
| 34 34 | 
             
                end
         | 
| 35 35 |  | 
| 36 | 
            +
                def access_token_with_auto_fetch
         | 
| 37 | 
            +
                  access_token_without_auto_fetch ||
         | 
| 38 | 
            +
                  self.secret && get_access_token
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
                alias_method_chain :access_token, :auto_fetch
         | 
| 41 | 
            +
             | 
| 36 42 | 
             
              end
         | 
| 37 43 | 
             
            end
         | 
| @@ -3,7 +3,6 @@ module FbGraph | |
| 3 3 | 
             
                module Insights
         | 
| 4 4 | 
             
                  def insights(options = {})
         | 
| 5 5 | 
             
                    options[:access_token] ||= self.access_token
         | 
| 6 | 
            -
                    options[:access_token] ||= get_access_token(options[:secret]) if respond_to?(:get_access_token)
         | 
| 7 6 | 
             
                    insights = self.connection(:insights, options.merge(:connection_scope => connection_scope(options)))
         | 
| 8 7 | 
             
                    insights.map! do |insight|
         | 
| 9 8 | 
             
                      Insight.new(insight[:id], insight.merge(:access_token => options[:access_token]))
         | 
| @@ -3,7 +3,6 @@ module FbGraph | |
| 3 3 | 
             
                module Payments
         | 
| 4 4 | 
             
                  def payments(options = {})
         | 
| 5 5 | 
             
                    options[:access_token] ||= self.access_token
         | 
| 6 | 
            -
                    options[:access_token] ||= get_access_token(options[:secret]) if respond_to?(:get_access_token)
         | 
| 7 6 | 
             
                    orders = self.connection(:payments, options)
         | 
| 8 7 | 
             
                    orders.map! do |order|
         | 
| 9 8 | 
             
                      orders[:access_token] ||= options[:access_token] || self.access_token
         | 
| @@ -7,7 +7,7 @@ module FbGraph | |
| 7 7 | 
             
                  #   app.subscriptions
         | 
| 8 8 | 
             
                  #   => Array of FbGraph::Subscriptions
         | 
| 9 9 | 
             
                  def subscriptions(options = {})
         | 
| 10 | 
            -
                    options[:access_token] ||= self.access_token | 
| 10 | 
            +
                    options[:access_token] ||= self.access_token
         | 
| 11 11 | 
             
                    subscriptions = self.connection(:subscriptions, options)
         | 
| 12 12 | 
             
                    subscriptions.map! do |subscription|
         | 
| 13 13 | 
             
                      Subscription.new(subscription.merge(:access_token => options[:access_token]))
         | 
| @@ -29,7 +29,7 @@ module FbGraph | |
| 29 29 | 
             
                  #   )
         | 
| 30 30 | 
             
                  #   => Array of FbGraph::Subscriptions
         | 
| 31 31 | 
             
                  def subscribe!(options = {})
         | 
| 32 | 
            -
                    options[:access_token] ||= self.access_token | 
| 32 | 
            +
                    options[:access_token] ||= self.access_token
         | 
| 33 33 | 
             
                    post(options.merge(:connection => :subscriptions))
         | 
| 34 34 | 
             
                  end
         | 
| 35 35 |  | 
| @@ -45,7 +45,7 @@ module FbGraph | |
| 45 45 | 
             
                  #   )
         | 
| 46 46 | 
             
                  #   => Array of FbGraph::Subscriptions
         | 
| 47 47 | 
             
                  def unsubscribe!(options = {})
         | 
| 48 | 
            -
                    options[:access_token] ||= self.access_token | 
| 48 | 
            +
                    options[:access_token] ||= self.access_token
         | 
| 49 49 | 
             
                    destroy(options.merge(:connection => :subscriptions))
         | 
| 50 50 | 
             
                  end
         | 
| 51 51 | 
             
                end
         | 
| @@ -2,7 +2,7 @@ module FbGraph | |
| 2 2 | 
             
              module Connections
         | 
| 3 3 | 
             
                module TestUsers
         | 
| 4 4 | 
             
                  def test_users(options = {})
         | 
| 5 | 
            -
                    options[:access_token] ||= self.access_token | 
| 5 | 
            +
                    options[:access_token] ||= self.access_token
         | 
| 6 6 | 
             
                    test_users = self.connection(:accounts, options.merge(:connection_scope => 'test-users'))
         | 
| 7 7 | 
             
                    test_users.map! do |test_user|
         | 
| 8 8 | 
             
                      TestUser.new(test_user[:id], test_user)
         | 
| @@ -10,7 +10,7 @@ module FbGraph | |
| 10 10 | 
             
                  end
         | 
| 11 11 |  | 
| 12 12 | 
             
                  def test_user!(options = {})
         | 
| 13 | 
            -
                    options[:access_token] ||= self.access_token | 
| 13 | 
            +
                    options[:access_token] ||= self.access_token
         | 
| 14 14 | 
             
                    test_user = post(options.merge(:connection => :accounts, :connection_scope => 'test-users'))
         | 
| 15 15 | 
             
                    TestUser.new(test_user[:id], test_user)
         | 
| 16 16 | 
             
                  end
         | 
| @@ -9,6 +9,13 @@ module FbGraph | |
| 9 9 | 
             
                      ))
         | 
| 10 10 | 
             
                    end
         | 
| 11 11 | 
             
                  end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  def video!(options = {})
         | 
| 14 | 
            +
                    video = post(options.merge(:connection => :videos))
         | 
| 15 | 
            +
                    Video.new(video[:id], options.merge(video).merge(
         | 
| 16 | 
            +
                      :access_token => options[:access_token] || self.access_token
         | 
| 17 | 
            +
                    ))
         | 
| 18 | 
            +
                  end
         | 
| 12 19 | 
             
                end
         | 
| 13 20 | 
             
              end
         | 
| 14 21 | 
             
            end
         | 
    
        data/lib/fb_graph/group.rb
    CHANGED
    
    
| @@ -1,33 +1,64 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
            describe FbGraph::Application | 
| 4 | 
            -
               | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
                   | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
                 | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 3 | 
            +
            describe FbGraph::Application do
         | 
| 4 | 
            +
              let(:app) { FbGraph::Application.new('client_id') }
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              describe '.new' do
         | 
| 7 | 
            +
                it 'should setup all supported attributes' do
         | 
| 8 | 
            +
                  attributes = {
         | 
| 9 | 
            +
                    :id          => '12345',
         | 
| 10 | 
            +
                    :name        => 'FbGraph',
         | 
| 11 | 
            +
                    :description => 'Owsome Facebook Graph Wrapper',
         | 
| 12 | 
            +
                    :category    => 'Programming',
         | 
| 13 | 
            +
                    :link        => 'http://github.com/nov/fb_graph',
         | 
| 14 | 
            +
                    :secret      => 'sec sec'
         | 
| 15 | 
            +
                  }
         | 
| 16 | 
            +
                  app = FbGraph::Application.new(attributes.delete(:id), attributes)
         | 
| 17 | 
            +
                  app.identifier.should  == '12345'
         | 
| 18 | 
            +
                  app.name.should        == 'FbGraph'
         | 
| 19 | 
            +
                  app.description.should == 'Owsome Facebook Graph Wrapper'
         | 
| 20 | 
            +
                  app.category.should    == 'Programming'
         | 
| 21 | 
            +
                  app.link.should        == 'http://github.com/nov/fb_graph'
         | 
| 22 | 
            +
                  app.secret.should      == 'sec sec'
         | 
| 23 | 
            +
                end
         | 
| 20 24 | 
             
              end
         | 
| 21 | 
            -
            end
         | 
| 22 25 |  | 
| 23 | 
            -
            describe  | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
                 | 
| 27 | 
            -
                   | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 26 | 
            +
              describe '#get_access_token' do
         | 
| 27 | 
            +
                before { app.secret = 'secret' }
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                it 'should return Rack::OAuth2::AccessToken::Legacy' do
         | 
| 30 | 
            +
                  mock_graph :post, 'oauth/access_token', 'token_response' do
         | 
| 31 | 
            +
                    token = app.get_access_token
         | 
| 32 | 
            +
                    token.should be_instance_of(Rack::OAuth2::AccessToken::Legacy)
         | 
| 33 | 
            +
                    token.access_token.should == 'token'
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              describe '#access_token' do
         | 
| 39 | 
            +
                context 'when access token already exists' do
         | 
| 40 | 
            +
                  before { app.access_token = "token" }
         | 
| 41 | 
            +
                  it 'should not fetch new token' do
         | 
| 42 | 
            +
                    app.should_not_receive(:get_access_token)
         | 
| 43 | 
            +
                    app.access_token
         | 
| 44 | 
            +
                  end
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                context 'otherwise' do
         | 
| 48 | 
            +
                  context 'when secret exists' do
         | 
| 49 | 
            +
                    before { app.secret = 'secret' }
         | 
| 50 | 
            +
                    it 'should fetch new token' do
         | 
| 51 | 
            +
                      app.should_receive(:get_access_token)
         | 
| 52 | 
            +
                      app.access_token
         | 
| 53 | 
            +
                    end
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                  context 'otherwise' do
         | 
| 57 | 
            +
                    it 'should not fetch new token' do
         | 
| 58 | 
            +
                      app.should_not_receive(:get_access_token)
         | 
| 59 | 
            +
                      app.access_token
         | 
| 60 | 
            +
                    end
         | 
| 61 | 
            +
                  end
         | 
| 31 62 | 
             
                end
         | 
| 32 63 | 
             
              end
         | 
| 33 64 | 
             
            end
         | 
| @@ -1,11 +1,26 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
            describe FbGraph::Connections::Videos | 
| 4 | 
            -
               | 
| 5 | 
            -
                 | 
| 6 | 
            -
                   | 
| 7 | 
            -
             | 
| 8 | 
            -
                     | 
| 3 | 
            +
            describe FbGraph::Connections::Videos do
         | 
| 4 | 
            +
              describe '#videos' do
         | 
| 5 | 
            +
                it 'should return videos as FbGraph::Video' do
         | 
| 6 | 
            +
                  mock_graph :get, 'kirk/videos', 'users/videos/kirk_private', :access_token => 'access_token' do
         | 
| 7 | 
            +
                    videos = FbGraph::User.new('kirk', :access_token => 'access_token').videos
         | 
| 8 | 
            +
                    videos.each do |video|
         | 
| 9 | 
            +
                      video.should be_instance_of(FbGraph::Video)
         | 
| 10 | 
            +
                    end
         | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              describe '#video!' do
         | 
| 16 | 
            +
                it 'should return generated photo' do
         | 
| 17 | 
            +
                  mock_graph :post, 'me/videos', 'users/videos/posted' do
         | 
| 18 | 
            +
                    me = FbGraph::User.me('access_token')
         | 
| 19 | 
            +
                    video = me.video!(
         | 
| 20 | 
            +
                      :source => Tempfile.new('movie_file')
         | 
| 21 | 
            +
                    )
         | 
| 22 | 
            +
                    video.should be_a FbGraph::Video
         | 
| 23 | 
            +
                    video.identifier.should == '10150241488822277'
         | 
| 9 24 | 
             
                  end
         | 
| 10 25 | 
             
                end
         | 
| 11 26 | 
             
              end
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            {"id":"10150241488822277"}
         | 
    
        metadata
    CHANGED
    
    | @@ -2,7 +2,7 @@ | |
| 2 2 | 
             
            name: fb_graph
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 4 | 
             
              prerelease: 
         | 
| 5 | 
            -
              version: 1.8. | 
| 5 | 
            +
              version: 1.8.6
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors: 
         | 
| 8 8 | 
             
            - nov matake
         | 
| @@ -10,7 +10,7 @@ autorequire: | |
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 12 |  | 
| 13 | 
            -
            date: 2011-06- | 
| 13 | 
            +
            date: 2011-06-18 00:00:00 Z
         | 
| 14 14 | 
             
            dependencies: 
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 16 16 | 
             
              name: httpclient
         | 
| @@ -403,6 +403,7 @@ files: | |
| 403 403 | 
             
            - spec/mock_json/users/tagged/arjun_public.json
         | 
| 404 404 | 
             
            - spec/mock_json/users/television/matake_private.json
         | 
| 405 405 | 
             
            - spec/mock_json/users/videos/kirk_private.json
         | 
| 406 | 
            +
            - spec/mock_json/users/videos/posted.json
         | 
| 406 407 | 
             
            - spec/spec_helper.rb
         | 
| 407 408 | 
             
            homepage: http://github.com/nov/fb_graph
         | 
| 408 409 | 
             
            licenses: []
         | 
| @@ -642,4 +643,5 @@ test_files: | |
| 642 643 | 
             
            - spec/mock_json/users/tagged/arjun_public.json
         | 
| 643 644 | 
             
            - spec/mock_json/users/television/matake_private.json
         | 
| 644 645 | 
             
            - spec/mock_json/users/videos/kirk_private.json
         | 
| 646 | 
            +
            - spec/mock_json/users/videos/posted.json
         | 
| 645 647 | 
             
            - spec/spec_helper.rb
         |