Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

FogbugzService expects parameters separately, and uses HTTP POST to t…

…alk with FogBugz.

Removed dependency on ActiveSupport.
  • Loading branch information...
commit c3726e4eab13185fbce5524076364f8fbd432ccc 1 parent 9d607fc
@francois francois authored
View
1  Rakefile
@@ -22,7 +22,6 @@ spec = Gem::Specification.new do |s|
s.homepage = HOMEPAGE
# Uncomment this to add a dependency
- s.add_dependency "activesupport", "~> 2.0"
s.add_dependency "json", "~> 1.1.2"
s.require_path = "lib"
View
2  bin/github-fogbugz
@@ -180,7 +180,7 @@ class GithubFogbugz
author = commit["author"]["email"]
token = tokens[author]
- submit_to_fogbugz(sha1, commit, token, curl_path) unless token.blank?
+ submit_to_fogbugz(sha1, commit, token, curl_path) if token
files = commit["removed"] | commit["added"] | commit["modified"]
View
2  lib/fogbugz_listener.rb
@@ -2,7 +2,7 @@ class FogbugzListener
attr_reader :options
def initialize(options={})
- @options = options.symbolize_keys
+ @options = options
@state = :invalid
@actions = Hash.new {|h, k| h[k] = Array.new}
end
View
7 lib/fogbugz_service.rb
@@ -1,7 +1,7 @@
require "uri"
require "rexml/document"
require "rexml/xpath"
-require "activesupport"
+require "cgi"
class FogbugzService
class FogbugzError < RuntimeError; end
@@ -37,7 +37,7 @@ def logon(email, password)
params = {"cmd" => "logon", "email" => email, "password" => password}
document = get(@api_uri, params)
bad_logon = REXML::XPath.first(document.root, "//error")
- raise BadCredentials, "Bad credentials supplied to Fogbugz: #{bad_logon}" unless bad_logon.blank?
+ raise BadCredentials, "Bad credentials supplied to Fogbugz: #{bad_logon}" if bad_logon
REXML::XPath.first(document.root, "//token/text()").to_s
end
@@ -65,7 +65,8 @@ def append_message(data)
# Returns an REXML::Document to the specified URI
def get(uri, params=nil)
cmd = if params then
- "#{@curl} --data '#{params.to_query}' --silent '#{uri.to_s}'"
+ query = params.map {|k, v| "#{CGI::escape(k.to_s)}=#{CGI::escape(v.to_s)}"}.join("&")
+ "#{@curl} --data '#{query}' --silent '#{uri.to_s}'"
else
"#{@curl} --silent '#{uri.to_s}'"
end
View
30 test/fogbugz_service_case_editing_test.rb
@@ -12,37 +12,37 @@ def setup
end
def test_implement_calls_fogbugz_with_cmd_set_to_resolve_and_status_set_to_implement
- @uri.query = {"cmd" => "resolve", "ixBug" => "2211", "ixStatus" => FogbugzService::STATES[:implemented],
- "sEvent" => "this is the message", "token" => TOKEN}.to_query
- @service.expects(:get).with(@uri).returns(REXML::Document.new(VALID_EDIT_RESPONSE))
+ params = {"cmd" => "resolve", "ixBug" => "2211", "ixStatus" => FogbugzService::STATES[:implemented],
+ "sEvent" => "this is the message", "token" => TOKEN}
+ @service.expects(:get).with(@uri, params).returns(REXML::Document.new(VALID_EDIT_RESPONSE))
@service.implement(:case => "2211", :message => "this is the message")
end
def test_fix_calls_fogbugz_with_cmd_set_to_resolve_and_status_set_to_fixed
- @uri.query = {"cmd" => "resolve", "ixBug" => "2211", "ixStatus" => FogbugzService::STATES[:fixed],
- "sEvent" => "this is the message", "token" => TOKEN}.to_query
- @service.expects(:get).with(@uri).returns(REXML::Document.new(VALID_EDIT_RESPONSE))
+ params = {"cmd" => "resolve", "ixBug" => "2211", "ixStatus" => FogbugzService::STATES[:fixed],
+ "sEvent" => "this is the message", "token" => TOKEN}
+ @service.expects(:get).with(@uri, params).returns(REXML::Document.new(VALID_EDIT_RESPONSE))
@service.fix(:case => "2211", :message => "this is the message")
end
def test_complete_calls_fogbugz_with_cmd_set_to_resolve_and_status_set_to_completed
- @uri.query = {"cmd" => "resolve", "ixBug" => "2211", "ixStatus" => FogbugzService::STATES[:completed],
- "sEvent" => "this is the message", "token" => TOKEN}.to_query
- @service.expects(:get).with(@uri).returns(REXML::Document.new(VALID_EDIT_RESPONSE))
+ params = {"cmd" => "resolve", "ixBug" => "2211", "ixStatus" => FogbugzService::STATES[:completed],
+ "sEvent" => "this is the message", "token" => TOKEN}
+ @service.expects(:get).with(@uri, params).returns(REXML::Document.new(VALID_EDIT_RESPONSE))
@service.complete(:case => "2211", :message => "this is the message")
end
def test_close_calls_fogbugz_with_cmd_set_to_close
- @uri.query = {"cmd" => "close", "ixBug" => "2211",
- "sEvent" => "this is the message", "token" => TOKEN}.to_query
- @service.expects(:get).with(@uri).returns(REXML::Document.new(VALID_EDIT_RESPONSE))
+ params = {"cmd" => "close", "ixBug" => "2211",
+ "sEvent" => "this is the message", "token" => TOKEN}
+ @service.expects(:get).with(@uri, params).returns(REXML::Document.new(VALID_EDIT_RESPONSE))
@service.close(:case => "2211", :message => "this is the message")
end
def test_append_message_calls_fogbugz_with_cmd_set_to_edit
- @uri.query = {"cmd" => "edit", "ixBug" => "2211",
- "sEvent" => "this is the message", "token" => TOKEN}.to_query
- @service.expects(:get).with(@uri).returns(REXML::Document.new(VALID_EDIT_RESPONSE))
+ params = {"cmd" => "edit", "ixBug" => "2211",
+ "sEvent" => "this is the message", "token" => TOKEN}
+ @service.expects(:get).with(@uri, params).returns(REXML::Document.new(VALID_EDIT_RESPONSE))
@service.append_message(:case => "2211", :message => "this is the message")
end
View
5 test/fogbugz_service_logon_test.rb
@@ -10,9 +10,8 @@ def setup
end
def test_logon_calls_fogbugz_to_retrieve_token
- params = {"cmd" => "logon", "email" => "me@my-domain.com", "password" => "my-super-duper-password"}.to_query
- @uri.query = params
- @service.expects(:get).with(@uri).returns(REXML::Document.new(VALID_LOGON_RESPONSE))
+ params = {"cmd" => "logon", "email" => "me@my-domain.com", "password" => "my-super-duper-password"}
+ @service.expects(:get).with(@uri, params).returns(REXML::Document.new(VALID_LOGON_RESPONSE))
@service.logon("me@my-domain.com", "my-super-duper-password")
end
Please sign in to comment.
Something went wrong with that request. Please try again.