]> git.openstreetmap.org Git - rails.git/blob - vendor/plugins/oauth-plugin/generators/oauth_provider/templates/oauth_token_spec.rb
Merge 17067 from trunk.
[rails.git] / vendor / plugins / oauth-plugin / generators / oauth_provider / templates / oauth_token_spec.rb
1 require File.dirname(__FILE__) + '/../spec_helper'
2
3 describe RequestToken do
4   fixtures :client_applications, :users, :oauth_tokens
5   before(:each) do
6     @token = RequestToken.create :client_application => client_applications(:one)
7   end
8
9   it "should be valid" do
10     @token.should be_valid
11   end
12   
13   it "should not have errors" do
14     @token.errors.should_not == []
15   end
16   
17   it "should have a token" do
18     @token.token.should_not be_nil
19   end
20
21   it "should have a secret" do
22     @token.secret.should_not be_nil
23   end
24   
25   it "should not be authorized" do 
26     @token.should_not be_authorized
27   end
28
29   it "should not be invalidated" do
30     @token.should_not be_invalidated
31   end
32   
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)
38   end
39   
40   it "should not exchange without approval" do
41     @token.exchange!.should == false
42     @token.should_not be_invalidated
43   end
44   
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
50     
51     @access.user.should == users(:quentin)
52     @access.should be_authorized
53   end
54   
55 end