Skip to content

Commit

Permalink
Merge pull request github#279 from JonnyFunFun/master
Browse files Browse the repository at this point in the history
Updated TP hook to play nicely with latest REST API changes
  • Loading branch information
technoweenie committed Apr 11, 2012
2 parents e24f5df + e37b95c commit f84eb04
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions services/target_process.rb
Expand Up @@ -47,7 +47,7 @@ def execute_command(author, entity_id, command, commit_message, commit_url)
# get the user's id
res = http_get "api/v1/Users", {:where => "(Email eq '%s')" % author}
valid_response?(res)
author_id = begin Hash.from_xml(res.body)['Items']['User']['Id'] rescue nil end
author_id = begin Hash.from_xml(res.body)['Users']['User']['Id'] rescue nil end
return if author_id.nil?
# get Context data for our project
res = http_get "api/v1/Context", :ids => @project_id
Expand All @@ -64,7 +64,7 @@ def execute_command(author, entity_id, command, commit_message, commit_url)
res = http_get "api/v1/Processes/%s/EntityStates" % [context_data['Context']['Processes']['ProcessInfo']['Id']],
{:where => "(Name eq '%s') and (EntityType.Name eq '%s')" % [command, entity_type], :acid => acid}
valid_response?(res)
new_state = begin Hash.from_xml(res.body)['Items']['EntityState']['Id'] rescue nil end
new_state = begin Hash.from_xml(res.body)['EntityStates']['EntityState']['Id'] rescue nil end
# Make it happen
http.headers['Content-Type'] = 'application/json'
commit_message = "#{commit_message}<br />Commit: #{commit_url}"
Expand Down
4 changes: 2 additions & 2 deletions test/target_process_test.rb
Expand Up @@ -16,14 +16,14 @@ def test_push
@stubs.get "/tp/api/v1/Users?where=(Email%20eq%20'jonnyfunfun@gmail.com')" do |env|
assert_equal basic_auth('uz0r', 'p455w0rd'), env[:request_headers]['authorization']
assert_equal "(Email eq 'jonnyfunfun@gmail.com')", env[:params]['where']
[200, {}, '<Items><User Id="31337"><Email>jonnyfunfun@gmail.com</Email></User><User Id="3"><Email>foobar@snafu.com</Email></User></Items>']
[200, {}, '<Users><User Id="31337"><Email>jonnyfunfun@gmail.com</Email></User><User Id="3"><Email>foobar@snafu.com</Email></User></Users>']
end

@stubs.get "/tp/api/v1/Processes/OMGWTFBBQ/EntityStates?where(Name%20eq%20'fubar')%20and%20(EntityType.Name%20eq%20'Bug')" do |env|
assert_equal 'ZOMG', env[:params]['acid']
assert_equal "(Name eq 'fubar') and (EntityType.Name eq 'Bug')", env[:params]['where']
assert_equal basic_auth('uz0r', 'p455w0rd'), env[:request_headers]['authorization']
[200, {}, '<Items><EntityState Name="fubar" Id="21"/><EntityState Name="not me" Id="0"/></Items>']
[200, {}, '<EntityStates><EntityState Name="fubar" Id="21"/><EntityState Name="not me" Id="0"/></EntityStates>']
end

@stubs.get "/tp/api/v1/Assignables/1783?acid=ZOMG&include=%5BEntityType%5D" do |env|
Expand Down

0 comments on commit f84eb04

Please sign in to comment.