polisher 0.4 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -661
  3. data/README.md +39 -0
  4. data/Rakefile +11 -88
  5. data/bin/binary_gem_resolver.rb +95 -0
  6. data/bin/gem_dependency_checker.rb +165 -0
  7. data/bin/git_gem_updater.rb +86 -0
  8. data/bin/ruby_rpm_spec_updater.rb +29 -0
  9. data/lib/polisher.rb +19 -0
  10. data/lib/polisher/apt.rb +12 -0
  11. data/lib/polisher/bodhi.rb +21 -0
  12. data/lib/polisher/bugzilla.rb +9 -0
  13. data/lib/polisher/core.rb +33 -0
  14. data/lib/polisher/errata.rb +43 -0
  15. data/lib/polisher/fedora.rb +43 -0
  16. data/lib/polisher/gem.rb +155 -0
  17. data/lib/polisher/gemfile.rb +72 -0
  18. data/lib/polisher/gemspec.rb +32 -0
  19. data/lib/polisher/git.rb +135 -0
  20. data/lib/polisher/koji.rb +54 -0
  21. data/lib/polisher/rhn.rb +14 -0
  22. data/lib/polisher/rpmspec.rb +254 -0
  23. data/lib/polisher/upstream.rb +29 -0
  24. data/lib/polisher/vendor.rb +9 -0
  25. data/lib/polisher/version_checker.rb +100 -0
  26. data/lib/polisher/yum.rb +28 -0
  27. data/spec/core_spec.rb +64 -0
  28. data/spec/fedora_spec.rb +14 -0
  29. data/spec/gem_spec.rb +82 -0
  30. data/spec/gemfile_spec.rb +45 -0
  31. data/spec/git_spec.rb +74 -0
  32. data/spec/rpmspec_spec.rb +105 -0
  33. data/spec/spec_helper.rb +50 -37
  34. data/spec/upstream_spec.rb +39 -0
  35. metadata +173 -179
  36. data/COPYING +0 -8
  37. data/README.rdoc +0 -105
  38. data/TODO +0 -7
  39. data/bin/server +0 -4
  40. data/config.ru +0 -25
  41. data/config/database.yml +0 -13
  42. data/config/polisher.yml +0 -5
  43. data/db/connection.rb +0 -52
  44. data/db/migrations/001_create_projects.rb +0 -23
  45. data/db/migrations/002_create_sources.rb +0 -25
  46. data/db/migrations/003_create_project_source_versions.rb +0 -28
  47. data/db/migrations/004_create_events.rb +0 -27
  48. data/db/migrations/005_create_project_dependencies.rb +0 -28
  49. data/db/models/event.rb +0 -87
  50. data/db/models/project.rb +0 -110
  51. data/db/models/project_dependency.rb +0 -27
  52. data/db/models/project_source_version.rb +0 -31
  53. data/db/models/source.rb +0 -101
  54. data/lib/common.rb +0 -71
  55. data/lib/dsl.rb +0 -292
  56. data/lib/event_handlers.rb +0 -166
  57. data/lib/gem_adapter.rb +0 -94
  58. data/lib/sinatra/url_for.rb +0 -40
  59. data/polisher.rb +0 -372
  60. data/public/stylesheets/style.css +0 -67
  61. data/spec/common_spec.rb +0 -28
  62. data/spec/dsl_spec.rb +0 -357
  63. data/spec/event_handlers_spec.rb +0 -300
  64. data/spec/gem_adapter_spec.rb +0 -89
  65. data/spec/models_spec.rb +0 -721
  66. data/spec/polisher_spec.rb +0 -573
  67. data/views/layout.haml +0 -22
  68. data/views/projects/index.haml +0 -42
  69. data/views/projects/index.html.haml +0 -38
  70. data/views/result.haml +0 -9
  71. data/views/sources/index.haml +0 -24
  72. data/views/sources/index.html.haml +0 -26
@@ -1,573 +0,0 @@
1
- # ruby gem polisher spec
2
- #
3
- # Copyright (C) 2010 Red Hat, Inc.
4
- # Written by Mohammed Morsi <mmorsi@redhat.com>
5
- #
6
- # This program is free software, you can redistribute it and/or modify
7
- # it under the terms of the GNU Affero General Public License
8
- # as published by the Free Software Foundation, either version 3
9
- # of the License, or (at your option) any later version.
10
- #
11
- # You should have received a copy of the the GNU Affero
12
- # General Public License, along with Polisher. If not, see
13
- # <http://www.gnu.org/licenses/>
14
-
15
- require File.dirname(__FILE__) + '/spec_helper'
16
-
17
- require 'libxml'
18
-
19
- describe "Polisher" do
20
-
21
- it "should redirect / to /projects.html" do
22
- get '/'
23
- last_response.should_not be_ok
24
- follow_redirect!
25
- last_request.url.should == "http://example.org/projects.html"
26
- last_response.should be_ok
27
- end
28
-
29
- it "should return projects in html format" do
30
- get '/projects.html'
31
- last_response.should be_ok
32
- end
33
-
34
- it "should return projects in xml format" do
35
- post '/projects/create', :name => 'project-xml-test1'
36
- post '/projects/create', :name => 'project-xml-test2'
37
- get '/projects'
38
- last_response.should be_ok
39
-
40
- expect = "<projects>"
41
- Project.find(:all).each { |p|
42
- expect += "<project><id>#{p.id}</id><name>#{p.name}</name><versions>"
43
- p.versions.each { |v|
44
- expect += "<version><id>#{v}</id><sources>"
45
- p.project_source_versions_for_version(v).each { |ps|
46
- expect += "<source><uri>#{ps.source.uri}</uri><version>#{ps.source_version}</version></source>"
47
- }
48
- expect += "</sources><events>"
49
- p.events_for_version(v).each { |e|
50
- expect += ("<event><process>#{e.process}</process>" +
51
- "<process_options>#{e.process_options}</process_options>" +
52
- "<version_qualifier>#{e.version_qualifier}</version_qualifier>" +
53
- "<version>#{e.version}</version></event>")
54
- }
55
- expect += "</events><dependencies>"
56
- p.dependencies_for_version(v).each { |d|
57
- expect += ("<dependency><project_id>#{d.depends_on_project.id}</project_id>" +
58
- "<project_name>#{d.depends_on_project.name}</project_name>" +
59
- "<project_version>#{d.depends_on_project_version}</project_version>" +
60
- "</dependency>")
61
-
62
- }
63
- expect += "</dependencies></version>"
64
- }
65
- expect += "</versions></project>"
66
- }
67
- expect += "</projects>"
68
- last_response.body.gsub(/\s*/, '').should == expect.gsub(/\s*/, '') # ignore whitespace differences
69
- end
70
-
71
- it "should allow project creations" do
72
- lambda do
73
- post '/projects/create', :name => 'create-project-test'
74
- end.should change(Project, :count).by(1)
75
- project = Project.find(:first, :conditions => [ 'name = ?', 'create-project-test'])
76
- project.should_not be_nil
77
-
78
- last_response.should be_ok
79
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "true"
80
- end
81
-
82
- it "should return an error if project name is not specified on creation" do
83
- lambda do
84
- post '/projects/create'
85
- end.should_not change(Project, :count)
86
- last_response.should be_ok
87
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
88
- end
89
-
90
- it "should return an error if a duplicate project is created" do
91
- lambda do
92
- post '/projects/create', :name => 'create-project-test2'
93
- end.should change(Project, :count).by(1)
94
-
95
- lambda do
96
- post '/projects/create', :name => 'create-project-test2'
97
- end.should_not change(Project, :count)
98
- last_response.should be_ok
99
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
100
- end
101
-
102
- it "should allow project deletions" do
103
- post '/projects/create', :name => 'delete-project-test'
104
- project_id = Project.find(:first, :conditions => ['name = ?', 'delete-project-test']).id
105
- lambda do
106
- delete "/projects/destroy/#{project_id}"
107
- end.should change(Project, :count).by(-1)
108
- last_response.should be_ok
109
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "true"
110
- end
111
-
112
- it "should return an error if project id to delete is invalid" do
113
- lambda do
114
- delete "/projects/destroy/abc"
115
- end.should_not change(Project, :count)
116
- last_response.should be_ok
117
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
118
- end
119
-
120
- # test triggering release event
121
- it "should successfully post-process a released project" do
122
- project = Project.create :name => 'myproj'
123
-
124
- event = Event.create :project => project,
125
- :process => "integration_test_handler3",
126
- :version_qualifier => '=',
127
- :version => "5.6"
128
-
129
- event = Event.create :project => project,
130
- :process => "integration_test_handler4",
131
- :version_qualifier => '>',
132
- :version => "7.9"
133
-
134
- post '/projects/released', :name => 'myproj',
135
- :version => "5.6"
136
-
137
- last_response.should be_ok
138
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "true"
139
-
140
- $integration_test_handler_flags.include?(3).should be_true
141
- $integration_test_handler_flags.include?(4).should be_false
142
- end
143
-
144
- it "should return an error if there is a problem in the project release process" do
145
- project = Project.create :name => 'foobar42'
146
-
147
- event = Event.create :project => project,
148
- :process => "failed_event_handler",
149
- :version_qualifier => '=',
150
- :version => 1.0
151
-
152
-
153
- # need to specify name and version
154
- post '/projects/released', :name => 'foobar42'
155
- last_response.should be_ok
156
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
157
-
158
- post '/projects/released', :version => '1.0'
159
- last_response.should be_ok
160
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
161
-
162
- # event handler should throw exception, which the app should return
163
- post '/projects/released', :name => 'foobar42',
164
- :version => '1.0'
165
- last_response.should be_ok
166
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
167
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "errors" }.content.strip.should =~ /.*MYERROR.*/
168
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "message" }.content.strip.should =~ /.*MYERROR.*/
169
- end
170
-
171
- # test triggering release event
172
- it "should successfully post-process a released project w/ request params" do
173
- project = Project.create :name => 'post-process-project2'
174
-
175
- event = Event.create :project => project,
176
- :process => "integration_test_handler5",
177
- :version_qualifier => '=',
178
- :version => "5.0"
179
-
180
- post '/projects/released', :name => 'post-process-project2',
181
- :version => "5.0",
182
- :xver => "5.0.2-122"
183
-
184
- $integration_test_handler_flags.include?("xver5.0.2-122").should be_true
185
- end
186
-
187
- it "should return sources in html format" do
188
- get '/sources.html'
189
- last_response.should be_ok
190
- end
191
-
192
- it "should return sources in xml format" do
193
- post '/sources/create', :name => 'sources-xml-test1', :uri => 'http://foo.uri', :source_type => 'file'
194
- post '/sources/create', :name => 'sources-xml-test2', :uri => 'http://bar.uri', :source_type => 'file'
195
- get '/sources'
196
- last_response.should be_ok
197
-
198
- expect = "<sources>"
199
- Source.find(:all).each { |s|
200
- expect += "<source><id>#{s.id}</id><name>#{s.name}</name><source_type>#{s.source_type}</source_type><uri>#{s.uri}</uri><versions>"
201
- s.versions.each { |v|
202
- expect += "<version><id>#{v}</id><projects>"
203
- s.project_source_versions_for_version(v).each { |ps|
204
- expect += "<project><name>#{ps.project.name}</name><version>#{ps.project_version}</version></project>"
205
- }
206
- expect += "</projects></version>"
207
- }
208
- expect += "</versions></source>"
209
- }
210
- expect += "</sources>"
211
- last_response.body.gsub(/\s*/, '').should == expect.gsub(/\s*/, '') # ignore whitespace differences
212
- end
213
-
214
- it "should allow source creations" do
215
- lambda do
216
- post '/sources/create', :name => 'create-source-test', :uri => 'http://create-source-test.uri', :source_type => 'gem'
217
- end.should change(Source, :count).by(1)
218
- project = Source.find(:first, :conditions => [ 'name = ? AND uri = ? AND source_type = ?', 'create-source-test', 'http://create-source-test.uri', 'gem'])
219
- project.should_not be_nil
220
-
221
- last_response.should be_ok
222
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "true"
223
- end
224
-
225
- it "should return an error if source name, uri, or source_type is not specified on creation" do
226
- lambda do
227
- post '/sources/create'
228
- end.should_not change(Source, :count)
229
- last_response.should be_ok
230
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
231
-
232
- lambda do
233
- post '/sources/create', :name => 'invalid-source-test1'
234
- end.should_not change(Source, :count)
235
- last_response.should be_ok
236
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
237
-
238
- lambda do
239
- post '/sources/create', :name => 'invalid-source-test2', :uri => 'http://invalid-source2.uri'
240
- end.should_not change(Source, :count)
241
- last_response.should be_ok
242
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
243
-
244
- lambda do
245
- post '/sources/create', :source_type => 'gem'
246
- end.should_not change(Source, :count)
247
- last_response.should be_ok
248
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
249
- end
250
-
251
- it "should return an error if a duplicate project or other error occurs on creation" do
252
- lambda do
253
- post '/sources/create', :name => 'create-source-test42', :uri => "http://create.42", :source_type => "file"
254
- end.should change(Source, :count).by(1)
255
-
256
- lambda do
257
- post '/sources/create', :name => 'create-source-test42', :uri => "http://create.42", :source_type => "file"
258
- end.should_not change(Source, :count)
259
- last_response.should be_ok
260
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
261
-
262
- # invalid source_type
263
- lambda do
264
- post '/sources/create', :name => 'create-source-test420', :uri => "http://create.420", :source_type => "xyz"
265
- end.should_not change(Source, :count)
266
- last_response.should be_ok
267
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
268
- end
269
-
270
- it "should allow source deletions" do
271
- post '/sources/create', :name => 'delete-source-test', :uri => 'http://delete.source.test', :source_type => 'gem'
272
- source_id = Source.find(:first, :conditions => ['name = ?', 'delete-source-test']).id
273
- lambda do
274
- delete "/sources/destroy/#{source_id}"
275
- end.should change(Source, :count).by(-1)
276
- last_response.should be_ok
277
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "true"
278
- end
279
-
280
- it "should return an error if source id to delete is invalid" do
281
- lambda do
282
- delete "/sources/destroy/abc"
283
- end.should_not change(Project, :count)
284
- last_response.should be_ok
285
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
286
- end
287
-
288
- # test triggering release event
289
- it "should successfully post-process a released source" do
290
- project = Project.create! :name => 'myproj42'
291
- project.sources << Source.create!(:name => 'mysource', :source_type => 'file',
292
- :uri => 'http://my.source.uri')
293
- project.save!
294
-
295
- event = Event.create :project => project,
296
- :process => "integration_test_handler6",
297
- :version_qualifier => '=',
298
- :version => "5.6"
299
-
300
- # since we don't specify source_id / project_id in project_source_versions above, the project
301
- # version used to trigger the events will be the same as the source version
302
- post '/sources/released', :name => 'mysource',
303
- :version => "5.6"
304
-
305
- last_response.should be_ok
306
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "true"
307
-
308
- $integration_test_handler_flags.include?("5.6").should == true
309
- end
310
-
311
- it "should return an error if there is a problem in the project release process" do
312
- project = Project.create :name => 'foobar142'
313
- project.sources << Source.create!(:name => 'mysource42', :source_type => 'file',
314
- :uri => 'http://my.source42.uri')
315
- project.save!
316
-
317
- event = Event.create :project => project,
318
- :process => "failed_event_handler",
319
- :version_qualifier => '=',
320
- :version => 1.0
321
-
322
-
323
- # need to specify name and version
324
- post '/sources/released', :name => 'mysource42'
325
- last_response.should be_ok
326
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
327
-
328
- post '/sources/released', :version => '1.0'
329
- last_response.should be_ok
330
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
331
-
332
- # event handler should throw exception, which the app should return
333
- post '/sources/released', :name => 'mysource42',
334
- :version => '1.0'
335
- last_response.should be_ok
336
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
337
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "errors" }.content.strip.should =~ /.*MYERROR.*/
338
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "message" }.content.strip.should =~ /.*MYERROR.*/
339
- end
340
-
341
- it "should allow project source version creations" do
342
- project = Project.create! :name => "create-project-source-testproject1"
343
- source = Source.create! :name => "create-project_source-testsource1", :source_type => 'file', :uri => 'http://cpsts1'
344
-
345
- lambda do
346
- post '/project_source_versions/create', :project_id => project.id, :source_id => source.id
347
- end.should change(ProjectSourceVersion, :count).by(1)
348
- ps = ProjectSourceVersion.find(:first, :conditions => [ 'project_id = ? AND source_id = ?', project.id, source.id])
349
- ps.should_not be_nil
350
-
351
- last_response.should be_ok
352
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "true"
353
- end
354
-
355
- it "should return an error if project source version project_id or source_id is not specified on creation" do
356
- project = Project.create! :name => "create-project_source-test2"
357
- source = Source.create! :name => "create-project_source-testsource2", :source_type => 'file', :uri => 'http://cpsts10'
358
-
359
- lambda do
360
- post '/project_source_versions/create', :project_id => project.id
361
- end.should_not change(ProjectSourceVersion, :count)
362
- last_response.should be_ok
363
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
364
-
365
- lambda do
366
- post '/project_source_versions/create', :source_id => source.id
367
- end.should_not change(ProjectSourceVersion, :count)
368
- last_response.should be_ok
369
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
370
- end
371
-
372
- it "should return an error if project source version project_id or source_id is invalid" do
373
- project = Project.create! :name => "create-project_source-test42"
374
- source = Source.create! :name => "create-project_source-testsource42", :source_type => 'file', :uri => 'http://cpsts10110'
375
-
376
- lambda do
377
- post '/project_source_versions/create', :project_id => 'abc', :source_id => source.id
378
- end.should_not change(ProjectSourceVersion, :count)
379
- last_response.should be_ok
380
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
381
-
382
- lambda do
383
- post '/project_source_versions/create', :source_id => 'def', :project_id => project.id
384
- end.should_not change(ProjectSourceVersion, :count)
385
- last_response.should be_ok
386
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
387
- end
388
-
389
- it "should allow project source version deletions" do
390
- project = Project.create! :name => "create-project_source-test20"
391
- source = Source.create! :name => "create-project_source-testsource420024", :source_type => 'file', :uri => 'http://cpsts20'
392
- post '/project_source_versions/create', :project_id => project.id, :source_id => source.id
393
-
394
- ps = ProjectSourceVersion.find(:first, :conditions => [ 'source_id = ? AND project_id = ?', source.id, project.id])
395
- lambda do
396
- delete "/project_source_versions/destroy/#{ps.id}"
397
- end.should change(ProjectSourceVersion, :count).by(-1)
398
- last_response.should be_ok
399
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "true"
400
- end
401
-
402
- it "should return an error if project source version id to delete is invalid" do
403
- lambda do
404
- delete "/project_source_versions/destroy/abc"
405
- end.should_not change(ProjectSourceVersion, :count)
406
- last_response.should be_ok
407
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
408
- end
409
-
410
- it "should allow project dependency creations" do
411
- project1 = Project.create! :name => "create-project-dep-testprojectA"
412
- project2 = Project.create! :name => "create-project-dep-testprojectB"
413
-
414
- lambda do
415
- post '/project_dependencies/create', :project_id => project1.id, :depends_on_project_id => project2.id
416
- end.should change(ProjectDependency, :count).by(1)
417
- pd = ProjectDependency.find(:first, :conditions => [ 'project_id = ? AND depends_on_project_id = ?', project1.id, project2.id])
418
- pd.should_not be_nil
419
-
420
- last_response.should be_ok
421
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "true"
422
- end
423
-
424
- it "should return an error if project_id or depends_on_project_id is not specified on dependency creation" do
425
- project = Project.create! :name => "create-project-dep-testprojectC"
426
-
427
- lambda do
428
- post '/project_dependencies/create', :project_id => project.id
429
- end.should_not change(ProjectDependency, :count)
430
- last_response.should be_ok
431
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
432
-
433
- lambda do
434
- post '/project_dependencies/create', :depends_on_project_id => project.id
435
- end.should_not change(ProjectDependency, :count)
436
- last_response.should be_ok
437
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
438
- end
439
-
440
- it "should return an error if project_id or depends_on_project_id is invalid" do
441
- project = Project.create! :name => "create-project-dep-testprojectD"
442
-
443
- lambda do
444
- post '/project_dependencies/create', :project_id => 'abc', :depends_on_project_id => project.id
445
- end.should_not change(ProjectDependency, :count)
446
- last_response.should be_ok
447
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
448
-
449
- lambda do
450
- post '/project_source_versions/create', :depends_on_project_id => 'def', :project_id => project.id
451
- end.should_not change(ProjectDependency, :count)
452
- last_response.should be_ok
453
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
454
- end
455
-
456
- it "should allow project dependency deletions" do
457
- project1 = Project.create! :name => "delete-project-dep-testprojectA"
458
- project2 = Project.create! :name => "delete-project-dep-testprojectB"
459
- post '/project_dependencies/create', :project_id => project1.id, :depends_on_project_id => project2.id
460
-
461
- ps = ProjectDependency.find(:first, :conditions => [ 'project_id = ? AND depends_on_project_id = ?', project1.id, project2.id])
462
- lambda do
463
- delete "/project_dependencies/destroy/#{ps.id}"
464
- end.should change(ProjectDependency, :count).by(-1)
465
- last_response.should be_ok
466
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "true"
467
- end
468
-
469
- it "should return an error if project dependency id to delete is invalid" do
470
- lambda do
471
- delete "/project_dependencies/destroy/abc"
472
- end.should_not change(ProjectDependency, :count)
473
- last_response.should be_ok
474
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
475
- end
476
-
477
- it "should allow project event creations" do
478
- project = Project.create! :name => "create-event-test-project"
479
- lambda do
480
- post '/events/create', :project_id => project.id,
481
- :process => 'fooproc',
482
- :version => '1.0',
483
- :version_qualifier => ">",
484
- :process_options => 'opts'
485
- end.should change(Event, :count).by(1)
486
- Event.find(:first,
487
- :conditions => ['project_id = ? AND process = ? AND version = ? ' +
488
- 'AND version_qualifier = ? AND process_options = ?',
489
- project.id, 'fooproc', '1.0', '>', 'opts']).should_not be_nil
490
- last_response.should be_ok
491
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "true"
492
- end
493
-
494
- it "should return an error if event process id or process is missing or invalid on creation" do
495
- project = Project.create! :name => "create-event-test-project2"
496
-
497
- lambda do
498
- post '/events/create'
499
- end.should_not change(Event, :count)
500
- last_response.should be_ok
501
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
502
-
503
- lambda do
504
- post '/events/create', :process => "fooproc"
505
- end.should_not change(Event, :count)
506
- last_response.should be_ok
507
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
508
-
509
- lambda do
510
- post '/events/create', :project_id => project.id
511
- end.should_not change(Event, :count)
512
- last_response.should be_ok
513
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
514
-
515
- lambda do
516
- post '/events/create', :project_id => 'abc'
517
- end.should_not change(Event, :count)
518
- last_response.should be_ok
519
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
520
- end
521
-
522
- it "should allow event deletions" do
523
- proj = Project.create :name => "delete-event-test-project"
524
- event = Event.create :project => proj, :process => 'fooproc'
525
- lambda do
526
- delete "/events/destroy/#{event.id}"
527
- end.should change(Event, :count).by(-1)
528
- last_response.should be_ok
529
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "true"
530
- end
531
-
532
- it "should return an error if event id to delete is invalid" do
533
- lambda do
534
- delete "/events/destroy/abc"
535
- end.should_not change(Event, :count)
536
- last_response.should be_ok
537
- LibXML::XML::Document.string(last_response.body).root.children.find { |c| c.name == "success" }.content.strip.should == "false"
538
- end
539
-
540
- end
541
-
542
- # prolly a better way todo this, but fine for now
543
- $integration_test_handler_flags = []
544
-
545
- def failed_event_handler(event, version, args = {})
546
- raise ArgumentError, "MYERROR"
547
- end
548
-
549
- def integration_test_handler1(event, version, args = {})
550
- $integration_test_handler_flags << 1
551
- end
552
-
553
- def integration_test_handler2(event, version, args = {})
554
- $integration_test_handler_flags << 2
555
- end
556
-
557
- def integration_test_handler3(event, version, args = {})
558
- $integration_test_handler_flags << 3
559
- end
560
-
561
- def integration_test_handler4(event, version, args = {})
562
- $integration_test_handler_flags << 4
563
- end
564
-
565
- def integration_test_handler5(event, version, args = {})
566
- args.each { |k,v|
567
- $integration_test_handler_flags << "#{k}#{v}"
568
- }
569
- end
570
-
571
- def integration_test_handler6(event, version, args = {})
572
- $integration_test_handler_flags << version
573
- end