roust 1.8.1 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4b39b8c377e3ff0189444fc873909125f5c8a6c
4
- data.tar.gz: 397ca6c7c0d04ce9ae323e03c7e98f4f4551c938
3
+ metadata.gz: 66c9350b75b1aac09b2b1d5c17401654d9b336bb
4
+ data.tar.gz: 2255b4b1690b40658e610c0b52ced4cd8de75e97
5
5
  SHA512:
6
- metadata.gz: 25d96d2bbb5c5545772e05fcc8c6541e44b010c3a06a9ebaa9e0802b7ddeaa66e285d1dbd1be0448fbfc4ff6bcc1a8826cd8df3c9dc8d4795c5a94146b4283c4
7
- data.tar.gz: 21ee9e8dffa21cf36b97866d2a51e2f35189a8a0c127ca167fa0b1090dd26293cde9fdd2417e046707567234e11894cc80b7d95a3eed6744e65ee397d596df67
6
+ metadata.gz: 01fd887c2725ef17cc14873c5677c3d7991e3c4fdeb7f3252ad1e59c72485a3b335b3e1a973f8f75c76e17a4d7bcc74de62697aa7ab4539a698ad44babe5b8bf
7
+ data.tar.gz: 94a0c365649b4ccbe28b417877223ada824fbae37d3e4a84c7fea8f0c2829b0e32ebfa01b6ac2bc40048315b4257f96c5fbf4858bc0eb069348db144360b255c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roust (1.8.1)
4
+ roust (1.8.2)
5
5
  activesupport (>= 4.0.10)
6
6
  httparty (>= 0.13.1)
7
7
  mail (>= 2.5.4)
@@ -9,11 +9,11 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (4.1.8)
13
- i18n (~> 0.6, >= 0.6.9)
12
+ activesupport (4.2.0)
13
+ i18n (~> 0.7)
14
14
  json (~> 1.7, >= 1.7.7)
15
15
  minitest (~> 5.1)
16
- thread_safe (~> 0.1)
16
+ thread_safe (~> 0.3, >= 0.3.4)
17
17
  tzinfo (~> 1.1)
18
18
  addressable (2.3.6)
19
19
  ast (2.0.0)
@@ -27,13 +27,13 @@ GEM
27
27
  httparty (0.13.3)
28
28
  json (~> 1.8)
29
29
  multi_xml (>= 0.5.2)
30
- i18n (0.6.11)
31
- json (1.8.1)
30
+ i18n (0.7.0)
31
+ json (1.8.2)
32
32
  mail (2.6.3)
33
33
  mime-types (>= 1.16, < 3)
34
34
  method_source (0.8.2)
35
35
  mime-types (2.4.3)
36
- minitest (5.4.3)
36
+ minitest (5.5.1)
37
37
  multi_xml (0.5.5)
38
38
  parser (2.2.0.pre.8)
39
39
  ast (>= 1.1, < 3.0)
data/README.md CHANGED
@@ -12,6 +12,7 @@ Features
12
12
  - Fetching ticket metadata (id, subject, queue, etc)
13
13
  - Fetching transactions on individual tickets (in long and short form)
14
14
  - Fetching user details
15
+ - Adding comments or correspondence to tickets
15
16
 
16
17
  Installing
17
18
  ----------
@@ -77,6 +78,23 @@ attrs = {
77
78
 
78
79
  rt.ticket_update(ticket_id, attrs) # => { 'Subject' => 'a test ticket', 'Queue' => 'sales', … }
79
80
 
81
+ # Add comments to a ticket
82
+
83
+ attrs = {
84
+ 'Action' => 'comment'
85
+ 'Text' => 'this is a test comment'
86
+ }
87
+
88
+ rt.ticket_comment(ticket_id, attrs) # => { 'Subject' => 'a test ticket', 'Queue' => 'sales', … }
89
+
90
+ # Add correspondence to a ticket
91
+
92
+ attrs = {
93
+ 'Action' => 'correspond'
94
+ 'Text' => 'this is a test piece of correspondence, which will email out to requestors'
95
+ }
96
+
97
+ rt.ticket_comment(ticket_id, attrs) # => { 'Subject' => 'a test ticket', 'Queue' => 'sales', … }
80
98
 
81
99
  # Fetch user details
82
100
  rt.user("dan@us.example") # => {"id"=>"user/160000", "name"=>"dan", "password"=>"********", "emailaddress"=>"dan@us.example", "realname"=>"Dan Smith", "nickname"=>"dan", … }
data/lib/roust/ticket.rb CHANGED
@@ -82,6 +82,35 @@ class Roust
82
82
  end
83
83
  end
84
84
 
85
+ def ticket_comment(id, attrs)
86
+ attrs['Text'].gsub!(/\n/, "\n ") if attrs['Text'] # insert a space on continuation lines.
87
+ content = compose_content('ticket', id, attrs)
88
+
89
+ unless content.match(/Action: (comment|correspond)/i)
90
+ raise "'Action' must be one of 'Comment' or 'Correspond'"
91
+ end
92
+
93
+ response = self.class.post(
94
+ "/ticket/#{id}/comment",
95
+ :body => {
96
+ :content => content
97
+ },
98
+ )
99
+
100
+ body, _ = explode_response(response)
101
+
102
+ case body
103
+ when /^# Message recorded/
104
+ ticket_show(id)
105
+ when /^# You are not allowed to modify ticket \d+/
106
+ raise Unauthorized, body
107
+ when /^# Syntax error/
108
+ raise SyntaxError, body
109
+ else
110
+ raise UnhandledResponse, body
111
+ end
112
+ end
113
+
85
114
  def ticket_search(attrs)
86
115
  params = {
87
116
  :format => 's',
data/lib/roust/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Roust
2
- VERSION = '1.8.1'
2
+ VERSION = '1.8.2'
3
3
  end
@@ -0,0 +1,3 @@
1
+ RT/3.4.6 200 Ok
2
+
3
+ # Message recorded.
@@ -60,6 +60,16 @@ describe Roust do
60
60
  :body => mocks_path.join('ticket-100-update.txt').read,
61
61
  :headers => {})
62
62
 
63
+ stub_request(:post, "http://rt.example.org/REST/1.0/ticket/100/comment")
64
+ .with { |request|
65
+ query = WebMock::Util::QueryMapper.query_to_values(request.body)
66
+ require 'pry'
67
+
68
+ true
69
+ }.to_return(:status => 200,
70
+ :body => mocks_path.join('ticket-100-comment.txt').read,
71
+ :headers => {})
72
+
63
73
  stub_request(:get, 'http://rt.example.org/REST/1.0/ticket/100/show')
64
74
  .to_return(:status => 200,
65
75
  :body => mocks_path.join('ticket-100-show.txt').read,
@@ -206,6 +216,36 @@ describe Roust do
206
216
  }
207
217
  end
208
218
 
219
+ it 'can comment on a ticket' do
220
+ attrs = {
221
+ 'action' => 'comment',
222
+ 'text' => 'this is a test comment'
223
+ }
224
+ ticket = @rt.ticket_comment(100, attrs)
225
+
226
+ expect(WebMock).to have_requested(:post, "rt.example.org/REST/1.0/ticket/100/comment")
227
+ .with { |request|
228
+ query = WebMock::Util::QueryMapper.query_to_values(request.body)
229
+ query['content'] =~ /Action: comment/ &&
230
+ query['content'] =~ /Text: this is a test comment/
231
+ }
232
+ end
233
+
234
+ it 'can correspond on a ticket' do
235
+ attrs = {
236
+ 'action' => 'correspond',
237
+ 'text' => 'this is a test piece of correspondence'
238
+ }
239
+ ticket = @rt.ticket_comment(100, attrs)
240
+
241
+ expect(WebMock).to have_requested(:post, "rt.example.org/REST/1.0/ticket/100/comment")
242
+ .with { |request|
243
+ query = WebMock::Util::QueryMapper.query_to_values(request.body)
244
+ query['content'] =~ /Action: correspond/ &&
245
+ query['content'] =~ /Text: this is a test piece of correspondence/
246
+ }
247
+ end
248
+
209
249
  it 'adds links' do
210
250
  attrs = {
211
251
  'RefersTo' => [
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roust
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lindsay Holmwood
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-04 00:00:00.000000000 Z
11
+ date: 2015-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail
@@ -84,6 +84,7 @@ files:
84
84
  - spec/mocks/ticket-1-history-short.txt
85
85
  - spec/mocks/ticket-1-show-unauthenticated.txt
86
86
  - spec/mocks/ticket-1-show.txt
87
+ - spec/mocks/ticket-100-comment.txt
87
88
  - spec/mocks/ticket-100-show.txt
88
89
  - spec/mocks/ticket-100-update.txt
89
90
  - spec/mocks/ticket-150-links-update.txt
@@ -131,4 +132,34 @@ rubygems_version: 2.2.2
131
132
  signing_key:
132
133
  specification_version: 4
133
134
  summary: Ruby client for RT's REST API
134
- test_files: []
135
+ test_files:
136
+ - spec/mocks/queue-13.txt
137
+ - spec/mocks/queue-nil.txt
138
+ - spec/mocks/ticket-1-history-long.txt
139
+ - spec/mocks/ticket-1-history-short.txt
140
+ - spec/mocks/ticket-1-show-unauthenticated.txt
141
+ - spec/mocks/ticket-1-show.txt
142
+ - spec/mocks/ticket-100-comment.txt
143
+ - spec/mocks/ticket-100-show.txt
144
+ - spec/mocks/ticket-100-update.txt
145
+ - spec/mocks/ticket-150-links-update.txt
146
+ - spec/mocks/ticket-150-links.txt
147
+ - spec/mocks/ticket-151-links-update.txt
148
+ - spec/mocks/ticket-151-links.txt
149
+ - spec/mocks/ticket-3-links.txt
150
+ - spec/mocks/ticket-99-show.txt
151
+ - spec/mocks/ticket-create.txt
152
+ - spec/mocks/ticket-search-1-or-2-long.txt
153
+ - spec/mocks/ticket-search-1-or-2.txt
154
+ - spec/mocks/ticket-search-that-does-not-exist.txt
155
+ - spec/mocks/user-dan@us.example-after-edit.txt
156
+ - spec/mocks/user-dan@us.example-edit.txt
157
+ - spec/mocks/user-dan@us.example.txt
158
+ - spec/mocks/user-erin@us.example-create.txt
159
+ - spec/mocks/user-erin@us.example.txt
160
+ - spec/mocks/user-nil.txt
161
+ - spec/roust/authentication_spec.rb
162
+ - spec/roust/queue_spec.rb
163
+ - spec/roust/ticket_spec.rb
164
+ - spec/roust/user_spec.rb
165
+ - spec/spec_helper.rb