confuddle 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. data/.gitignore +18 -0
  2. data/.passwd_to_unfuddle.example.yml +7 -0
  3. data/README.md +40 -0
  4. data/bin/un +833 -0
  5. data/bin/un.cmd +1 -0
  6. data/confuddle.gemspec +22 -0
  7. data/lib/graft/README.rdoc +138 -0
  8. data/lib/graft/Rakefile +43 -0
  9. data/lib/graft/lib/graft/core_ext/hash.rb +9 -0
  10. data/lib/graft/lib/graft/json.rb +14 -0
  11. data/lib/graft/lib/graft/json/attribute.rb +18 -0
  12. data/lib/graft/lib/graft/json/model.rb +28 -0
  13. data/lib/graft/lib/graft/model.rb +43 -0
  14. data/lib/graft/lib/graft/version.rb +13 -0
  15. data/lib/graft/lib/graft/xml.rb +19 -0
  16. data/lib/graft/lib/graft/xml/attribute.rb +55 -0
  17. data/lib/graft/lib/graft/xml/model.rb +49 -0
  18. data/lib/graft/lib/graft/xml/type.rb +91 -0
  19. data/lib/graft/test/test_helper.rb +38 -0
  20. data/lib/graft/test/unit/core_ext/hash_test.rb +29 -0
  21. data/lib/graft/test/unit/json/attribute_test.rb +51 -0
  22. data/lib/graft/test/unit/json/model_test.rb +86 -0
  23. data/lib/graft/test/unit/xml/attribute_test.rb +161 -0
  24. data/lib/graft/test/unit/xml/model_test.rb +173 -0
  25. data/lib/graft/test/unit/xml/type_test.rb +65 -0
  26. data/lib/unfuzzle/.gitignore +4 -0
  27. data/lib/unfuzzle/README.rdoc +129 -0
  28. data/lib/unfuzzle/Rakefile +39 -0
  29. data/lib/unfuzzle/lib/unfuzzle.rb +87 -0
  30. data/lib/unfuzzle/lib/unfuzzle/comment.rb +37 -0
  31. data/lib/unfuzzle/lib/unfuzzle/component.rb +31 -0
  32. data/lib/unfuzzle/lib/unfuzzle/milestone.rb +54 -0
  33. data/lib/unfuzzle/lib/unfuzzle/person.rb +20 -0
  34. data/lib/unfuzzle/lib/unfuzzle/priority.rb +30 -0
  35. data/lib/unfuzzle/lib/unfuzzle/project.rb +62 -0
  36. data/lib/unfuzzle/lib/unfuzzle/request.rb +75 -0
  37. data/lib/unfuzzle/lib/unfuzzle/response.rb +25 -0
  38. data/lib/unfuzzle/lib/unfuzzle/severity.rb +31 -0
  39. data/lib/unfuzzle/lib/unfuzzle/ticket.rb +156 -0
  40. data/lib/unfuzzle/lib/unfuzzle/ticket_report.rb +29 -0
  41. data/lib/unfuzzle/lib/unfuzzle/time_entry.rb +75 -0
  42. data/lib/unfuzzle/lib/unfuzzle/version.rb +13 -0
  43. data/lib/unfuzzle/test/fixtures/component.xml +8 -0
  44. data/lib/unfuzzle/test/fixtures/components.xml +17 -0
  45. data/lib/unfuzzle/test/fixtures/milestone.xml +12 -0
  46. data/lib/unfuzzle/test/fixtures/milestones.xml +25 -0
  47. data/lib/unfuzzle/test/fixtures/project.xml +17 -0
  48. data/lib/unfuzzle/test/fixtures/projects.xml +35 -0
  49. data/lib/unfuzzle/test/fixtures/severities.xml +24 -0
  50. data/lib/unfuzzle/test/fixtures/severity.xml +8 -0
  51. data/lib/unfuzzle/test/fixtures/ticket.xml +25 -0
  52. data/lib/unfuzzle/test/fixtures/tickets.xml +51 -0
  53. data/lib/unfuzzle/test/test_helper.rb +60 -0
  54. data/lib/unfuzzle/test/unit/unfuzzle/component_test.rb +36 -0
  55. data/lib/unfuzzle/test/unit/unfuzzle/milestone_test.rb +100 -0
  56. data/lib/unfuzzle/test/unit/unfuzzle/priority_test.rb +25 -0
  57. data/lib/unfuzzle/test/unit/unfuzzle/project_test.rb +87 -0
  58. data/lib/unfuzzle/test/unit/unfuzzle/request_test.rb +104 -0
  59. data/lib/unfuzzle/test/unit/unfuzzle/response_test.rb +37 -0
  60. data/lib/unfuzzle/test/unit/unfuzzle/severity_test.rb +36 -0
  61. data/lib/unfuzzle/test/unit/unfuzzle/ticket_test.rb +181 -0
  62. data/lib/unfuzzle/test/unit/unfuzzle_test.rb +39 -0
  63. data/lib/unfuzzle/unfuzzle.gemspec +31 -0
  64. data/lib/version.rb +3 -0
  65. metadata +176 -0
@@ -0,0 +1,100 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ module Unfuzzle
4
+ class MilestoneTest < Test::Unit::TestCase
5
+
6
+ context "The Milestone class" do
7
+
8
+ should "be able to find all by project ID" do
9
+ project_id = 1
10
+
11
+ response = mock_request_cycle :for => "/projects/#{project_id}/milestones", :data => 'milestones'
12
+
13
+ Unfuzzle::Milestone.expects(:collection_from).with(response.body, 'milestones/milestone').returns(['milestone_1', 'milestone_2'])
14
+
15
+ Milestone.find_all_by_project_id(project_id).should == ['milestone_1', 'milestone_2']
16
+ end
17
+
18
+ should "be able to find one by project ID an milestone ID" do
19
+ project_id = 1
20
+ milestone_id = 2
21
+ response = mock_request_cycle :for => "/projects/#{project_id}/milestones/#{milestone_id}", :data => 'milestone'
22
+
23
+ Unfuzzle::Milestone.expects(:new).with(response.body).returns('milestone')
24
+
25
+ Milestone.find_by_project_id_and_milestone_id(1, 2).should == 'milestone'
26
+ end
27
+
28
+ end
29
+
30
+ context "An instance of the Milestone class" do
31
+
32
+ when_populating Milestone, :from => 'milestone' do
33
+
34
+ value_for :id, :is => 2
35
+ value_for :project_id, :is => 1
36
+ value_for :archived, :is => false
37
+ value_for :created_at, :is => Time.parse('2009-04-02T19:43:16Z')
38
+ value_for :name, :is => 'Milestone #1'
39
+ value_for :due_on, :is => Date.parse('2009-04-03')
40
+ value_for :updated_at, :is => Time.parse('2009-07-02T16:40:28Z')
41
+
42
+ end
43
+
44
+ context "with a new instance" do
45
+
46
+ setup { @milestone = Milestone.new }
47
+
48
+ should "know that it is archived" do
49
+ @milestone.stubs(:archived).with().returns(true)
50
+ @milestone.archived?.should be(true)
51
+ end
52
+
53
+ should "know that it isn't archived" do
54
+ @milestone.stubs(:archived).with().returns(false)
55
+ @milestone.archived?.should be(false)
56
+ end
57
+
58
+ should "have associated tickets" do
59
+ id = 1
60
+ project_id = 1
61
+
62
+ Ticket.expects(:find_all_by_project_id_and_milestone_id).with(project_id, id).returns('tickets')
63
+
64
+ @milestone.stubs(:id).with().returns(id)
65
+ @milestone.stubs(:project_id).with().returns(project_id)
66
+
67
+ @milestone.tickets.should == 'tickets'
68
+ end
69
+
70
+ should "know that it's in the past if the due date is in the past" do
71
+ due_date = Date.today
72
+ today = due_date.next
73
+
74
+ @milestone.stubs(:due_on).with().returns(due_date)
75
+ Date.expects(:today).with().returns(today)
76
+
77
+ @milestone.past?.should be(true)
78
+ end
79
+
80
+ should "know that it's not in the past if the date is today" do
81
+ due_date = Date.today
82
+ @milestone.stubs(:due_on).with().returns(due_date)
83
+
84
+ @milestone.past?.should be(false)
85
+ end
86
+
87
+ should "know that it's not in the past if the due date is in the future" do
88
+ due_date = Date.today.next
89
+ @milestone.stubs(:due_on).with().returns(due_date)
90
+
91
+ @milestone.past?.should be(false)
92
+ end
93
+
94
+
95
+ end
96
+
97
+ end
98
+
99
+ end
100
+ end
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ module Unfuzzle
4
+ class PriorityTest < Test::Unit::TestCase
5
+
6
+ def self.should_have_a_name_of(name, options)
7
+ should "have a name of '#{name}' when the priority is #{options[:when]}" do
8
+ p = Priority.new(options[:when])
9
+ p.name.should == name
10
+ end
11
+ end
12
+
13
+
14
+ context "An instance of the Priority class" do
15
+
16
+ should_have_a_name_of 'Highest', :when => 5
17
+ should_have_a_name_of 'High', :when => 4
18
+ should_have_a_name_of 'Normal', :when => 3
19
+ should_have_a_name_of 'Low', :when => 2
20
+ should_have_a_name_of 'Lowest', :when => 1
21
+
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,87 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ module Unfuzzle
4
+ class ProjectTest < Test::Unit::TestCase
5
+
6
+ context "The Project class" do
7
+
8
+ should "be able to return a list of all projects" do
9
+ response = mock_request_cycle :for => '/projects', :data => 'projects'
10
+
11
+ Unfuzzle::Project.expects(:collection_from).with(response.body, 'projects/project').returns(['project_1', 'project_2'])
12
+
13
+ Project.all.should == ['project_1', 'project_2']
14
+ end
15
+
16
+ should "be able to find a project by its slug" do
17
+ slug = 'blip'
18
+
19
+ response = mock_request_cycle :for => "/projects/by_short_name/#{slug}", :data => 'project'
20
+
21
+ Unfuzzle::Project.expects(:new).with(response.body).returns('project')
22
+
23
+ Project.find_by_slug(slug).should == 'project'
24
+ end
25
+
26
+ should "be able to find a project by its ID" do
27
+ id = 1
28
+
29
+ response = mock_request_cycle :for => "/projects/#{id}", :data => 'project'
30
+
31
+ Unfuzzle::Project.expects(:new).with(response.body).returns('project')
32
+
33
+ Project.find_by_id(id).should == 'project'
34
+ end
35
+
36
+
37
+ end
38
+
39
+ context "An instance of the Project class" do
40
+
41
+ when_populating Project, :from => 'project' do
42
+
43
+ value_for :id, :is => 1
44
+ value_for :archived, :is => false
45
+ value_for :slug, :is => 'blip'
46
+ value_for :name, :is => 'Blip Bleep Co.'
47
+ value_for :description, :is => 'This is the project for Blip Bleep Co.'
48
+ value_for :created_at, :is => Time.parse('2008-07-28T16:57:10Z')
49
+ value_for :updated_at, :is => Time.parse('2009-04-28T18:48:52Z')
50
+
51
+ end
52
+
53
+ context "with a new instance" do
54
+
55
+ setup { @project = Project.new }
56
+
57
+ should "know that it's archived" do
58
+ @project.stubs(:archived).with().returns(true)
59
+ @project.archived?.should be(true)
60
+ end
61
+
62
+ should "know that it's not archived" do
63
+ @project.stubs(:archived).with().returns(false)
64
+ @project.archived?.should be(false)
65
+ end
66
+
67
+ should "have a list of associated milestones" do
68
+ id = 1
69
+ Milestone.expects(:find_all_by_project_id).with(id).returns('milestones')
70
+
71
+ @project.stubs(:id).with().returns(id)
72
+ @project.milestones.should == 'milestones'
73
+ end
74
+
75
+ should "have a list of associated tickets" do
76
+ id = 1
77
+ Ticket.expects(:find_all_by_project_id).with(id).returns('tickets')
78
+
79
+ @project.stubs(:id).with().returns(id)
80
+ @project.tickets.should == 'tickets'
81
+ end
82
+
83
+ end
84
+ end
85
+
86
+ end
87
+ end
@@ -0,0 +1,104 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ module Unfuzzle
4
+ class RequestTest < Test::Unit::TestCase
5
+
6
+ context "The Request class" do
7
+
8
+ should "be able to perform a GET request" do
9
+ request = mock() {|r| r.expects(:get).with().returns('response') }
10
+ Unfuzzle::Request.expects(:new).with('/projects').returns(request)
11
+
12
+ Unfuzzle::Request.get('/projects').should == 'response'
13
+ end
14
+
15
+ should "be able to perform a PUT request" do
16
+ request = mock() {|r| r.expects(:put).with().returns('response') }
17
+ Unfuzzle::Request.expects(:new).with('/projects', '<payload>').returns(request)
18
+
19
+ Unfuzzle::Request.put('/projects', '<payload>').should == 'response'
20
+ end
21
+
22
+ end
23
+
24
+ context "An instance of the Request class" do
25
+
26
+ should "have an endpoint URI" do
27
+ Unfuzzle.stubs(:subdomain).with().returns('viget')
28
+
29
+ request = Unfuzzle::Request.new('/projects')
30
+ request.endpoint_uri.should == URI.parse('http://viget.unfuddle.com/api/v1/projects.xml')
31
+ end
32
+
33
+ should "have an endpoint URI with the appropriate format when specified" do
34
+ Unfuzzle.stubs(:subdomain).with().returns('viget')
35
+
36
+ request = Unfuzzle::Request.new('/projects', nil)
37
+ request.endpoint_uri.should == URI.parse('http://viget.unfuddle.com/api/v1/projects.xml')
38
+ end
39
+
40
+ should "have a client" do
41
+ client = stub()
42
+
43
+ request = Unfuzzle::Request.new('/projects')
44
+ request.stubs(:endpoint_uri).with().returns(URI.parse('http://example.com'))
45
+
46
+ Net::HTTP.expects(:new).with('example.com').returns(client)
47
+
48
+ request.client.should == client
49
+ end
50
+
51
+ should "be able to perform a GET request" do
52
+ Unfuzzle.stubs(:username).with().returns('username')
53
+ Unfuzzle.stubs(:password).with().returns('password')
54
+
55
+ request = Unfuzzle::Request.new('/projects')
56
+ request.stubs(:endpoint_uri).returns(URI.parse('http://example.com/projects'))
57
+
58
+ get_request = mock() do |g|
59
+ g.expects(:basic_auth).with('username', 'password')
60
+ end
61
+
62
+ client = mock() {|c| c.expects(:request).with(get_request).returns('response') }
63
+
64
+ response = stub()
65
+ Unfuzzle::Response.expects(:new).with('response').returns(response)
66
+
67
+ Net::HTTP::Get.expects(:new).with('/projects').returns(get_request)
68
+
69
+ request.stubs(:client).with().returns(client)
70
+
71
+ request.get.should == response
72
+ end
73
+
74
+ should "be able to perform a PUT request" do
75
+ Unfuzzle.stubs(:username).with().returns('username')
76
+ Unfuzzle.stubs(:password).with().returns('password')
77
+
78
+ request_body = '<payload>'
79
+
80
+ request = Unfuzzle::Request.new('/projects', request_body)
81
+
82
+ request.stubs(:endpoint_uri).returns(URI.parse('http://example.com/projects'))
83
+
84
+ put_request = mock() do |p|
85
+ p.expects(:basic_auth).with('username', 'password')
86
+ p.expects(:content_type=).with('application/xml')
87
+ end
88
+
89
+ client = mock() {|c| c.expects(:request).with(put_request, request_body).returns('response') }
90
+
91
+ response = stub()
92
+ Unfuzzle::Response.expects(:new).with('response').returns(response)
93
+
94
+ Net::HTTP::Put.expects(:new).with('/projects').returns(put_request)
95
+
96
+ request.stubs(:client).with().returns(client)
97
+
98
+ request.put.should == response
99
+ end
100
+
101
+ end
102
+
103
+ end
104
+ end
@@ -0,0 +1,37 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ module Unfuzzle
4
+ class ResponseTest < Test::Unit::TestCase
5
+
6
+ context "An instance of the Response class" do
7
+
8
+ should "delegate to the HTTP response to determine the body" do
9
+ http_response = mock() {|r| r.expects(:body).with().returns('check mah boday') }
10
+
11
+ response = Unfuzzle::Response.new(http_response)
12
+
13
+ response.body.should == 'check mah boday'
14
+ end
15
+
16
+ should "know that there are no errors" do
17
+ http_response = mock() do |r|
18
+ r.expects(:is_a?).with(Net::HTTPSuccess).returns(true)
19
+ end
20
+
21
+ response = Unfuzzle::Response.new(http_response)
22
+ response.error?.should be(false)
23
+ end
24
+
25
+ should "know if there are errors" do
26
+ http_response = mock() do |r|
27
+ r.expects(:is_a?).with(Net::HTTPSuccess).returns(false)
28
+ end
29
+
30
+ response = Unfuzzle::Response.new(http_response)
31
+ response.error?.should be(true)
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ module Unfuzzle
4
+ class SeverityTest < Test::Unit::TestCase
5
+
6
+ context "The Severity class" do
7
+
8
+ should "be able to return a severity for a project and severity id" do
9
+ project_id = 1
10
+ severity_id = 1
11
+
12
+ response = mock_request_cycle :for => "/projects/#{project_id}/severities/#{severity_id}", :data => 'severity'
13
+
14
+ Unfuzzle::Severity.expects(:new).with(response.body).returns('severity')
15
+
16
+ Unfuzzle::Severity.find_by_project_id_and_severity_id(project_id, severity_id).should == 'severity'
17
+ end
18
+
19
+ end
20
+
21
+ context "An instance of the Severity class" do
22
+
23
+ when_populating Severity, :from => 'severity' do
24
+
25
+ value_for :id, :is => 1
26
+ value_for :name, :is => 'Story'
27
+ value_for :project_id, :is => 2
28
+ value_for :created_at, :is => Time.parse('2009-04-02T19:44:49Z')
29
+ value_for :updated_at, :is => Time.parse('2009-04-02T19:44:49Z')
30
+
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,181 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ module Unfuzzle
4
+ class TicketTest < Test::Unit::TestCase
5
+
6
+ context "The Ticket class" do
7
+
8
+ should "be able to return a list of tickets for a project" do
9
+ project_id = 1
10
+
11
+ response = mock_request_cycle :for => "/projects/#{project_id}/tickets", :data => 'tickets'
12
+
13
+ Unfuzzle::Ticket.expects(:collection_from).with(response.body, 'tickets/ticket').returns(['ticket_1', 'ticket_2'])
14
+
15
+ Ticket.find_all_by_project_id(project_id).should == ['ticket_1', 'ticket_2']
16
+ end
17
+
18
+ should "be able to return a list of tickets for a milestone" do
19
+ milestone_id = 1
20
+ project_id = 1
21
+
22
+ response = mock_request_cycle :for => "/projects/#{project_id}/milestones/#{milestone_id}/tickets", :data => 'tickets'
23
+
24
+ Unfuzzle::Ticket.expects(:collection_from).with(response.body, 'tickets/ticket').returns(['ticket_1', 'ticket_2'])
25
+
26
+ Ticket.find_all_by_project_id_and_milestone_id(project_id, milestone_id).should == ['ticket_1', 'ticket_2']
27
+ end
28
+
29
+ end
30
+
31
+ context "An instance of the Ticket class" do
32
+
33
+ when_populating Ticket, :from => 'ticket' do
34
+
35
+ value_for :id, :is => 1
36
+ value_for :project_id, :is => 1
37
+ value_for :milestone_id, :is => 1
38
+ value_for :severity_id, :is => 123
39
+ value_for :priority_id, :is => 3
40
+ value_for :component_id, :is => 1
41
+ value_for :created_at, :is => Time.parse('2008-11-25T14:00:19Z')
42
+ value_for :updated_at, :is => Time.parse('2008-12-31T15:51:41Z')
43
+ value_for :number, :is => '1'
44
+ value_for :title, :is => 'Ticket #1'
45
+ value_for :description, :is => 'Do something important'
46
+ value_for :due_on, :is => nil
47
+ value_for :status, :is => 'closed'
48
+
49
+ end
50
+
51
+ should_set_a_value_for :title
52
+ should_set_a_value_for :description
53
+
54
+ context "with a new instance" do
55
+ setup { @ticket = Ticket.new }
56
+
57
+ should "have a due date" do
58
+ xml = '<ticket><due-on>2009-08-01</due-on></ticket>'
59
+
60
+ ticket = Ticket.new(xml)
61
+ ticket.due_on.should == Date.parse('2009-08-01')
62
+ end
63
+
64
+ should "have an associated milestone" do
65
+ Milestone.expects(:find_by_project_id_and_milestone_id).with(1, 2).returns('milestone')
66
+
67
+ @ticket.stubs(:project_id).with().returns(1)
68
+ @ticket.stubs(:milestone_id).with().returns(2)
69
+
70
+ @ticket.milestone.should == 'milestone'
71
+ end
72
+
73
+ should "have an associated severity" do
74
+ project_id = 1
75
+ severity_id = 1
76
+
77
+ Severity.expects(:find_by_project_id_and_severity_id).with(project_id, severity_id).returns('severity')
78
+
79
+ @ticket.stubs(:project_id).with().returns(project_id)
80
+ @ticket.stubs(:severity_id).with().returns(severity_id)
81
+
82
+ @ticket.severity.should == 'severity'
83
+ end
84
+
85
+ should "have no associated severity if it is not set" do
86
+ @ticket.stubs(:severity_id).with().returns(nil)
87
+ @ticket.severity.should be(nil)
88
+ end
89
+
90
+ should "have a severity_name" do
91
+ @ticket.stubs(:severity).with().returns(stub(:name => 'Story'))
92
+ @ticket.severity_name.should == 'Story'
93
+ end
94
+
95
+ should "have no severity_name if there is no severity" do
96
+ @ticket.stubs(:severity).with().returns(nil)
97
+ @ticket.severity_name.should be(nil)
98
+ end
99
+
100
+ should "have an associated priority" do
101
+ Priority.expects(:new).with(1).returns('priority')
102
+
103
+ @ticket.stubs(:priority_id).with().returns(1)
104
+ @ticket.priority.should == 'priority'
105
+ end
106
+
107
+ should "have a priority_name" do
108
+ @ticket.stubs(:priority).with().returns(stub(:name => 'High'))
109
+ @ticket.priority_name.should == 'High'
110
+ end
111
+
112
+ should "have an associated component" do
113
+ project_id = 1
114
+ component_id = 1
115
+
116
+ Component.expects(:find_by_project_id_and_component_id).with(project_id, component_id).returns('component')
117
+
118
+ @ticket.stubs(:project_id).with().returns(project_id)
119
+ @ticket.stubs(:component_id).with().returns(component_id)
120
+
121
+ @ticket.component.should == 'component'
122
+ end
123
+
124
+ should "have no associated component if it is not set" do
125
+ @ticket.stubs(:component_id).with().returns(nil)
126
+ @ticket.component.should be(nil)
127
+ end
128
+
129
+ should "have a component_name" do
130
+ @ticket.stubs(:component).with().returns(stub(:name => 'Admin'))
131
+ @ticket.component_name.should == 'Admin'
132
+ end
133
+
134
+ should "have no component_name if there is no component" do
135
+ @ticket.stubs(:component).with().returns(nil)
136
+ @ticket.component_name.should be(nil)
137
+ end
138
+
139
+ should "be able to generate a hash representation of itself for updating" do
140
+ @ticket.id = 1
141
+ @ticket.project_id = 2
142
+ @ticket.milestone_id = 3
143
+ @ticket.number = '12'
144
+ @ticket.title = 'summary'
145
+ @ticket.description = 'description'
146
+ @ticket.status = 'closed'
147
+
148
+
149
+ expected = {
150
+ 'id' => 1,
151
+ 'project_id' => 2,
152
+ 'milestone_id' => 3,
153
+ 'number' => '12',
154
+ 'summary' => 'summary',
155
+ 'description' => 'description',
156
+ 'status' => 'closed'
157
+ }
158
+
159
+ @ticket.to_hash.should == expected
160
+ end
161
+
162
+ should "be able to perform an update" do
163
+ @ticket.stubs(:project_id).with().returns(1)
164
+ @ticket.stubs(:id).with().returns(2)
165
+
166
+ resource_path = '/projects/1/tickets/2'
167
+ ticket_xml = '<ticket />'
168
+
169
+ @ticket.stubs(:to_xml).with('ticket').returns(ticket_xml)
170
+
171
+ Unfuzzle::Request.expects(:put).with(resource_path, ticket_xml).returns('response')
172
+
173
+ @ticket.update.should == 'response'
174
+ end
175
+
176
+ end
177
+
178
+ end
179
+
180
+ end
181
+ end