1 require File.dirname(__FILE__) + '/../test_helper'
3 class RequestTokenTest < ActiveSupport::TestCase
5 fixtures :client_applications, :users, :oauth_tokens
8 @token = RequestToken.create :client_application=>client_applications(:one)
11 def test_should_be_valid
15 def test_should_not_have_errors
16 assert @token.errors.empty?
19 def test_should_have_a_token
20 assert_not_nil @token.token
23 def test_should_have_a_secret
24 assert_not_nil @token.secret
27 def test_should_not_be_authorized
28 assert !@token.authorized?
31 def test_should_not_be_invalidated
32 assert !@token.invalidated?
35 def test_should_authorize_request
36 @token.authorize!(users(:quentin))
37 assert @token.authorized?
38 assert_not_nil @token.authorized_at
39 assert_equal users(:quentin), @token.user
42 def test_should_not_exchange_without_approval
43 assert_equal false, @token.exchange!
44 assert_equal false, @token.invalidated?
47 def test_should_not_exchange_without_approval
48 @token.authorize!(users(:quentin))
49 @access = @token.exchange!
50 assert_not_equal false, @access
51 assert @token.invalidated?
53 assert_equal users(:quentin), @access.user
54 assert @access.authorized?