Skip to content

Commit

Permalink
Added projects create
Browse files Browse the repository at this point in the history
  • Loading branch information
jwright committed Jul 26, 2013
1 parent f483292 commit 36d1f65
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ This is a very early release. All the base classes and supporting classes should
* Support for OAuth authentication

* Clients (update, get, delete)
* Projects (create, update, get, delete)
* Projects (update, get, delete)
* Categories (create, update, get, delete, list)
* Estimates (create, update, get, delete, list, sendByEmail)
* Categories (create, update, get, delete, list)
Expand Down
4 changes: 4 additions & 0 deletions spec/fixtures/new_project_successful_response.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<response xmlns="http://www.freshbooks.com/api/" status="ok">
<project_id>15</project_id>
</response>
32 changes: 32 additions & 0 deletions spec/lib/sox/projects_operations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,36 @@
response[:projects][:project][0][:client_id][:data].should == '119'
end
end

it 'can create a new project' do
body = load_fixture('new_project_successful_response.xml')
stub_request(:post, @client.base_url).to_return body: body, content_type: 'application/xml'

request = { project: {
name: 'Website Redesign',
bill_method: 'project-rate',
client_id: 21,
rate: 45.00,
description: 'A new website for ABC Corp',
tasks: {
task: {
task_id: 5
},
task: {
task_id: 3
}
}
} }

@client.projects.create(request) do |r|
@response = r
resume
end
wait_max 1.0 do
response = @response[:response]
response[:status].should == 'ok'
response[:project_id][:data].should == '15'
end
end

end

0 comments on commit 36d1f65

Please sign in to comment.