Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
This service listens to commits and push it to an iceScrum server. Te…
…sts and documentation are included.
  • Loading branch information
vbarrier committed Apr 27, 2012
1 parent 827d890 commit 6a248ef
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 0 deletions.
33 changes: 33 additions & 0 deletions docs/icescrum
@@ -0,0 +1,33 @@
iceScrum
========

iceScrum is a an open source web application for using Scrum while keeping the spirit of a collaborative workspace. It also offers virtual boards with post-its for sprint backlog, product backlog and others. You can use iceScrum on your own server or in the cloud (SaaS) with Kagilum.

Integrating with GitHub will allow you to associate Git commits to specific tasks. If you add a task number (ID) to your commit message, iceScrum will associate the commit with the task.

For example, if you add the text 'T76' to your commit message, iceScrum will attach the commit to task 76 and move the task to in Progress column in the Sprint Plan.One or more TXX in the same commit message. You can also update the remaining time on the task if you write : 'T76-4' : iceScrum will update remaining time to 4 hours for the task 76.

This allows your team to stay up to date on the latest development work and view a history of commits for each story / task.

More information on iceScrum : http://www.icescrum.org
More information on Kagilum : https://www.kagilum.com

Install Notes
-------------

1. **project_key** - This is your iceScrum Project key.
2. **username** - Username of one team member in the project (such as the ScrumMaster).
3. **password** - Password of one team member in the project.
4. **base_url** - Base_url is the url where your iceScrum is alive (http://www.example.com/icescrum). This is input is optional if not set "https://www.kagilum.com/a" for iceScrum Cloud customers.

Developer Notes
---------------

data
- username
- password
- project_key
- base_url

payload
- refer to docs/github_payload
26 changes: 26 additions & 0 deletions services/icescrum.rb
@@ -0,0 +1,26 @@
class Service::IceScrum < Service
string :base_url, :username, :project_key, :password

def receive_push
raise_config_error "Invalid username" if data['username'].to_s.empty?
raise_config_error "Invalid password" if data['password'].to_s.empty?
raise_config_error "Invalid project key" if data['project_key'].to_s.empty?

username = data['username'].to_s.gsub(/\s+/, "")
project_key = data['project_key'].to_s.upcase.gsub(/\s+/, "")
password = data['password'].to_s.gsub(/\s+/, "")

if data['base_url'].present?
url = "#{data['base_url']}/ws/p/#{project_key}/commit/save"
else
url = "https://www.kagilum.com/a/ws/p/#{project_key}/commit/save"
end

http.ssl[:verify] = false
http.basic_auth username, password

http_post url, { :payload => payload.to_json }
end

end

127 changes: 127 additions & 0 deletions test/icescrum_test.rb
@@ -0,0 +1,127 @@
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/save" 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/save" 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/save" 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/save" 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




0 comments on commit 6a248ef

Please sign in to comment.