Sha256: ef9207606f9e2d6381805706f6ef23ec20a01569f4531a731efc4cfaf9f42aa0

Contents?: true

Size: 1.76 KB

Versions: 41

Compression:

Stored size: 1.76 KB

Contents

require 'spec_helper'

describe FbGraph::Connections::Roles do
  let(:app) do
    FbGraph::Application.new('app_id', :secret => 'app_secret')
  end

  describe '#roles' do
    it 'should return an Array of FbGraph::Role' do
      mock_graph :post, 'oauth/access_token', 'app_token_response' do
        mock_graph :get, 'app_id/roles', 'applications/roles/list', :access_token => 'app_token' do
          roles = app.roles
          roles.should be_instance_of FbGraph::Connection
          roles.each do |role|
            role.should be_instance_of FbGraph::Role
          end
          roles.first.user.should == FbGraph::User.new('579612276')
          roles.first.application.== FbGraph::Application.new('210798282372757')
          roles.first.role.should == 'administrators'
        end
      end
    end
  end

  {
    :admin!         => 'administrators',
    :developer!     => 'developers',
    :tester!        => 'testers',
    :insights_user! => 'insights users'
  }.each do |method, role|
    describe "##{method}" do
      it 'should return true' do
        mock_graph :post, 'app_id/roles', 'true', :access_token => 'admin_user_token', :params => {
          :user => 'new_admin_uid',
          :role => role
        } do
          app.send(
            method,
            FbGraph::User.new('new_admin_uid'),
            :access_token => 'admin_user_token'
          ).should be_true
        end
      end
    end
  end

  describe '#unrole!' do
    it 'should return true' do
      mock_graph :delete, 'app_id/roles', 'true', :access_token => 'role_owner_token', :params => {
        :user => 'role_owner_uid'
      } do
        app.unrole!(
          FbGraph::User.new('role_owner_uid'),
          :access_token => 'role_owner_token'
        ).should be_true
      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/roles_spec.rb
fb_graph-2.7.16 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.7.15 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.7.14 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.7.13 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.7.12 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.7.11 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.7.10 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.7.9 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.7.8 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.7.7 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.7.6 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.7.5 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.7.4 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.7.3 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.7.2 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.7.1 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.7.0 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.6.7 spec/fb_graph/connections/roles_spec.rb
fb_graph-2.6.6 spec/fb_graph/connections/roles_spec.rb