1 require File.dirname(__FILE__) + '/../spec_helper'
3 describe RequestToken do
4 fixtures :client_applications, :users, :oauth_tokens
6 @token = RequestToken.create :client_application => client_applications(:one)
9 it "should be valid" do
10 @token.should be_valid
13 it "should not have errors" do
14 @token.errors.should_not == []
17 it "should have a token" do
18 @token.token.should_not be_nil
21 it "should have a secret" do
22 @token.secret.should_not be_nil
25 it "should not be authorized" do
26 @token.should_not be_authorized
29 it "should not be invalidated" do
30 @token.should_not be_invalidated
33 it "should authorize request" do
34 @token.authorize!(users(:quentin))
35 @token.should be_authorized
36 @token.authorized_at.should_not be_nil
37 @token.user.should == users(:quentin)
40 it "should not exchange without approval" do
41 @token.exchange!.should == false
42 @token.should_not be_invalidated
45 it "should not exchange without approval" do
46 @token.authorize!(users(:quentin))
47 @access = @token.exchange!
48 @access.should_not == false
49 @token.should be_invalidated
51 @access.user.should == users(:quentin)
52 @access.should be_authorized