roust 1.3.0 → 1.4.0
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/.rspec +2 -0
- data/.rubocop.yml +3 -0
- data/.rubocop_roust.yml +11 -0
- data/.rubocop_todo.yml +15 -0
- data/.travis.yml +6 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +29 -11
- data/README.md +1 -0
- data/Rakefile +5 -6
- data/lib/roust/exceptions.rb +5 -0
- data/lib/roust/queue.rb +21 -0
- data/lib/roust/ticket.rb +245 -0
- data/lib/roust/user.rb +48 -0
- data/lib/roust/version.rb +1 -1
- data/lib/roust.rb +23 -329
- data/roust.gemspec +13 -13
- data/spec/mocks/ticket-1-show-unauthenticated.txt +1 -0
- data/spec/roust/authentication_spec.rb +33 -0
- data/spec/roust/queue_spec.rb +40 -0
- data/spec/roust/ticket_spec.rb +80 -0
- data/spec/roust/user_spec.rb +58 -0
- data/spec/spec_helper.rb +28 -9
- metadata +21 -5
- data/examples/example.rb +0 -15
- data/spec/roust_spec.rb +0 -202
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.
|
4
|
+
version: 1.4.0
|
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-
|
11
|
+
date: 2014-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -61,27 +61,39 @@ extensions: []
|
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
63
|
- .gitignore
|
64
|
+
- .rspec
|
65
|
+
- .rubocop.yml
|
66
|
+
- .rubocop_roust.yml
|
67
|
+
- .rubocop_todo.yml
|
64
68
|
- .ruby-version
|
69
|
+
- .travis.yml
|
65
70
|
- Gemfile
|
66
71
|
- Gemfile.lock
|
67
72
|
- LICENSE
|
68
73
|
- README.md
|
69
74
|
- Rakefile
|
70
|
-
- examples/example.rb
|
71
75
|
- lib/roust.rb
|
76
|
+
- lib/roust/exceptions.rb
|
77
|
+
- lib/roust/queue.rb
|
78
|
+
- lib/roust/ticket.rb
|
79
|
+
- lib/roust/user.rb
|
72
80
|
- lib/roust/version.rb
|
73
81
|
- roust.gemspec
|
74
82
|
- spec/mocks/queue-13.txt
|
75
83
|
- spec/mocks/queue-nil.txt
|
76
84
|
- spec/mocks/ticket-1-history-long.txt
|
77
85
|
- spec/mocks/ticket-1-history-short.txt
|
86
|
+
- spec/mocks/ticket-1-show-unauthenticated.txt
|
78
87
|
- spec/mocks/ticket-1-show.txt
|
79
88
|
- spec/mocks/ticket-search-1-or-2.txt
|
80
89
|
- spec/mocks/user-dan@us.example-after-edit.txt
|
81
90
|
- spec/mocks/user-dan@us.example-edit.txt
|
82
91
|
- spec/mocks/user-dan@us.example.txt
|
83
92
|
- spec/mocks/user-nil.txt
|
84
|
-
- spec/
|
93
|
+
- spec/roust/authentication_spec.rb
|
94
|
+
- spec/roust/queue_spec.rb
|
95
|
+
- spec/roust/ticket_spec.rb
|
96
|
+
- spec/roust/user_spec.rb
|
85
97
|
- spec/spec_helper.rb
|
86
98
|
homepage: http://github.com/bulletproofnetworks/roust
|
87
99
|
licenses:
|
@@ -112,11 +124,15 @@ test_files:
|
|
112
124
|
- spec/mocks/queue-nil.txt
|
113
125
|
- spec/mocks/ticket-1-history-long.txt
|
114
126
|
- spec/mocks/ticket-1-history-short.txt
|
127
|
+
- spec/mocks/ticket-1-show-unauthenticated.txt
|
115
128
|
- spec/mocks/ticket-1-show.txt
|
116
129
|
- spec/mocks/ticket-search-1-or-2.txt
|
117
130
|
- spec/mocks/user-dan@us.example-after-edit.txt
|
118
131
|
- spec/mocks/user-dan@us.example-edit.txt
|
119
132
|
- spec/mocks/user-dan@us.example.txt
|
120
133
|
- spec/mocks/user-nil.txt
|
121
|
-
- spec/
|
134
|
+
- spec/roust/authentication_spec.rb
|
135
|
+
- spec/roust/queue_spec.rb
|
136
|
+
- spec/roust/ticket_spec.rb
|
137
|
+
- spec/roust/user_spec.rb
|
122
138
|
- spec/spec_helper.rb
|
data/examples/example.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'rt/client' # requires ruby 1.8
|
5
|
-
require 'pp'
|
6
|
-
|
7
|
-
|
8
|
-
ticket_id = '1318622'
|
9
|
-
parent_id = '1258480'
|
10
|
-
|
11
|
-
rt = RT_Client.new
|
12
|
-
|
13
|
-
rt.add_link(:id => ticket_id, :MemberOf => parent_id)
|
14
|
-
links = rt.links(:id => ticket_id)
|
15
|
-
pp links
|
data/spec/roust_spec.rb
DELETED
@@ -1,202 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'roust'
|
3
|
-
|
4
|
-
describe "Roust" do
|
5
|
-
before do
|
6
|
-
@credentials = {
|
7
|
-
:server => 'http://rt.example.org',
|
8
|
-
:username => 'admin',
|
9
|
-
:password => 'password'
|
10
|
-
}
|
11
|
-
mocks_path = Pathname.new(__FILE__).parent.join('mocks')
|
12
|
-
|
13
|
-
stub_request(:post, "http://rt.example.org/index.html").
|
14
|
-
with(:body => {
|
15
|
-
"user"=>"admin",
|
16
|
-
"pass"=>"password",
|
17
|
-
}).
|
18
|
-
to_return(:status => 200, :body => "", :headers => {})
|
19
|
-
|
20
|
-
stub_request(:get, "http://rt.example.org/REST/1.0/ticket/1/show").
|
21
|
-
to_return(:status => 200,
|
22
|
-
:body => mocks_path.join('ticket-1-show.txt').read,
|
23
|
-
:headers => {})
|
24
|
-
|
25
|
-
stub_request(:get, "http://rt.example.org/REST/1.0/search/ticket?format=s&orderby=%2Bid&query%5Bquery%5D=id%20=%201%20or%20id%20=%202").
|
26
|
-
to_return(:status => 200,
|
27
|
-
:body => mocks_path.join('ticket-search-1-or-2.txt').read,
|
28
|
-
:headers => {})
|
29
|
-
|
30
|
-
stub_request(:get, "http://rt.example.org/REST/1.0/ticket/1/history?format=s").
|
31
|
-
to_return(:status => 200,
|
32
|
-
:body => mocks_path.join('ticket-1-history-short.txt').read,
|
33
|
-
:headers => {})
|
34
|
-
|
35
|
-
stub_request(:get, "http://rt.example.org/REST/1.0/ticket/1/history?format=l").
|
36
|
-
to_return(:status => 200,
|
37
|
-
:body => mocks_path.join('ticket-1-history-long.txt').read,
|
38
|
-
:headers => {})
|
39
|
-
|
40
|
-
stub_request(:get, "http://rt.example.org/REST/1.0/user/dan@us.example").
|
41
|
-
to_return(:status => 200,
|
42
|
-
:body => mocks_path.join('user-dan@us.example.txt').read,
|
43
|
-
:headers => {})
|
44
|
-
|
45
|
-
stub_request(:get, "http://rt.example.org/REST/1.0/user/nil").
|
46
|
-
to_return(:status => 200,
|
47
|
-
:body => mocks_path.join('user-nil.txt').read,
|
48
|
-
:headers => {})
|
49
|
-
|
50
|
-
stub_request(:post, "http://rt.example.org/REST/1.0/user/dan@us.example/edit").
|
51
|
-
with(:body => "content=id%3A%20user%2Fdan%40us.example%0ARealName%3A%20Daniel%20Smith").
|
52
|
-
to_return(:status => 200,
|
53
|
-
:body => mocks_path.join('user-dan@us.example-edit.txt').read,
|
54
|
-
:headers => {})
|
55
|
-
|
56
|
-
stub_request(:get, "http://rt.example.org/REST/1.0/queue/13").
|
57
|
-
to_return(:status => 200,
|
58
|
-
:body => mocks_path.join('queue-13.txt').read,
|
59
|
-
:headers => {})
|
60
|
-
|
61
|
-
stub_request(:get, "http://rt.example.org/REST/1.0/queue/nil").
|
62
|
-
to_return(:status => 200,
|
63
|
-
:body => mocks_path.join('queue-nil.txt').read,
|
64
|
-
:headers => {})
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
describe 'authentication' do
|
69
|
-
it "authenticates on instantiation" do
|
70
|
-
rt = Roust.new(@credentials)
|
71
|
-
rt.authenticated?.should be_true
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe 'tickets' do
|
76
|
-
it "can list tickets matching a query" do
|
77
|
-
rt = Roust.new(@credentials)
|
78
|
-
rt.authenticated?.should be_true
|
79
|
-
|
80
|
-
results = rt.search(:query => "id = 1 or id = 2")
|
81
|
-
results.size.should == 2
|
82
|
-
results.each do |result|
|
83
|
-
result.size.should == 2
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
it "can fetch metadata on individual tickets" do
|
88
|
-
rt = Roust.new(@credentials)
|
89
|
-
rt.authenticated?.should be_true
|
90
|
-
|
91
|
-
ticket = rt.show("1")
|
92
|
-
ticket.should_not be_nil
|
93
|
-
|
94
|
-
attrs = %w(id Subject Queue) +
|
95
|
-
%w(Requestors Cc AdminCc Owner Creator) +
|
96
|
-
%w(Resolved Status) +
|
97
|
-
%w(Starts Started TimeLeft Due TimeWorked TimeEstimated) +
|
98
|
-
%w(LastUpdated Created Told) +
|
99
|
-
%w(Priority FinalPriority InitialPriority)
|
100
|
-
|
101
|
-
attrs.each do |attr|
|
102
|
-
ticket[attr].should_not be_nil, "#{attr} key doesn't exist"
|
103
|
-
end
|
104
|
-
|
105
|
-
%w(Requestors Cc AdminCc).each do |field|
|
106
|
-
ticket[field].size.should > 1
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
it "can fetch transactions on individual tickets" do
|
111
|
-
rt = Roust.new(@credentials)
|
112
|
-
rt.authenticated?.should be_true
|
113
|
-
|
114
|
-
short = rt.history("1", :format => "short")
|
115
|
-
|
116
|
-
short.size.should > 1
|
117
|
-
short.each do |txn|
|
118
|
-
txn.size.should == 2
|
119
|
-
txn.first.should match(/^\d+$/)
|
120
|
-
txn.last.should match(/^\w.*\w$/)
|
121
|
-
end
|
122
|
-
|
123
|
-
#attrs = %w(ticket data oldvalue creator timetaken) +
|
124
|
-
# %w(id type field newvalue content description) +
|
125
|
-
# %w(attachments created)
|
126
|
-
attrs = %w(ticket data oldvalue timetaken) +
|
127
|
-
%w(id type field newvalue content description)
|
128
|
-
|
129
|
-
long = rt.history("1", :format => "long")
|
130
|
-
long.size.should > 0
|
131
|
-
long.each do |txn|
|
132
|
-
attrs.each do |attr|
|
133
|
-
txn[attr].should_not be_nil, "#{attr} key doesn't exist"
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
describe 'user' do
|
140
|
-
it 'can lookup user details' do
|
141
|
-
rt = Roust.new(@credentials)
|
142
|
-
rt.authenticated?.should be_true
|
143
|
-
|
144
|
-
attrs = %w(name realname gecos nickname emailaddress id lang password)
|
145
|
-
|
146
|
-
user = rt.user_show('dan@us.example')
|
147
|
-
attrs.each do |attr|
|
148
|
-
user[attr].should_not be_nil, "#{attr} key doesn't exist"
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
it 'returns nil for unknown users' do
|
153
|
-
rt = Roust.new(@credentials)
|
154
|
-
rt.authenticated?.should be_true
|
155
|
-
|
156
|
-
queue = rt.user_show('nil')
|
157
|
-
queue.should be_nil
|
158
|
-
end
|
159
|
-
|
160
|
-
it 'can modify an existing user' do
|
161
|
-
mocks_path = Pathname.new(__FILE__).parent.join('mocks')
|
162
|
-
stub_request(:get, "http://rt.example.org/REST/1.0/user/dan@us.example").
|
163
|
-
to_return(:status => 200,
|
164
|
-
:body => mocks_path.join('user-dan@us.example-after-edit.txt').read,
|
165
|
-
:headers => {})
|
166
|
-
|
167
|
-
rt = Roust.new(@credentials)
|
168
|
-
rt.authenticated?.should be_true
|
169
|
-
|
170
|
-
attrs = %w(name realname gecos nickname emailaddress id lang password)
|
171
|
-
|
172
|
-
attrs = { 'RealName' => 'Daniel Smith' }
|
173
|
-
user = rt.user_update('dan@us.example', attrs)
|
174
|
-
|
175
|
-
user['realname'].should == 'Daniel Smith'
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
describe 'queue' do
|
180
|
-
it "can lookup queue details" do
|
181
|
-
rt = Roust.new(@credentials)
|
182
|
-
rt.authenticated?.should be_true
|
183
|
-
|
184
|
-
attrs = %w(id name description correspondaddress commentaddress) +
|
185
|
-
%w(initialpriority finalpriority defaultduein)
|
186
|
-
|
187
|
-
queue = rt.queue('13')
|
188
|
-
attrs.each do |attr|
|
189
|
-
queue[attr].should_not be_nil, "#{attr} key doesn't exist"
|
190
|
-
end
|
191
|
-
|
192
|
-
end
|
193
|
-
|
194
|
-
it 'returns nil for unknown queues' do
|
195
|
-
rt = Roust.new(@credentials)
|
196
|
-
rt.authenticated?.should be_true
|
197
|
-
|
198
|
-
queue = rt.queue('nil')
|
199
|
-
queue.should be_nil
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|