|
1 | 1 | require File.expand_path('../../test_helper', __FILE__) |
2 | 2 |
|
3 | 3 | class StubbedToken < OAuth::RequestToken |
4 | | - define_method :build_authorize_url_promoted do |root_domain, params| |
5 | | - build_authorize_url root_domain, params |
| 4 | + define_method :build_url_promoted do |root_domain, params| |
| 5 | + build_url root_domain, params |
6 | 6 | end |
7 | 7 | end |
8 | 8 |
|
@@ -40,14 +40,38 @@ def test_request_token_returns_nil_authorize_url_when_token_is_nil |
40 | 40 | assert_nil @request_token.authorize_url |
41 | 41 | end |
42 | 42 |
|
| 43 | + def test_request_token_builds_authenticate_url_connectly_with_additional_params |
| 44 | + authenticate_url = @request_token.authenticate_url({:oauth_callback => "github.com"}) |
| 45 | + assert authenticate_url |
| 46 | + assert_match(/oauth_token/, authenticate_url) |
| 47 | + assert_match(/oauth_callback/, authenticate_url) |
| 48 | + end |
| 49 | + |
| 50 | + def test_request_token_builds_authenticate_url_connectly_with_no_or_nil_params |
| 51 | + # we should only have 1 key in the url returned if we didn't pass anything. |
| 52 | + # this is the only required param to authenticate the client. |
| 53 | + authenticate_url = @request_token.authenticate_url(nil) |
| 54 | + assert authenticate_url |
| 55 | + assert_match(/\?oauth_token=/, authenticate_url) |
| 56 | + |
| 57 | + authenticate_url2 = @request_token.authenticate_url |
| 58 | + assert authenticate_url2 |
| 59 | + assert_match(/\?oauth_token=/, authenticate_url2) |
| 60 | + end |
| 61 | + |
| 62 | + def test_request_token_returns_nil_authenticate_url_when_token_is_nil |
| 63 | + @request_token.token = nil |
| 64 | + assert_nil @request_token.authenticate_url |
| 65 | + end |
| 66 | + |
43 | 67 | #TODO: mock out the Consumer to test the Consumer/AccessToken interaction. |
44 | 68 | def test_get_access_token |
45 | 69 | end |
46 | 70 |
|
47 | | - def test_build_authorize_url |
| 71 | + def test_build_url |
48 | 72 | @stubbed_token = StubbedToken.new(nil, nil, nil) |
49 | | - assert_respond_to @stubbed_token, :build_authorize_url_promoted |
50 | | - url = @stubbed_token.build_authorize_url_promoted( |
| 73 | + assert_respond_to @stubbed_token, :build_url_promoted |
| 74 | + url = @stubbed_token.build_url_promoted( |
51 | 75 | "http://github.com/oauth/authorize", |
52 | 76 | {:foo => "bar bar"}) |
53 | 77 | assert url |
|
0 commit comments