Sha256: 78ced33553cdd78eba39f3cd882317234ba0a7889704c17c0ee319a1fc78eac0

Contents?: true

Size: 1.85 KB

Versions: 41

Compression:

Stored size: 1.85 KB

Contents

require 'spec_helper'

describe FbGraph::Connections::Banned do
  let(:app)  { FbGraph::Application.new('app_id', :secret => 'app_secret') }
  let(:user) { FbGraph::User.new('uid') }

  describe '#banned' do
    it 'should return an Array of FbGraph::User' do
      mock_graph :post, 'oauth/access_token', 'app_token_response' do
        mock_graph :get, 'app_id/banned', 'applications/banned/list', :access_token => 'app_token' do
          users = app.banned
          users.each do |user|
            user.should be_a FbGraph::User
          end
        end
      end
    end
  end

  describe '#banned?' do
    context 'when banned' do
      it 'should retrun true' do
        mock_graph :post, 'oauth/access_token', 'app_token_response' do
          mock_graph :get, 'app_id/banned/uid', 'applications/banned/banned_user', :access_token => 'app_token' do
            app.banned?(user).should be_true
          end
        end
      end
    end

    context 'otherwise' do
      it 'should retrun false' do
        mock_graph :post, 'oauth/access_token', 'app_token_response' do
          mock_graph :get, 'app_id/banned/uid', 'empty', :access_token => 'app_token' do
            app.banned?(user).should be_false
          end
        end
      end
    end
  end

  describe '#ban!' do
    it 'should return true' do
      mock_graph :post, 'oauth/access_token', 'app_token_response' do
        mock_graph :post, 'app_id/banned', 'true', :access_token => 'app_token', :params => {
          :uid => 'uid'
        } do
          app.ban!(user).should be_true
        end
      end
    end
  end

  describe '#unban!' do
    it 'should return true' do
      mock_graph :post, 'oauth/access_token', 'app_token_response' do
        mock_graph :delete, 'app_id/banned/uid', 'true', :access_token => 'app_token' do
          app.unban!(user).should be_true
        end
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
fb_graph-2.7.17 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.16 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.15 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.14 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.13 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.12 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.11 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.10 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.9 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.8 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.7 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.6 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.5 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.4 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.3 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.2 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.1 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.7.0 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.6.7 spec/fb_graph/connections/banned_spec.rb
fb_graph-2.6.6 spec/fb_graph/connections/banned_spec.rb