Sha256: 937fee619f10774c81ba8ef41ea88bf008f99fe8b396815d10032c69d4dc618f

Contents?: true

Size: 1.95 KB

Versions: 11

Compression:

Stored size: 1.95 KB

Contents

require File.expand_path('../../test_helper', __FILE__)

class UserWithFb < User
  include Authpwn::UserExtensions::FacebookFields
end

class FacebookFieldsTest < ActiveSupport::TestCase
  def setup
    @user = UserWithFb.new

    @john = UserWithFb.find_by_id(users(:john).id)
    @jane = UserWithFb.find_by_id(users(:jane).id)
    @bill = UserWithFb.find_by_id(users(:bill).id)
  end

  test 'setup' do
    assert @user.valid?
  end

  test 'facebook_credential' do
    assert_equal credentials(:john_facebook), @john.facebook_credential
    assert_equal credentials(:jane_facebook), @jane.facebook_credential
    assert_nil @bill.facebook_credential
  end

  test 'facebook_uid' do
    assert_equal credentials(:john_facebook).facebook_uid, @john.facebook_uid
    assert_equal credentials(:jane_facebook).facebook_uid, @jane.facebook_uid
    assert_nil @bill.facebook_uid
  end

  test 'facebook_access_token' do
    assert_equal credentials(:john_facebook).access_token,
                 @john.facebook_access_token
    assert_equal credentials(:jane_facebook).access_token,
                 @jane.facebook_access_token
    assert_nil @bill.facebook_access_token
  end

  test 'facebook_client' do
    assert_equal credentials(:john_facebook).access_token,
                 @john.facebook_client.access_token
    assert_nil @bill.facebook_client
  end

  test 'with_facebook_uid' do
    assert_equal users(:john), UserWithFb.with_facebook_uid(
        credentials(:john_facebook).facebook_uid)
    assert_equal users(:jane), UserWithFb.with_facebook_uid(
        credentials(:jane_facebook).facebook_uid)
    assert_nil UserWithFb.with_facebook_uid('0000000')
  end

  test 'for_facebook_token' do
    Credentials::Facebook.expects(:uid_from_token).at_least_once.
        with(credentials(:john_facebook).key).
        returns credentials(:john_facebook).facebook_uid
    assert_equal users(:john),
        UserWithFb.for_facebook_token(credentials(:john_facebook).access_token)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
authpwn_rails-0.16.2 test/user_extensions/facebook_fields_test.rb
authpwn_rails-0.16.1 test/user_extensions/facebook_fields_test.rb
authpwn_rails-0.16.0 test/user_extensions/facebook_fields_test.rb
authpwn_rails-0.15.3 test/user_extensions/facebook_fields_test.rb
authpwn_rails-0.15.2 test/user_extensions/facebook_fields_test.rb
authpwn_rails-0.15.1 test/user_extensions/facebook_fields_test.rb
authpwn_rails-0.15.0 test/user_extensions/facebook_fields_test.rb
authpwn_rails-0.14.3 test/user_extensions/facebook_fields_test.rb
authpwn_rails-0.14.2 test/user_extensions/facebook_fields_test.rb
authpwn_rails-0.14.1 test/user_extensions/facebook_fields_test.rb
authpwn_rails-0.14.0 test/user_extensions/facebook_fields_test.rb