]> git.openstreetmap.org Git - rails.git/blob - vendor/plugins/oauth-plugin/generators/oauth_provider/templates/client_application_spec.rb
Merge 16110:16487 from trunk.
[rails.git] / vendor / plugins / oauth-plugin / generators / oauth_provider / templates / client_application_spec.rb
1 require File.dirname(__FILE__) + '/../spec_helper'
2 module OAuthSpecHelpers
3   
4   def create_consumer
5     @consumer = OAuth::Consumer.new(@application.key,@application.secret,
6       {
7         :site => @application.oauth_server.base_url
8       })
9   end
10   
11   def create_test_request
12     
13   end
14   
15   def create_oauth_request
16     @token = AccessToken.create :client_application => @application, :user => users(:quentin)
17     @request = @consumer.create_signed_request(:get, "/hello", @token)
18   end
19   
20   def create_request_token_request
21     @request = @consumer.create_signed_request(:get, @application.oauth_server.request_token_path, @token)
22   end
23   
24   def create_access_token_request
25     @token = RequestToken.create :client_application => @application
26     @request = @consumer.create_signed_request(:get, @application.oauth_server.request_token_path, @token)
27   end
28   
29 end
30
31 describe ClientApplication do #, :shared => true do
32   include OAuthSpecHelpers
33   fixtures :users, :client_applications, :oauth_tokens
34   before(:each) do
35     @application = ClientApplication.create :name => "Agree2", :url => "http://agree2.com", :user => users(:quentin)
36     create_consumer
37   end
38
39   it "should be valid" do
40     @application.should be_valid
41   end
42   
43     
44   it "should not have errors" do
45     @application.errors.full_messages.should == []
46   end
47   
48   it "should have key and secret" do
49     @application.key.should_not be_nil
50     @application.secret.should_not be_nil
51   end
52
53   it "should have credentials" do
54     @application.credentials.should_not be_nil
55     @application.credentials.key.should == @application.key
56     @application.credentials.secret.should == @application.secret
57   end
58   
59 end
60