ruby_bugzilla 0.2.0 → 0.3.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.
- data/lib/ruby_bugzilla/version.rb +1 -1
- data/lib/ruby_bugzilla.rb +64 -1
- data/spec/ruby_bugzilla_spec.rb +98 -5
- metadata +4 -4
data/lib/ruby_bugzilla.rb
CHANGED
@@ -126,6 +126,65 @@ class RubyBugzilla
|
|
126
126
|
[self.string_command(CMD, params), query_cmd_result.output]
|
127
127
|
end
|
128
128
|
|
129
|
+
|
130
|
+
#
|
131
|
+
# Example Usage:
|
132
|
+
#
|
133
|
+
# bugids can be an Array of bug ids, a String or Fixnum
|
134
|
+
# containing a single bug id
|
135
|
+
#
|
136
|
+
# options are a hash of options supported by python-bugzilla
|
137
|
+
#
|
138
|
+
# Set the status of multiple bugs to RELEASE_PENDING:
|
139
|
+
# RubyBugzilla.modify([948970, 948971], :status => "RELEASE_PENDING")
|
140
|
+
#
|
141
|
+
# Add a comment
|
142
|
+
# RubyBugzilla.modify("948972", :comment => "whatevs")
|
143
|
+
#
|
144
|
+
# Set the status to POST and add a comment
|
145
|
+
# RubyBugzilla.modify(948970, :status => "POST", :comment => "Fixed in shabla")
|
146
|
+
#
|
147
|
+
def self.modify(bugids_arg, options)
|
148
|
+
|
149
|
+
raise "Please install python-bugzilla" unless File.exists?(File.expand_path(CMD))
|
150
|
+
|
151
|
+
bugids = Array(bugids_arg)
|
152
|
+
if bugids.empty? || options.empty? || bugids_arg.to_s.empty?
|
153
|
+
raise ArgumentError, "bugids and options must be specified"
|
154
|
+
end
|
155
|
+
|
156
|
+
uri_opt, debug_opt = self.options
|
157
|
+
params = {}
|
158
|
+
|
159
|
+
params["--bugzilla="] = "#{uri_opt}/xmlrpc.cgi" unless uri_opt.nil?
|
160
|
+
params["modify"] = nil
|
161
|
+
|
162
|
+
self.set_params_bugids(params, bugids)
|
163
|
+
self.set_params_options(params, options)
|
164
|
+
|
165
|
+
begin
|
166
|
+
modify_cmd_result = LinuxAdmin.run!(CMD, :params => params)
|
167
|
+
rescue => error
|
168
|
+
raise "#{self.string_command(CMD, params)} Failed.\n#{error}"
|
169
|
+
end
|
170
|
+
|
171
|
+
self.string_command(CMD, params)
|
172
|
+
end
|
173
|
+
|
174
|
+
private
|
175
|
+
def self.set_params_options(params, options)
|
176
|
+
options.each do |key,value|
|
177
|
+
params["--#{key}="] = value
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
private
|
182
|
+
def self.set_params_bugids(params, bugids)
|
183
|
+
bugids.each do |bugid|
|
184
|
+
params[bugid] = nil
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
129
188
|
private
|
130
189
|
def self.string_command(cmd, params = {}, password=nil)
|
131
190
|
scrubbed_str = str = ""
|
@@ -134,7 +193,11 @@ class RubyBugzilla
|
|
134
193
|
if value.kind_of?(Array)
|
135
194
|
str << " #{param} \"#{value.join(" ")}\" "
|
136
195
|
else
|
137
|
-
|
196
|
+
if value.to_s.length == 0
|
197
|
+
str << " #{param} "
|
198
|
+
else
|
199
|
+
str << " #{param}\"#{value}\" "
|
200
|
+
end
|
138
201
|
end
|
139
202
|
end
|
140
203
|
scrubbed_str = str.sub(password, "********") unless password.nil?
|
data/spec/ruby_bugzilla_spec.rb
CHANGED
@@ -59,12 +59,11 @@ describe RubyBugzilla do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
context "#login!" do
|
62
|
-
|
63
62
|
it "when the bugzilla command is not found" do
|
64
63
|
ignore_warnings do
|
65
64
|
RubyBugzilla::CMD = '/This/cmd/does/not/exist'
|
66
65
|
end
|
67
|
-
expect{RubyBugzilla.login!}.to raise_exception
|
66
|
+
expect { RubyBugzilla.login! }.to raise_exception
|
68
67
|
end
|
69
68
|
|
70
69
|
it "when the bugzilla login command produces output" do
|
@@ -90,19 +89,18 @@ describe RubyBugzilla do
|
|
90
89
|
end
|
91
90
|
|
92
91
|
context "#query" do
|
93
|
-
|
94
92
|
it "when the bugzilla command is not found" do
|
95
93
|
ignore_warnings do
|
96
94
|
RubyBugzilla::CMD = '/This/cmd/does/not/exist'
|
97
95
|
end
|
98
|
-
expect{RubyBugzilla.query}.to raise_exception
|
96
|
+
expect { RubyBugzilla.query }.to raise_exception
|
99
97
|
end
|
100
98
|
|
101
99
|
it "when no product is specified" do
|
102
100
|
ignore_warnings do
|
103
101
|
RubyBugzilla::CMD = '/bin/echo'
|
104
102
|
end
|
105
|
-
expect{RubyBugzilla.query}.to raise_error(ArgumentError)
|
103
|
+
expect { RubyBugzilla.query }.to raise_error(ArgumentError)
|
106
104
|
end
|
107
105
|
|
108
106
|
it "when the bugzilla query command produces output" do
|
@@ -123,7 +121,102 @@ describe RubyBugzilla do
|
|
123
121
|
output.should include("STATUS:")
|
124
122
|
output.should include("SUMMARY:")
|
125
123
|
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context "#modify" do
|
127
|
+
it "when the bugzilla command is not found" do
|
128
|
+
ignore_warnings do
|
129
|
+
RubyBugzilla::CMD = '/This/cmd/does/not/exist'
|
130
|
+
end
|
131
|
+
expect { RubyBugzilla.modify }.to raise_exception
|
132
|
+
end
|
133
|
+
|
134
|
+
it "when no arguments are specified" do
|
135
|
+
ignore_warnings do
|
136
|
+
RubyBugzilla::CMD = '/bin/echo'
|
137
|
+
end
|
138
|
+
expect { RubyBugzilla.modify }.to raise_error(ArgumentError)
|
139
|
+
end
|
140
|
+
|
141
|
+
it "when no bugids are are specified" do
|
142
|
+
ignore_warnings do
|
143
|
+
RubyBugzilla::CMD = '/bin/echo'
|
144
|
+
end
|
145
|
+
expect { RubyBugzilla.modify("", :status => "POST") }.to raise_error(ArgumentError)
|
146
|
+
end
|
147
|
+
|
148
|
+
it "when no options are specified" do
|
149
|
+
ignore_warnings do
|
150
|
+
RubyBugzilla::CMD = '/bin/echo'
|
151
|
+
end
|
152
|
+
expect { RubyBugzilla.modify(9, {}) }.to raise_error(ArgumentError)
|
153
|
+
end
|
154
|
+
|
155
|
+
it "when the bugzilla modify command succeeds for one option and multiple BZs" do
|
156
|
+
# Fake the command and cookies file.
|
157
|
+
ignore_warnings do
|
158
|
+
RubyBugzilla::CMD = '/bin/echo'
|
159
|
+
RubyBugzilla::COOKIES_FILE = '/This/file/does/not/exist'
|
160
|
+
end
|
161
|
+
|
162
|
+
cmd, output = RubyBugzilla.login!("calvin", "hobbes")
|
163
|
+
cmd = RubyBugzilla.modify(["948970", "948971", "948972", "948973"],
|
164
|
+
:status => "RELEASE_PENDING")
|
126
165
|
|
166
|
+
cmd.should include("modify")
|
167
|
+
cmd.should include("--status=\"RELEASE_PENDING\"")
|
168
|
+
cmd.should include("948970")
|
169
|
+
cmd.should include("948971")
|
170
|
+
cmd.should include("948972")
|
171
|
+
cmd.should include("948973")
|
172
|
+
end
|
173
|
+
|
174
|
+
it "when the bugzilla modify command succeeds for multiple options and a Array BZ" do
|
175
|
+
# Fake the command and cookies file.
|
176
|
+
ignore_warnings do
|
177
|
+
RubyBugzilla::CMD = '/bin/echo'
|
178
|
+
RubyBugzilla::COOKIES_FILE = '/This/file/does/not/exist'
|
179
|
+
end
|
180
|
+
|
181
|
+
cmd, output = RubyBugzilla.login!("calvin", "hobbes")
|
182
|
+
cmd = RubyBugzilla.modify(bugids = ["948972"],
|
183
|
+
options = { :status => "POST", :comment => "Fixed in shabla" } )
|
184
|
+
|
185
|
+
cmd.should include("modify")
|
186
|
+
cmd.should include("--status=\"POST\"")
|
187
|
+
cmd.should include("948972")
|
188
|
+
cmd.should include("Fixed in shabla")
|
189
|
+
end
|
190
|
+
|
191
|
+
it "when the bugzilla modify command succeeds for a Fixnum BZ" do
|
192
|
+
# Fake the command and cookies file.
|
193
|
+
ignore_warnings do
|
194
|
+
RubyBugzilla::CMD = '/bin/echo'
|
195
|
+
RubyBugzilla::COOKIES_FILE = '/This/file/does/not/exist'
|
196
|
+
end
|
197
|
+
|
198
|
+
cmd, output = RubyBugzilla.login!("calvin", "hobbes")
|
199
|
+
cmd = RubyBugzilla.modify(948972, :status => "POST")
|
200
|
+
|
201
|
+
cmd.should include("modify")
|
202
|
+
cmd.should include("--status=\"POST\"")
|
203
|
+
cmd.should include("948972")
|
204
|
+
end
|
205
|
+
|
206
|
+
it "when the bugzilla modify command succeeds for a String BZ" do
|
207
|
+
# Fake the command and cookies file.
|
208
|
+
ignore_warnings do
|
209
|
+
RubyBugzilla::CMD = '/bin/echo'
|
210
|
+
RubyBugzilla::COOKIES_FILE = '/This/file/does/not/exist'
|
211
|
+
end
|
212
|
+
|
213
|
+
cmd, output = RubyBugzilla.login!("calvin", "hobbes")
|
214
|
+
cmd = RubyBugzilla.modify("948972", :status => "POST")
|
215
|
+
|
216
|
+
cmd.should include("modify")
|
217
|
+
cmd.should include("--status=\"POST\"")
|
218
|
+
cmd.should include("948972")
|
219
|
+
end
|
127
220
|
end
|
128
221
|
|
129
222
|
context "#credentials_from_file" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_bugzilla
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -131,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
segments:
|
133
133
|
- 0
|
134
|
-
hash: -
|
134
|
+
hash: -142661522033235115
|
135
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
136
|
none: false
|
137
137
|
requirements:
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
version: '0'
|
141
141
|
segments:
|
142
142
|
- 0
|
143
|
-
hash: -
|
143
|
+
hash: -142661522033235115
|
144
144
|
requirements: []
|
145
145
|
rubyforge_project:
|
146
146
|
rubygems_version: 1.8.25
|