Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

128 lines (103 sloc) 3.065 kB
require File.expand_path('../helper', __FILE__)
class IceScrumTest < Service::TestCase
def setup
@stubs = Faraday::Adapter::Test::Stubs.new
end
def test_push_valid
@stubs.post "/a/ws/p/TESTPROJ/commit" do |env|
assert_equal 'www.kagilum.com', env[:url].host
assert_equal basic_auth(:u, :p), env[:request_headers]['authorization']
body = Rack::Utils.parse_nested_query(env[:body])
recv = JSON.parse(body['payload'])
assert_equal payload, recv
[200, {}, '']
end
svc = service({
'username' => 'u',
'password' => 'p',
'project_key' => 'TESTPROJ'
}, payload)
svc.receive_push
@stubs.verify_stubbed_calls
end
def test_push_valid_custom_url
@stubs.post "/icescrum/ws/p/TESTPROJ/commit" do |env|
assert_equal 'www.example.com', env[:url].host
assert_equal basic_auth(:u, :p), env[:request_headers]['authorization']
body = Rack::Utils.parse_nested_query(env[:body])
recv = JSON.parse(body['payload'])
assert_equal payload, recv
[200, {}, '']
end
svc = service({
'username' => 'u',
'password' => 'p',
'project_key' => 'TESTPROJ',
'base_url' => 'http://www.example.com/icescrum'
}, payload)
svc.receive_push
@stubs.verify_stubbed_calls
end
def test_push_lowcase_project_key
@stubs.post "/a/ws/p/TESTPROJ/commit" do |env|
assert_equal basic_auth(:u, :p), env[:request_headers]['authorization']
body = Rack::Utils.parse_nested_query(env[:body])
recv = JSON.parse(body['payload'])
assert_equal payload, recv
[200, {}, '']
end
svc = service({
'username' => 'u',
'password' => 'p',
'project_key' => 'testProj'
}, payload)
svc.receive_push
@stubs.verify_stubbed_calls
end
def test_push_whitespace_project_key
@stubs.post "/a/ws/p/TESTPROJ/commit" do |env|
assert_equal basic_auth(:u, :p), env[:request_headers]['authorization']
body = Rack::Utils.parse_nested_query(env[:body])
recv = JSON.parse(body['payload'])
assert_equal payload, recv
[200, {}, '']
end
svc = service({
'username' => ' u ',
'password' => ' p ',
'project_key' => ' TEST PROJ '
}, payload)
svc.receive_push
@stubs.verify_stubbed_calls
end
def test_push_missing_username
svc = service({
'password' => 'p',
'project_key' => 'TESTPROJ'
}, payload)
assert_raises Service::ConfigurationError do
svc.receive_push
end
end
def test_push_missing_password
svc = service({
'username' => 'u',
'project_key' => 'TESTPROJ'
}, payload)
assert_raises Service::ConfigurationError do
svc.receive_push
end
end
def test_push_missing_project_key
svc = service({
'username' => 'u',
'password' => 'p',
}, payload)
assert_raises Service::ConfigurationError do
svc.receive_push
end
end
def service(*args)
super Service::IceScrum, *args
end
end
Jump to Line
Something went wrong with that request. Please try again.