Skip to content

Commit c7e95ca

Browse files
author
Agora@Ubuntu-dev
committed
Fix specs for test_request_token
1 parent 174606d commit c7e95ca

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

test/units/test_request_token.rb

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
require File.expand_path('../../test_helper', __FILE__)
22

33
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
66
end
77
end
88

@@ -40,14 +40,38 @@ def test_request_token_returns_nil_authorize_url_when_token_is_nil
4040
assert_nil @request_token.authorize_url
4141
end
4242

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+
4367
#TODO: mock out the Consumer to test the Consumer/AccessToken interaction.
4468
def test_get_access_token
4569
end
4670

47-
def test_build_authorize_url
71+
def test_build_url
4872
@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(
5175
"http://github.com/oauth/authorize",
5276
{:foo => "bar bar"})
5377
assert url

0 commit comments

Comments
 (0)