roust 1.7.1 → 1.7.2
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +12 -12
- data/lib/roust/ticket.rb +8 -4
- data/lib/roust/version.rb +1 -1
- data/lib/roust.rb +14 -0
- data/spec/mocks/ticket-100-show.txt +19 -0
- data/spec/mocks/ticket-100-update.txt +4 -0
- data/spec/roust/ticket_spec.rb +32 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0fd7ec9d960d69cac7e4728a7fed55ee4cdd0bb
|
4
|
+
data.tar.gz: 170095fffdbaf6911552314acda4cd04f71698fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f986a4c50c33eb97157162d367e5ecfc9273c572146d3fa429dca28a4346bf88fbe14c03ff24f679534c9af560cf67ff80246fcecf84054c5d0557f5ea62154a
|
7
|
+
data.tar.gz: 419951703eaad4a2813cad671f50710f87da264981b4de72e92b0cbd85b5d05e4f69a5a408cbec10f138e3f4cfff8eda231336eaf872df45f0d4962d635be8c3
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
roust (1.7.
|
4
|
+
roust (1.7.2)
|
5
5
|
activesupport (>= 4.1.0)
|
6
6
|
httparty (>= 0.13.1)
|
7
7
|
mail (>= 2.5.4)
|
@@ -43,18 +43,18 @@ GEM
|
|
43
43
|
slop (~> 3.4)
|
44
44
|
rainbow (2.0.0)
|
45
45
|
rake (10.1.0)
|
46
|
-
rspec (3.
|
47
|
-
rspec-core (~> 3.
|
48
|
-
rspec-expectations (~> 3.
|
49
|
-
rspec-mocks (~> 3.
|
50
|
-
rspec-core (3.
|
51
|
-
rspec-support (~> 3.
|
52
|
-
rspec-expectations (3.0
|
46
|
+
rspec (3.1.0)
|
47
|
+
rspec-core (~> 3.1.0)
|
48
|
+
rspec-expectations (~> 3.1.0)
|
49
|
+
rspec-mocks (~> 3.1.0)
|
50
|
+
rspec-core (3.1.1)
|
51
|
+
rspec-support (~> 3.1.0)
|
52
|
+
rspec-expectations (3.1.0)
|
53
53
|
diff-lcs (>= 1.2.0, < 2.0)
|
54
|
-
rspec-support (~> 3.
|
55
|
-
rspec-mocks (3.0
|
56
|
-
rspec-support (~> 3.
|
57
|
-
rspec-support (3.0
|
54
|
+
rspec-support (~> 3.1.0)
|
55
|
+
rspec-mocks (3.1.0)
|
56
|
+
rspec-support (~> 3.1.0)
|
57
|
+
rspec-support (3.1.0)
|
58
58
|
rubocop (0.24.1)
|
59
59
|
json (>= 1.7.7, < 2)
|
60
60
|
parser (>= 2.2.0.pre.3, < 3.0)
|
data/lib/roust/ticket.rb
CHANGED
@@ -25,7 +25,8 @@ class Roust
|
|
25
25
|
#
|
26
26
|
# Delete it from the ticket we are creating, and we'll update the ticket
|
27
27
|
# after we've created.
|
28
|
-
admincc = attrs.
|
28
|
+
key, admincc = attrs.detect {|k,v| k =~ /admincc/i }
|
29
|
+
attrs.delete(key)
|
29
30
|
|
30
31
|
content = compose_content('ticket', attrs['id'], attrs)
|
31
32
|
|
@@ -43,10 +44,10 @@ class Roust
|
|
43
44
|
id = $1
|
44
45
|
# Add the AdminCc after the ticket is created, because we can't set it
|
45
46
|
# on ticket creation.
|
46
|
-
|
47
|
+
ticket_update(id, 'AdminCc' => admincc) if admincc
|
47
48
|
|
48
49
|
# Return the whole ticket, not just the id.
|
49
|
-
|
50
|
+
ticket_show(id)
|
50
51
|
when /^# Could not create ticket/
|
51
52
|
raise BadRequest, body
|
52
53
|
when /^# Syntax error/
|
@@ -71,7 +72,7 @@ class Roust
|
|
71
72
|
case body
|
72
73
|
when /^# Ticket (\d+) updated/
|
73
74
|
id = $1
|
74
|
-
|
75
|
+
ticket_show(id)
|
75
76
|
when /^# You are not allowed to modify ticket \d+/
|
76
77
|
raise Unauthorized, body
|
77
78
|
when /^# Syntax error/
|
@@ -175,6 +176,9 @@ class Roust
|
|
175
176
|
end
|
176
177
|
end
|
177
178
|
|
179
|
+
# parse_ticket_attributes decodes a response body of ticket metadata.
|
180
|
+
#
|
181
|
+
# Used by ticket_show and verbose ticket_search.
|
178
182
|
def parse_ticket_attributes(body)
|
179
183
|
# Replace CF spaces with underscores
|
180
184
|
while body.match(/CF\.\{[\w_ ]*[ ]+[\w ]*\}/)
|
data/lib/roust/version.rb
CHANGED
data/lib/roust.rb
CHANGED
@@ -87,6 +87,7 @@ class Roust
|
|
87
87
|
k
|
88
88
|
end
|
89
89
|
|
90
|
+
k = sanitize_content_key(k)
|
90
91
|
v = v.join(', ') if v.respond_to?(:join)
|
91
92
|
|
92
93
|
"#{k}: #{v}"
|
@@ -95,6 +96,19 @@ class Roust
|
|
95
96
|
content.join("\n")
|
96
97
|
end
|
97
98
|
|
99
|
+
def sanitize_content_key(k)
|
100
|
+
case k.downcase
|
101
|
+
when 'requestors'
|
102
|
+
'Requestors'
|
103
|
+
when 'cc'
|
104
|
+
'Cc'
|
105
|
+
when 'admincc'
|
106
|
+
'AdminCc'
|
107
|
+
else
|
108
|
+
k
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
98
112
|
# explode_response separates RT's response content from the response status.
|
99
113
|
#
|
100
114
|
# All HTTP-level response codes from RT are a lie. The only way to check if
|
@@ -0,0 +1,19 @@
|
|
1
|
+
RT/3.4.6 200 Ok
|
2
|
+
|
3
|
+
id: ticket/100
|
4
|
+
Queue: sales
|
5
|
+
Subject: test ticket
|
6
|
+
Status: new
|
7
|
+
Priority: 101
|
8
|
+
InitialPriority: 101
|
9
|
+
FinalPriority: 100
|
10
|
+
Created: Tue Dec 11 07:59:31 2012
|
11
|
+
Starts: Not set
|
12
|
+
Started: Not set
|
13
|
+
Due: Wed Dec 12 20:58:48 2012
|
14
|
+
Resolved: Wed Jan 16 16:33:15 2013
|
15
|
+
Told: Mon Jan 07 15:27:09 2013
|
16
|
+
LastUpdated: Wed Nov 06 09:33:43 2013
|
17
|
+
TimeEstimated: 0
|
18
|
+
TimeWorked: 12 hours
|
19
|
+
TimeLeft: 0
|
data/spec/roust/ticket_spec.rb
CHANGED
@@ -50,6 +50,21 @@ describe Roust do
|
|
50
50
|
:body => mocks_path.join('ticket-99-show.txt').read,
|
51
51
|
:headers => {})
|
52
52
|
|
53
|
+
stub_request(:post, "http://rt.example.org/REST/1.0/ticket/100/edit")
|
54
|
+
.with { |request|
|
55
|
+
query = WebMock::Util::QueryMapper.query_to_values(request.body)
|
56
|
+
require 'pry'
|
57
|
+
|
58
|
+
true
|
59
|
+
}.to_return(:status => 200,
|
60
|
+
:body => mocks_path.join('ticket-100-update.txt').read,
|
61
|
+
:headers => {})
|
62
|
+
|
63
|
+
stub_request(:get, 'http://rt.example.org/REST/1.0/ticket/100/show')
|
64
|
+
.to_return(:status => 200,
|
65
|
+
:body => mocks_path.join('ticket-100-show.txt').read,
|
66
|
+
:headers => {})
|
67
|
+
|
53
68
|
@rt = Roust.new(credentials)
|
54
69
|
expect(@rt.authenticated?).to eq(true)
|
55
70
|
end
|
@@ -153,5 +168,22 @@ describe Roust do
|
|
153
168
|
expect(ticket[k]).to eq(v)
|
154
169
|
end
|
155
170
|
end
|
171
|
+
|
172
|
+
it 'transforms attribute case when creating or updating tickets' do
|
173
|
+
attrs = {
|
174
|
+
'requestors' => 'alice@them.example,bob@them.example',
|
175
|
+
'cc' => 'charlie@them.example',
|
176
|
+
'admincc' => 'daisy@us.example,eleanor@us.example',
|
177
|
+
}
|
178
|
+
ticket = @rt.ticket_update(100, attrs)
|
179
|
+
|
180
|
+
expect(WebMock).to have_requested(:post, "rt.example.org/REST/1.0/ticket/100/edit")
|
181
|
+
.with { |request|
|
182
|
+
query = WebMock::Util::QueryMapper.query_to_values(request.body)
|
183
|
+
query['content'] =~ /Requestors:/ &&
|
184
|
+
query['content'] =~ /Cc:/ &&
|
185
|
+
query['content'] =~ /AdminCc:/
|
186
|
+
}
|
187
|
+
end
|
156
188
|
end
|
157
189
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roust
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lindsay Holmwood
|
@@ -84,6 +84,8 @@ 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-show.txt
|
88
|
+
- spec/mocks/ticket-100-update.txt
|
87
89
|
- spec/mocks/ticket-3-links.txt
|
88
90
|
- spec/mocks/ticket-99-show.txt
|
89
91
|
- spec/mocks/ticket-create.txt
|
@@ -132,6 +134,8 @@ test_files:
|
|
132
134
|
- spec/mocks/ticket-1-history-short.txt
|
133
135
|
- spec/mocks/ticket-1-show-unauthenticated.txt
|
134
136
|
- spec/mocks/ticket-1-show.txt
|
137
|
+
- spec/mocks/ticket-100-show.txt
|
138
|
+
- spec/mocks/ticket-100-update.txt
|
135
139
|
- spec/mocks/ticket-3-links.txt
|
136
140
|
- spec/mocks/ticket-99-show.txt
|
137
141
|
- spec/mocks/ticket-create.txt
|