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,300 +0,0 @@
1
- # ruby gem polisher event handlers 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 Motel. If not, see
13
- # <http://www.gnu.org/licenses/>
14
-
15
- require 'fileutils'
16
-
17
- require File.dirname(__FILE__) + '/spec_helper'
18
-
19
- include EventHandlers
20
-
21
- describe "EventHandlers" do
22
-
23
- before(:all) do
24
- @gem = Project.create! :name => 'rubygem-polisher'
25
- @gem.primary_source = Source.new :name => 'polisher', :source_type => 'gem', :uri => 'http://rubygems.org/gems/polisher-%{version}.gem'
26
- @gem_event0 = Event.create! :project => @gem, :process => 'download_sources'
27
- @gem_event1 = Event.create! :project => @gem, :process => 'create_rpm_package', :process_options => "mock=fedora-12-x86_64"
28
-
29
- @gem_event2 = Event.create! :project => @gem, :process => 'create_rpm_package',
30
- :process_options => "spec=#{ARTIFACTS_DIR}/templates/polisher.spec.tpl;mock=fedora-12-x86_64"
31
-
32
- @gem_event3 = Event.create! :project => @gem, :process => 'update_repo', :process_options => "#{ARTIFACTS_DIR}/repos/fedora-ruby"
33
-
34
- @project = Project.create :name => 'ruby-activerecord'
35
- @project.sources << Source.new(:name => 'activerecord', :source_type => 'file',
36
- :uri => 'http://rubyforge.org/frs/download.php/%{level}/activerecord-%{version}.tgz')
37
-
38
- @project_event0 = Event.create! :project => @project, :process => 'download_sources', :process_options => "level=28874"
39
- @project_event1 = Event.create! :project => @project, :process => 'create_rpm_package',
40
- :process_options => "spec=#{ARTIFACTS_DIR}/templates/polisher-projects.spec.tpl;mock=fedora-12-x86_64"
41
-
42
- @project_event2 = Event.create! :project => @project, :process => 'update_repo', :process_options => "#{ARTIFACTS_DIR}/repos/fedora-ruby"
43
- end
44
-
45
- before(:each) do
46
- FileUtils.rm_rf(ARTIFACTS_DIR) if File.directory? ARTIFACTS_DIR
47
- FileUtils.mkdir_p(ARTIFACTS_DIR + '/repos')
48
- FileUtils.mkdir_p(ARTIFACTS_DIR + '/SOURCES')
49
- FileUtils.mkdir_p(ARTIFACTS_DIR + '/SPECS')
50
- FileUtils.mkdir_p(ARTIFACTS_DIR + '/templates')
51
-
52
- File.write(ARTIFACTS_DIR + '/templates/polisher.spec.tpl', POLISHER_GEM2RPM_TEST_TEMPLATE)
53
- File.write(ARTIFACTS_DIR + '/templates/polisher-projects.spec.tpl', POLISHER_ERB_TEST_TEMPLATE)
54
- end
55
-
56
- after(:each) do
57
- FileUtils.rm_rf(ARTIFACTS_DIR) if File.directory? ARTIFACTS_DIR
58
- end
59
-
60
- it "should download sources" do
61
- download_sources(@gem_event0, "0.3")
62
- File.exists?(ARTIFACTS_DIR + '/SOURCES/polisher-0.3.gem').should == true
63
-
64
- download_sources(@project_event0, "2.0.1")
65
- File.exists?(ARTIFACTS_DIR + '/SOURCES/activerecord-2.0.1.tgz').should == true
66
- end
67
-
68
- it "should correctly create a gem based package" do
69
- download_sources(@gem_event0, "0.3")
70
- create_rpm_package(@gem_event1, "0.3")
71
- File.exists?(ARTIFACTS_DIR + '/SPECS/rubygem-polisher.spec').should == true
72
- File.exists?(ARTIFACTS_DIR + "/SRPMS/rubygem-polisher-0.3-1.fc11.src.rpm").should == true
73
- File.exists?(ARTIFACTS_DIR + "/RPMS/noarch/rubygem-polisher-0.3-1.fc12.noarch.rpm").should == true
74
- end
75
-
76
- it "should correctly create a gem based package using template" do
77
- download_sources(@gem_event0, "0.3")
78
- create_rpm_package(@gem_event2, '0.3')
79
- File.exists?(ARTIFACTS_DIR + '/SPECS/rubygem-polisher.spec').should == true
80
- File.read_all(ARTIFACTS_DIR + '/SPECS/rubygem-polisher.spec').should =~ /.*by polisher.*/
81
- end
82
-
83
- it "should correctly create an upstream based project package" do
84
- download_sources(@project_event0, "2.0.1")
85
- create_rpm_package(@project_event1, "2.0.1", :release => 3)
86
-
87
- File.exists?(ARTIFACTS_DIR + '/SPECS/ruby-activerecord.spec').should == true
88
- File.exists?(ARTIFACTS_DIR + "/SRPMS/ruby-activerecord-2.0.1-3.fc11.src.rpm").should == true
89
- File.exists?(ARTIFACTS_DIR + "/RPMS/noarch/ruby-activerecord-2.0.1-3.fc12.noarch.rpm").should == true
90
- File.exists?(ARTIFACTS_DIR + "/RPMS/noarch/ruby-activerecord-subpkg-2.0.1-3.fc12.noarch.rpm").should == true
91
- File.exists?(ARTIFACTS_DIR + "/RPMS/noarch/another-subpkg-2.0.1-3.fc12.noarch.rpm").should == true
92
- end
93
-
94
- it "should correctly update repository" do
95
- download_sources(@gem_event0, "0.3")
96
- create_rpm_package(@gem_event1, '0.3')
97
- update_yum_repo(@gem_event3, '0.3')
98
-
99
- template = ARTIFACTS_DIR + '/templates/polisher-projects.spec.tpl'
100
- File.write(template, POLISHER_ERB_TEST_TEMPLATE)
101
- download_sources(@project_event0, "2.0.1")
102
- create_rpm_package(@project_event1, "2.0.1", :release => 3)
103
- update_yum_repo(@project_event2, '2.0')
104
-
105
- File.directory?(ARTIFACTS_DIR + '/repos/fedora-ruby/noarch').should == true
106
- File.directory?(ARTIFACTS_DIR + '/repos/fedora-ruby/repodata').should == true
107
- File.exists?(ARTIFACTS_DIR + "/repos/fedora-ruby/noarch/rubygem-polisher-0.3-1.fc12.noarch.rpm").should == true
108
- File.exists?(ARTIFACTS_DIR + "/repos/fedora-ruby/noarch/ruby-activerecord-2.0.1-3.fc12.noarch.rpm").should == true
109
- File.exists?(ARTIFACTS_DIR + "/repos/fedora-ruby/noarch/ruby-activerecord-subpkg-2.0.1-3.fc12.noarch.rpm").should == true
110
- File.exists?(ARTIFACTS_DIR + "/repos/fedora-ruby/noarch/another-subpkg-2.0.1-3.fc12.noarch.rpm").should == true
111
- File.exists?(ARTIFACTS_DIR + '/repos/fedora-ruby/repodata/repomd.xml').should == true
112
- File.exists?(ARTIFACTS_DIR + '/repos/fedora-ruby/repodata/primary.xml.gz').should == true
113
- File.exists?(ARTIFACTS_DIR + '/repos/fedora-ruby/repodata/other.xml.gz').should == true
114
- File.exists?(ARTIFACTS_DIR + '/repos/fedora-ruby/repodata/filelists.xml.gz').should == true
115
- end
116
-
117
- end
118
-
119
- POLISHER_GEM2RPM_TEST_TEMPLATE =
120
- %q{# Generated from <%= File::basename(format.gem_path) %> by polisher -*- rpm-spec -*-
121
- %define ruby_sitelib %(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")
122
- %define gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
123
- %define gemname <%= spec.name %>
124
- %define geminstdir %{gemdir}/gems/%{gemname}-%{version}
125
-
126
- Summary: <%= spec.summary.gsub(/\.$/, "") %>
127
- Name: rubygem-%{gemname}
128
- Version: <%= spec.version %>
129
- Release: 1%{?dist}
130
- Group: Development/Languages
131
- License: GPLv2+ or Ruby
132
- URL: <%= spec.homepage %>
133
- Source0: <%= download_path %>%{gemname}-%{version}.gem
134
- BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
135
- Requires: rubygems
136
- <% for d in spec.dependencies %>
137
- <% for req in d.version_requirements.to_rpm %>
138
- Requires: rubygem(<%= d.name %>) <%= req %>
139
- <% end %>
140
- <% end %>
141
- BuildRequires: rubygems
142
- <% if spec.extensions.empty? %>
143
- BuildArch: noarch
144
- <% end %>
145
- Provides: rubygem(%{gemname}) = %{version}
146
-
147
- %description
148
- <%= spec.description.to_s.chomp.word_wrap(78) + "\n" %>
149
-
150
- <% if nongem %>
151
- %package -n ruby-%{gemname}
152
- Summary: <%= spec.summary.gsub(/\.$/, "") %>
153
- Group: Development/Languages
154
- Requires: rubygem(%{gemname}) = %{version}
155
- <% spec.files.select{ |f| spec.require_paths.include?(File::dirname(f)) }.reject { |f| f =~ /\.rb$/ }.collect { |f| File::basename(f) }.each do |p| %>
156
- Provides: ruby(<%= p %>) = %{version}
157
- <% end %>
158
- %description -n ruby-%{gemname}
159
- <%= spec.description.to_s.chomp.word_wrap(78) + "\n" %>
160
- <% end # if nongem %>
161
-
162
- %prep
163
-
164
- %build
165
-
166
- %install
167
- rm -rf %{buildroot}
168
- mkdir -p %{buildroot}%{gemdir}
169
- <% rdoc_opt = spec.has_rdoc ? "--rdoc " : "" %>
170
- gem install --local --install-dir %{buildroot}%{gemdir} \
171
- --force <%= rdoc_opt %>%{SOURCE0}
172
- <% unless spec.executables.empty? %>
173
- mkdir -p %{buildroot}/%{_bindir}
174
- mv %{buildroot}%{gemdir}/bin/* %{buildroot}/%{_bindir}
175
- rmdir %{buildroot}%{gemdir}/bin
176
- find %{buildroot}%{geminstdir}/bin -type f | xargs chmod a+x
177
- <% end %>
178
- <% if nongem %>
179
- mkdir -p %{buildroot}%{ruby_sitelib}
180
- <% spec.files.select{ |f| spec.require_paths.include?(File::dirname(f)) }.each do |p| %>
181
- ln -s %{gemdir}/gems/%{gemname}-%{version}/<%= p %> %{buildroot}%{ruby_sitelib}
182
- <% end %>
183
- <% end # if nongem %>
184
-
185
- %clean
186
- rm -rf %{buildroot}
187
-
188
- %files
189
- %defattr(-, root, root, -)
190
- <% for f in spec.executables %>
191
- %{_bindir}/<%= f %>
192
- <% end %>
193
- %{gemdir}/gems/%{gemname}-%{version}/
194
- <% if spec.has_rdoc %>
195
- %doc %{gemdir}/doc/%{gemname}-%{version}
196
- <% end %>
197
- <% for f in spec.extra_rdoc_files %>
198
- %doc %{geminstdir}/<%= f %>
199
- <% end %>
200
- %{gemdir}/cache/%{gemname}-%{version}.gem
201
- %{gemdir}/specifications/%{gemname}-%{version}.gemspec
202
-
203
- <% if nongem %>
204
- %files -n ruby-%{gemname}
205
- %defattr(-, root, root, -)
206
- %{ruby_sitelib}/*
207
- <% end # if nongem %>
208
-
209
- %changelog
210
- * <%= Time.now.strftime("%a %b %d %Y") %> <%= packager %> - <%= spec.version %>-1
211
- - Initial package
212
- }
213
-
214
- # copied w/ changes from http://cvs.fedoraproject.org/viewvc/rpms/ruby-activerecord/F-13/ruby-activerecord.spec?revision=1.6&view=co
215
- POLISHER_ERB_TEST_TEMPLATE =
216
- %q{
217
- %{!?ruby_sitelib: %define ruby_sitelib %(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")}
218
- %define rname activerecord
219
- # Only run the tests on distros that have sqlite3
220
- %define with_check 0
221
-
222
- Name: ruby-%{rname}
223
- Version: <%= version %>
224
- Release: <%= release %>%{?dist}
225
- Summary: Implements the ActiveRecord pattern for ORM
226
-
227
- Group: Development/Languages
228
-
229
- License: MIT
230
- URL: http://rubyforge.org/projects/activerecord/
231
- Source0: http://rubyforge.org/frs/download.php/28874/activerecord-%{version}.tgz
232
- BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
233
-
234
- BuildArch: noarch
235
- BuildRequires: ruby >= 1.8
236
- %if %with_check
237
- BuildRequires: ruby(active_support) = 2.0.1
238
- BuildRequires: ruby(sqlite3)
239
- %endif
240
- Requires: ruby(abi) = 1.8
241
- Requires: ruby(active_support) = 2.0.1
242
- Provides: ruby(active_record) = %{version}
243
-
244
- %description
245
- Implements the ActiveRecord pattern (Fowler, PoEAA) for ORM. It ties
246
- database tables and classes together for business objects, like Customer or
247
- Subscription, that can find, save, and destroy themselves without resorting
248
- to manual SQL.
249
-
250
- %package subpkg
251
- Summary: Test sub package
252
- Group: Development/Languages
253
-
254
- %package -n another-subpkg
255
- Summary: Another test sub package
256
- Group: Development/Languages
257
-
258
- %description subpkg
259
- Test subpackage
260
-
261
- %description -n another-subpkg
262
- Another est subpackage
263
-
264
- %prep
265
- %setup -q -n %{rname}-%{version}
266
- chmod 0644 README
267
-
268
- %build
269
-
270
- %install
271
- rm -rf $RPM_BUILD_ROOT
272
- install -d $RPM_BUILD_ROOT/%{ruby_sitelib}/
273
- cp -pr lib/* $RPM_BUILD_ROOT/%{ruby_sitelib}/
274
- find $RPM_BUILD_ROOT/%{ruby_sitelib} -type f | xargs chmod a-x
275
-
276
- %check
277
- %if %with_check
278
- cd test
279
- ruby -I "connections/native_sqlite3" base_test.rb
280
- %endif
281
-
282
- %clean
283
- rm -rf $RPM_BUILD_ROOT
284
-
285
- %files
286
- %defattr(-,root,root,-)
287
- %{ruby_sitelib}/activerecord.rb
288
- %{ruby_sitelib}/active_record.rb
289
- %{ruby_sitelib}/active_record
290
- %doc README CHANGELOG examples/
291
-
292
- %files subpkg
293
- %defattr(-,root,root,-)
294
- %doc README
295
-
296
- %files -n another-subpkg
297
- %defattr(-,root,root,-)
298
- %doc CHANGELOG
299
-
300
- }
@@ -1,89 +0,0 @@
1
- # ruby gem polisher gem adapter 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 'uri'
16
- require 'json'
17
- require 'net/http'
18
-
19
- require File.dirname(__FILE__) + '/spec_helper'
20
-
21
- describe "Polisher::GemAdapter" do
22
- it "should successfully subscribe/unsubscribe to updates" do
23
- gem = Source.new :name => "polisher", :source_type => "gem",
24
- :uri => "http://rubygems.org/downloads/polisher-0.3.gem"
25
-
26
- Polisher::GemAdapter.subscribe(gem,
27
- "http://projects.morsi.org/polisher/demo/gems/released/1",
28
- POLISHER_CONFIG["gem_api_key"])
29
- Polisher::GemAdapter.subscribed?(gem, POLISHER_CONFIG["gem_api_key"]).should == true
30
- Polisher::GemAdapter.unsubscribe(gem,
31
- "http://projects.morsi.org/polisher/demo/gems/released/1",
32
- POLISHER_CONFIG["gem_api_key"])
33
- Polisher::GemAdapter.subscribed?(gem, POLISHER_CONFIG["gem_api_key"]).should == false
34
- end
35
-
36
- it "should raise error if subscribe source, callback_url, or api_key is invalid" do
37
- lambda {
38
- Polisher::GemAdapter.subscribe(nil,
39
- "http://projects.morsi.org/polisher/demo/gems/released/1",
40
- POLISHER_CONFIG['gem_api_key'])
41
- }.should raise_error(ArgumentError)
42
-
43
- gem = Source.new :name => "polisher", :source_type => "gem",
44
- :uri => "http://rubygems.org/downloads/polisher-0.3.gem"
45
- lambda {
46
- Polisher::GemAdapter.subscribe(gem, 42, POLISHER_CONFIG['gem_api_key'])
47
- }.should raise_error(ArgumentError)
48
-
49
- lambda {
50
- Polisher::GemAdapter.subscribe(gem,
51
- "http://projects.morsi.org/polisher/demo/gems/released/1",
52
- nil)
53
- }.should raise_error(ArgumentError)
54
- end
55
-
56
- it "should raise error if subscription target is invalid" do
57
- gem = Source.new :name => "polisher", :source_type => "gem",
58
- :uri => "http://non.existant/downloads/polisher-0.3.gem"
59
- lambda {
60
- Polisher::GemAdapter.subscribe(gem,
61
- "http://projects.morsi.org/polisher/demo/gems/released/1",
62
- POLISHER_CONFIG["gem_api_key"])
63
- }.should raise_error(RuntimeError)
64
-
65
- gem = Source.new :name => "polisher", :source_type => "gem",
66
- :uri => "http://morsi.org/downloads/polisher-0.3.gem"
67
- lambda {
68
- Polisher::GemAdapter.subscribe(gem,
69
- "http://projects.morsi.org/polisher/demo/gems/released/1",
70
- POLISHER_CONFIG["gem_api_key"])
71
- }.should raise_error(RuntimeError)
72
- end
73
-
74
- it "should successfully get remote gem info" do
75
- gem = Source.new :name => "polisher", :source_type => "gem",
76
- :uri => "http://rubygems.org/downloads/polisher-0.3.gem"
77
- info = Polisher::GemAdapter.get_info(gem)
78
- info["name"].should == "polisher"
79
- end
80
-
81
- it "should raise error if get info target is invalid" do
82
- gem = Source.new :name => "polisher", :source_type => "gem",
83
- :uri => "http://invalid.uri/downloads/polisher-0.3.gem"
84
- lambda {
85
- Polisher::GemAdapter.get_info(gem)
86
- }.should raise_error(RuntimeError)
87
- end
88
-
89
- end
@@ -1,721 +0,0 @@
1
- # ruby gem polisher models 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
- describe "Polisher::Project" do
18
- before(:each) do
19
- FileUtils.rm_rf(ARTIFACTS_DIR) if File.directory? ARTIFACTS_DIR
20
- FileUtils.mkdir_p(ARTIFACTS_DIR)
21
- end
22
-
23
- after(:each) do
24
- FileUtils.rm_rf(ARTIFACTS_DIR) if File.directory? ARTIFACTS_DIR
25
- end
26
-
27
- it "should not be valid if name is missing" do
28
- project = Project.new :name => 'foo'
29
- project.should be_valid
30
-
31
- project.name = nil
32
- project.should_not be_valid
33
- end
34
-
35
- it "should not be valid if duplicate name exists" do
36
- Project.create! :name => 'dup-project-name-test'
37
- project = Project.new :name => 'dup-project-name-test'
38
- project.should_not be_valid
39
- end
40
-
41
- it "should provide access to all dependencies and dependent projects" do
42
- project1 = Project.create! :name => "project-dependency-tree1"
43
- project2 = Project.create! :name => "project-dependency-tree2"
44
- project3 = Project.create! :name => "project-dependency-tree3"
45
- project4 = Project.create! :name => "project-dependency-tree4"
46
- project5 = Project.create! :name => "project-dependency-tree5"
47
-
48
- pd1 = ProjectDependency.create! :project => project2, :depends_on_project => project1
49
- pd2 = ProjectDependency.create! :project => project3, :depends_on_project => project2
50
- pd3 = ProjectDependency.create! :project => project4, :depends_on_project => project2
51
- pd4 = ProjectDependency.create! :project => project4, :depends_on_project => project5
52
-
53
- deps = project1.dependencies
54
- deps.size.should == 0
55
- depts = project1.dependents
56
- depts.size.should == 1
57
- depts[0].project.id.should == project2.id
58
-
59
- deps = project2.dependencies
60
- deps.size.should == 1
61
- deps[0].depends_on_project.id.should == project1.id
62
- depts = project2.dependents
63
- depts.size.should == 2
64
- depts[0].project.id.should == project3.id
65
- depts[1].project.id.should == project4.id
66
-
67
- deps = project3.dependencies
68
- deps.size.should == 1
69
- deps[0].depends_on_project.id.should == project2.id
70
- depts = project3.dependents
71
- depts.size.should == 0
72
-
73
- deps = project4.dependencies
74
- deps.size.should == 2
75
- deps[0].depends_on_project.id.should == project2.id
76
- deps[1].depends_on_project.id.should == project5.id
77
- depts = project4.dependents
78
- depts.size.should == 0
79
-
80
- deps = project5.dependencies
81
- deps.size.should == 0
82
- depts = project5.dependents
83
- depts.size.should == 1
84
- depts[0].project.id.should == project4.id
85
- end
86
-
87
- it "should download all sources" do
88
- project = Project.create! :name => 'project-dl-test100'
89
-
90
- # see FIXME in Project::download_to
91
- source1 = Source.create! :name => 'jffi-spec', :uri => 'http://mo.morsi.org/files/jruby/jffi.spec', :source_type => 'spec'
92
- source2 = Source.create! :name => 'joni-spec', :uri => 'http://mo.morsi.org/files/jruby/joni.spec', :source_type => 'spec'
93
-
94
- ps1 = ProjectSourceVersion.create! :project => project, :source => source1
95
- ps2 = ProjectSourceVersion.create! :project => project, :source => source2, :project_version => "1.5"
96
-
97
- project.download_to :dir => ARTIFACTS_DIR
98
-
99
- File.size?(ARTIFACTS_DIR + '/joni.spec').should_not be_nil
100
- File.size?(ARTIFACTS_DIR + '/jffi.spec').should_not be_nil
101
- end
102
-
103
- it "should download all sources for specified version" do
104
- project = Project.new :name => 'project-dl-test100'
105
- source1 = Source.new :name => 'jffi-spec', :uri => 'http://mo.morsi.org/%{dir}/%{cluster}/jffi.spec', :source_type => 'spec'
106
- source2 = Source.new :name => 'joni-spec', :uri => 'http://mo.morsi.org/%{dir}/%{cluster}/joni.spec', :source_type => 'spec'
107
-
108
- ps1 = ProjectSourceVersion.new :project => project, :source => source1, :project_version => "1.6", :source_uri_params => "cluster=jruby;filetype=spec"
109
- ps2 = ProjectSourceVersion.new :project => project, :source => source2, :project_version => "1.5", :source_uri_params => "cluster=jruby;dir=files"
110
- project.project_source_versions << ps1 << ps2
111
-
112
- project.download_to :version => "1.5", :dir => ARTIFACTS_DIR
113
-
114
- File.size?(ARTIFACTS_DIR + '/joni.spec').should_not be_nil
115
- File.size?(ARTIFACTS_DIR + '/jffi.spec').should be_nil
116
- end
117
-
118
- it "should return all events for the specified version" do
119
- project = Project.new :name => 'project-dl-test100'
120
- event1 = Event.new :version_qualifier => "=", :version => "1.5"
121
- event2 = Event.new :version_qualifier => ">", :version => "1.6"
122
- project.events << event1 << event2
123
-
124
- events = project.events_for_version("1.5")
125
- events.size.should == 1
126
- events.include?(event1).should be_true
127
- events.include?(event2).should be_false
128
- end
129
-
130
- it "should return all project_source_versions for the specified version" do
131
- project = Project.new :name => 'project-dl-test100'
132
- source1 = Source.new :name => 'jffi-spec', :uri => 'http://mo.morsi.org/%{dir}/%{cluster}/jffi.spec', :source_type => 'spec'
133
- source2 = Source.new :name => 'joni-spec', :uri => 'http://mo.morsi.org/%{dir}/%{cluster}/joni.spec', :source_type => 'spec'
134
- source3 = Source.new :name => 'jruby-spec', :uri => 'http://mo.morsi.org/%{dir}/%{cluster}/jruby.spec', :source_type => 'spec'
135
-
136
- ps1 = ProjectSourceVersion.new :project => project, :source => source1, :project_version => '1.6', :source_uri_params => "cluster=jruby;filetype=spec"
137
- ps2 = ProjectSourceVersion.new :project => project, :source => source2, :project_version => "1.5", :source_uri_params => "cluster=jruby;dir=files"
138
- ps3 = ProjectSourceVersion.new :project => project, :source => source3, :source_uri_params => "cluster=jruby;filetype=spec"
139
- project.project_source_versions << ps1 << ps2 << ps3
140
-
141
- project_sources = project.project_source_versions_for_version("1.5")
142
- project_sources.size.should == 2
143
- project_sources.include?(ps1).should be_false
144
- project_sources.include?(ps2).should be_true
145
- project_sources.include?(ps3).should be_true
146
- end
147
-
148
- it "should return all sources for the specified version with formatted uris" do
149
- project = Project.new :name => 'project-dl-test100'
150
- source1 = Source.new :name => 'jffi-spec', :uri => 'http://mo.morsi.org/%{dir}/%{cluster}/jffi.spec', :source_type => 'spec'
151
- source2 = Source.new :name => 'joni-spec', :uri => 'http://mo.morsi.org/%{dir}/%{cluster}/joni.spec', :source_type => 'spec'
152
- source3 = Source.new :name => 'jruby-spec', :uri => 'http://mo.morsi.org/%{dir}/%{cluster}/jruby.spec', :source_type => 'spec'
153
-
154
- ps1 = ProjectSourceVersion.new :project => project, :source => source1, :project_version => "1.6", :source_uri_params => "cluster=jruby;filetype=spec"
155
- ps2 = ProjectSourceVersion.new :project => project, :source => source2, :project_version => "1.5", :source_uri_params => "cluster=jruby;dir=files"
156
- ps3 = ProjectSourceVersion.new :project => project, :source => source3, :source_uri_params => "cluster=jruby;dir=files"
157
- project.project_source_versions << ps1 << ps2 << ps3
158
-
159
- sources = project.sources_for_version("1.5")
160
- sources.size.should == 2
161
- sources.include?(source1).should be_false
162
- sources.include?(source2).should be_true
163
- sources.include?(source3).should be_true
164
-
165
- sources[0].uri.should == "http://mo.morsi.org/files/jruby/joni.spec"
166
- sources[1].uri.should == "http://mo.morsi.org/files/jruby/jruby.spec"
167
- end
168
-
169
- it "should provide access to primary source" do
170
- project = Project.create! :name => 'primary-source-project-test'
171
- source1 = Source.create!(:name => 'primary-source-test1', :source_type => 'file', :uri => 'http://foo1.foo')
172
- source2 = Source.create!(:name => 'primary-source-test2', :source_type => 'file', :uri => 'http://foo2.foo')
173
- project.sources << source1
174
- project.primary_source= source2
175
-
176
- primary_src = project.primary_source
177
- primary_src.should_not be_nil
178
- primary_src.name.should == source2.name
179
- end
180
-
181
- it "should provide access to all dependencies for the specified version" do
182
- project1 = Project.create! :name => "project-dependency-tree10"
183
- project2 = Project.create! :name => "project-dependency-tree20"
184
- project3 = Project.create! :name => "project-dependency-tree30"
185
- project4 = Project.create! :name => "project-dependency-tree40"
186
-
187
- pd1 = ProjectDependency.create! :project => project1, :depends_on_project => project2, :project_version => "1.0.0"
188
- pd2 = ProjectDependency.create! :project => project1, :depends_on_project => project3, :project_version => "2.0.0"
189
- pd2 = ProjectDependency.create! :project => project1, :depends_on_project => project4
190
-
191
- deps = project1.dependencies_for_version("1.0.0")
192
- deps.size.should == 2
193
- deps[0].depends_on_project.id.should == project2.id
194
- deps[1].depends_on_project.id.should == project4.id
195
- end
196
-
197
- it "should return all versions which the project is configured for" do
198
- project = Project.new :name => 'project-dl-test100'
199
- event1 = Event.new :version_qualifier => "=", :version => "1.5"
200
- event2 = Event.new :version_qualifier => ">", :version => "1.6"
201
- project.events << event1 << event2
202
-
203
- source1 = Source.new :name => 'jffi-spec', :uri => 'http://mo.morsi.org/%{dir}/%{cluster}/jffi.spec', :source_type => 'spec'
204
- source2 = Source.new :name => 'joni-spec', :uri => 'http://mo.morsi.org/%{dir}/%{cluster}/joni.spec', :source_type => 'spec'
205
- source3 = Source.new :name => 'jruby-spec', :uri => 'http://mo.morsi.org/%{dir}/%{cluster}/jruby.spec', :source_type => 'spec'
206
- ps1 = ProjectSourceVersion.new :project => project, :source => source1, :source_uri_params => "cluster=jruby;filetype=spec"
207
- ps2 = ProjectSourceVersion.new :project => project, :source => source2, :project_version => "1.5", :source_uri_params => "cluster=jruby;dir=files"
208
- ps3 = ProjectSourceVersion.new :project => project, :source => source3, :project_version => "1.7", :source_uri_params => "cluster=jruby;dir=files"
209
- project.project_source_versions << ps1 << ps2 << ps3
210
-
211
- projectd = Project.new :name => 'project-version-test99'
212
- project.project_dependencies << ProjectDependency.new(:project => project, :depends_on_project => projectd, :project_version => "9.9")
213
-
214
- versions = project.versions
215
- versions.size.should == 4
216
- versions.include?("1.5").should be_true
217
- versions.include?("1.6").should be_true
218
- versions.include?("1.7").should be_true
219
- versions.include?("9.9").should be_true
220
- end
221
-
222
- it "should trigger dependencies and events upon release" do
223
- project = Project.create :name => 'project-release-test-199'
224
-
225
- Event.create :project => project,
226
- :process => "project_released_test_handlerAAA",
227
- :version_qualifier => '=',
228
- :version => "5.6"
229
-
230
- Event.create :project => project,
231
- :process => "project_released_test_handlerBBB",
232
- :version_qualifier => '>',
233
- :version => "7.9"
234
-
235
- projectd1 = Project.create :name => 'project-release-test-299'
236
- Event.create :project => projectd1,
237
- :process => "project_released_test_handlerDDD"
238
- Event.create :project => projectd1,
239
- :process => "project_released_test_handlerEEE",
240
- :version_qualifier => "=",
241
- :version => "1.9"
242
-
243
- projectd2 = Project.create :name => 'project-release-test-399'
244
- Event.create :project => projectd2,
245
- :process => "project_released_test_handlerFFF",
246
- :version_qualifier => "=",
247
- :version => "1.9"
248
- Event.create :project => projectd2,
249
- :process => "project_released_test_handlerGGG",
250
- :version_qualifier => "=",
251
- :version => "6.5"
252
-
253
- projectd3 = Project.create :name => 'project-release-test-499'
254
- Event.create :project => projectd3,
255
- :process => "project_released_test_handlerCCC"
256
-
257
- pd1 = ProjectDependency.new :project => project, :depends_on_project => projectd1, :depends_on_project_params => "jim=bo;john=mark"
258
- pd2 = ProjectDependency.new :project => project, :depends_on_project => projectd2, :project_version => "5.6", :depends_on_project_version => "6.5"
259
- pd3 = ProjectDependency.new :project => project, :depends_on_project => projectd3, :project_version => "7.9"
260
- project.project_dependencies << pd1 << pd2 << pd3
261
-
262
- project.released_version("5.6", :joe => 'bob', :sam => 'sue')
263
-
264
- $project_released_test_handler_flags.include?('AAA').should be_true
265
- $project_released_test_handler_flags.include?('BBB').should be_false
266
- $project_released_test_handler_flags.include?('CCC').should be_false
267
- $project_released_test_handler_flags.include?('DDD').should be_true
268
- $project_released_test_handler_flags.include?('EEE').should be_true
269
- $project_released_test_handler_flags.include?('FFF').should be_false
270
- $project_released_test_handler_flags.include?('GGG').should be_true
271
- $project_released_test_handler_flags.include?('joe=bob').should be_true
272
- $project_released_test_handler_flags.include?('sam=sue').should be_true
273
- $project_released_test_handler_flags.include?('jim=bo').should be_true
274
- $project_released_test_handler_flags.include?('john=mark').should be_true
275
- end
276
- end
277
-
278
- describe "Polisher::Source" do
279
- before(:each) do
280
- FileUtils.rm_rf(ARTIFACTS_DIR) if File.directory? ARTIFACTS_DIR
281
- FileUtils.mkdir_p(ARTIFACTS_DIR)
282
- end
283
-
284
- after(:each) do
285
- FileUtils.rm_rf(ARTIFACTS_DIR) if File.directory? ARTIFACTS_DIR
286
- end
287
-
288
- it "should not be valid if name, source_type, or uri is missing or invalid" do
289
- source = Source.new :uri => 'uri', :name => "foo", :source_type => "gem"
290
- source.should be_valid
291
-
292
- source.uri = nil
293
- source.should_not be_valid
294
- source.uri = 'uri'
295
-
296
- source.source_type = nil
297
- source.should_not be_valid
298
- source.source_type = 'bar'
299
- source.should_not be_valid
300
- source.source_type = 'file'
301
-
302
- source.name = nil
303
- source.should_not be_valid
304
- end
305
-
306
- it "should not be valid if name or uri is not unique in scope" do
307
- source1 = Source.create! :uri => 'uri', :name => "foo", :source_type => "gem"
308
- source2 = Source.new :uri => 'uri', :name => "bar", :source_type => "archive"
309
- source2.should_not be_valid
310
-
311
- source3 = Source.new :uri => 'zaz', :name => "foo", :source_type => "archive"
312
- source3.should_not be_valid
313
- end
314
-
315
- it "should return filename generated from uri" do
316
- source = Source.new(
317
- :uri => 'http://mo.morsi.org/files/jruby/joni-123.spec?addition=foo&params=bar',
318
- :name => "joni-spec", :source_type => "spec")
319
- source.filename.should == "joni-123.spec"
320
- end
321
-
322
- it "should return all project_source_versions for the specified version" do
323
- project1 = Project.new :name => 'project-src-p100'
324
- project2 = Project.new :name => 'project-src-p101'
325
- project3 = Project.new :name => 'project-src-p102'
326
- source = Source.new :name => 'jffi-spec', :uri => 'http://mo.morsi.org/%{dir}/%{cluster}/jffi.spec', :source_type => 'spec'
327
-
328
- ps1 = ProjectSourceVersion.new :project => project1, :source => source, :source_uri_params => "cluster=jruby;filetype=spec"
329
- ps2 = ProjectSourceVersion.new :project => project2, :source => source, :project_version => "1.5", :source_uri_params => "cluster=jruby;dir=files"
330
- ps3 = ProjectSourceVersion.new :project => project3, :source => source, :project_version => "1.6", :source_uri_params => "cluster=jruby;dir=files"
331
- source.project_source_versions << ps1 << ps2
332
-
333
- project_sources = source.project_source_versions_for_version("1.5")
334
- project_sources.size.should == 2
335
- project_sources.include?(ps1).should be_true
336
- project_sources.include?(ps2).should be_true
337
- project_sources.include?(ps3).should be_false
338
- end
339
-
340
- it "should return all projects for the specified version" do
341
- project1 = Project.new :name => 'project-src-p100'
342
- project2 = Project.new :name => 'project-src-p101'
343
- project3 = Project.new :name => 'project-src-p102'
344
- source = Source.new :name => 'jffi-spec', :uri => 'http://mo.morsi.org/%{dir}/%{cluster}/jffi.spec', :source_type => 'spec'
345
-
346
- ps1 = ProjectSourceVersion.new :project => project1, :source => source, :source_uri_params => "cluster=jruby;filetype=spec"
347
- ps2 = ProjectSourceVersion.new :project => project2, :source => source, :source_version => "1.5", :source_uri_params => "cluster=jruby;dir=files"
348
- ps3 = ProjectSourceVersion.new :project => project3, :source => source, :source_version => "1.6", :source_uri_params => "cluster=jruby;dir=files"
349
- source.project_source_versions << ps1 << ps2 << ps3
350
-
351
- projects = source.project_source_versions_for_version("1.5")
352
- projects.size.should == 2
353
- projects.collect { |p| p.source_version }.include?(nil).should be_true
354
- projects.collect { |p| p.source_version }.include?("1.5").should be_true
355
- projects.collect { |p| p.source_version }.include?("1.6").should be_false
356
-
357
- projects.collect { |p| p.project.name }.include?("project-src-p100").should be_true
358
- projects.collect { |p| p.project.name }.include?("project-src-p101").should be_true
359
- projects.collect { |p| p.project.name }.include?("project-src-p102").should be_false
360
- end
361
-
362
- it "should return all versions which the source is configured for" do
363
- project1 = Project.new :name => 'project-src-p100'
364
- project2 = Project.new :name => 'project-src-p101'
365
- project3 = Project.new :name => 'project-src-p102'
366
- source = Source.new :name => 'jffi-spec', :uri => 'http://mo.morsi.org/%{dir}/%{cluster}/jffi.spec', :source_type => 'spec'
367
-
368
- ps1 = ProjectSourceVersion.new :project => project1, :source => source, :source_uri_params => "cluster=jruby;filetype=spec"
369
- ps2 = ProjectSourceVersion.new :project => project2, :source => source, :source_version => "1.5", :source_uri_params => "cluster=jruby;dir=files"
370
- ps3 = ProjectSourceVersion.new :project => project3, :source => source, :source_version => "1.6", :source_uri_params => "cluster=jruby;dir=files"
371
- source.project_source_versions << ps1 << ps2 << ps3
372
-
373
- versions = source.versions
374
- versions.size.should == 2
375
- versions.include?("1.5").should be_true
376
- versions.include?("1.6").should be_true
377
- end
378
-
379
- it "should format the uri w/ the specified variables" do
380
- source = Source.new :uri => "http://%{var1}.%{var2}/%{another}?%{yet_another}=%{even_more}&%{last}"
381
- source.format_uri! :var1 => 'val1', :var2 => 'val2',
382
- :another => 'foo', :yet_another => 'bar',
383
- :even_more => 'something', :last => '123'
384
-
385
- source.uri.should == "http://val1.val2/foo?bar=something&123"
386
- end
387
-
388
- it "should be downloadable" do
389
- source = Source.new(
390
- :uri => 'http://mo.morsi.org/files/jruby/joni.spec',
391
- :name => "joni-spec", :source_type => "spec")
392
- path = source.download_to(:dir => ARTIFACTS_DIR)
393
- File.size?(ARTIFACTS_DIR + '/joni.spec').should_not be_nil
394
- FileUtils.rm(ARTIFACTS_DIR + '/joni.spec')
395
- path.should == ARTIFACTS_DIR + '/joni.spec'
396
-
397
- source.download_to(:path => ARTIFACTS_DIR + '/joni.spec')
398
- File.size?(ARTIFACTS_DIR + '/joni.spec').should_not be_nil
399
- end
400
-
401
- it "should permit a parameterized download" do
402
- source = Source.new(
403
- :uri => 'http://mo.morsi.org/files/%{group}/%{name}.spec',
404
- :name => "joni-spec", :source_type => 'spec')
405
- path = source.download_to(:dir => ARTIFACTS_DIR, :group => "jruby", :name => "joni")
406
- File.size?(ARTIFACTS_DIR + '/joni.spec').should_not be_nil
407
- FileUtils.rm(ARTIFACTS_DIR + '/joni.spec')
408
- path.should == ARTIFACTS_DIR + '/joni.spec'
409
-
410
- source.download_to(:path => ARTIFACTS_DIR + '/joni.spec')
411
- File.size?(ARTIFACTS_DIR + '/joni.spec').should_not be_nil
412
- end
413
-
414
- it "should raise an exception if download source uri or destination path is invalid" do
415
- source = Source.new(
416
- :uri => 'http://invalid.uri',
417
- :name => 'invalid-source1', :source_type => 'file')
418
- lambda {
419
- path = source.download_to(:dir => ARTIFACTS_DIR)
420
- }.should raise_error(RuntimeError)
421
-
422
- source = Source.new(
423
- :uri => 'http://mo.morsi.org/files/jruby/joni.spec',
424
- :name => 'invalid-source2', :source_type => 'spec')
425
- lambda {
426
- path = source.download_to(:dir => '/')
427
- }.should raise_error(RuntimeError)
428
-
429
- lambda {
430
- path = source.download_to(:dir => '/nonexistantfoobar')
431
- }.should raise_error(RuntimeError)
432
- end
433
- end
434
-
435
- describe "Polisher::ProjectSourceVersion" do
436
-
437
- it "should default primary_source to false" do
438
- project = Project.create! :name => 'project-source-valid-testproj0'
439
- source = Source.create! :name => 'project-source-valid-testsource0',
440
- :uri => 'http://presvts234', :source_type => 'file'
441
- ps = ProjectSourceVersion.create! :project => project, :source => source
442
- ps.primary_source.should be_false
443
- end
444
-
445
- it "should default versions to nil" do
446
- project = Project.create! :name => 'project-source-valid-testproj10'
447
- source = Source.create! :name => 'project-source-valid-testsource10',
448
- :uri => 'http://presvts098', :source_type => 'file'
449
- ps = ProjectSourceVersion.create! :project => project, :source => source, :project_version => "", :source_version => ""
450
- ps.project_version.should be_nil
451
- ps.source_version.should be_nil
452
- end
453
-
454
- it "should not be valid if a project id/version is associated w/ a source multiple times" do
455
- project = Project.create! :name => 'project-source-valid-testproj1'
456
- source = Source.create! :name => 'project-source-valid-testsource1',
457
- :uri => 'http://presvts581', :source_type => 'file'
458
-
459
- ps1 = ProjectSourceVersion.create! :project => project, :source => source, :project_version => '1.6'
460
- ps2 = ProjectSourceVersion.new :project => project, :source => source, :project_version => '1.6'
461
-
462
- ps2.valid?.should be_false
463
- end
464
-
465
- it "should not be valid if a project id/version is associated w/ multiple primary sources" do
466
- project = Project.create! :name => 'project-source-valid-testproj2'
467
- source1 = Source.create! :name => 'project-source-valid-testsource100',
468
- :uri => 'http://presvts690', :source_type => 'file'
469
- source2 = Source.create! :name => 'project-source-valid-testsource200',
470
- :uri => 'http://presvts456', :source_type => 'file'
471
-
472
- ps1 = ProjectSourceVersion.create! :project => project, :source => source1, :project_version => '1.6',
473
- :primary_source => true
474
-
475
- ps2 = ProjectSourceVersion.new :project => project, :source => source2, :project_version => '1.6',
476
- :primary_source => true
477
-
478
- ps2.valid?.should be_false
479
- end
480
-
481
- end
482
-
483
- describe "Polisher::ProjectDependency" do
484
-
485
- it "should default versions to nil" do
486
- project1 = Project.create! :name => 'project-dep-valid-testproj10'
487
- project2 = Project.create! :name => 'project-dep-valid-testproj20'
488
-
489
- pd = ProjectDependency.create! :project => project1, :depends_on_project => project2
490
- pd.project_version.should be_nil
491
- pd.depends_on_project_version.should be_nil
492
- end
493
-
494
- it "should not be valid if missing project or depends_on_project" do
495
- project1 = Project.create! :name => 'project-dep-valid-testproj30'
496
- project2 = Project.create! :name => 'project-dep-valid-testproj40'
497
-
498
- pd = ProjectDependency.new
499
- pd.should_not be_valid
500
-
501
-
502
- pd = ProjectDependency.new :project => project1
503
- pd.should_not be_valid
504
-
505
- pd = ProjectDependency.new :depends_on_project => project2
506
- pd.should_not be_valid
507
-
508
- pd = ProjectDependency.new :project => project1, :depends_on_project => project2
509
- pd.should be_valid
510
- end
511
-
512
- it "should not be valid if project/depends_on_project/project_version/depends_on_project_version are not unique" do
513
- project1 = Project.create! :name => 'project-dep-valid-testproj50'
514
- project2 = Project.create! :name => 'project-dep-valid-testproj60'
515
-
516
- pd = ProjectDependency.create! :project => project1, :depends_on_project => project2, :project_version => "1.0.0", :depends_on_project_version => "2.0.1"
517
-
518
- pd2 = ProjectDependency.new :project => project1, :depends_on_project => project2, :project_version => "1.0.0", :depends_on_project_version => "2.0.1"
519
- pd2.should_not be_valid
520
-
521
- pd2.depends_on_project_version = "2.0.2"
522
- pd2.should be_valid
523
- end
524
-
525
- end
526
-
527
- describe "Polisher::Event" do
528
-
529
- it "should return list of supported event handlers" do
530
- processes = Event::processes
531
- processes.size.should == 3
532
- processes.include?("download_sources").should be_true
533
- processes.include?("create_rpm_package").should be_true
534
- processes.include?("update_yum_repo").should be_true
535
- end
536
-
537
- it "should not be valid if process is missing" do
538
- project = Project.create! :name => 'valid-event-test-project0'
539
- event = Event.new :project_id => project.id, :process => 'create_repo'
540
- event.should be_valid
541
-
542
- event.process = nil
543
- event.should_not be_valid
544
- end
545
-
546
- it "should not be valid if project is missing" do
547
- project = Project.create! :name => 'valid-event-test-project1'
548
- event = Event.new :process => 'create_repo'
549
- event.should_not be_valid
550
- event.project = project
551
- event.should be_valid
552
- end
553
-
554
- it "should not be valid with invalid version qualifier" do
555
- project = Project.create! :name => 'valid-event-test-project2'
556
-
557
- event = Event.new :project_id => project.id, :process => 'create_repo', :version_qualifier => ">", :version => 5
558
- event.should be_valid
559
-
560
- event.version_qualifier = '=='
561
- event.should_not be_valid
562
- end
563
-
564
- it "should not be valid if version/qualifier are not both present or nil" do
565
- project = Project.create! :name => 'valid-event-test-project3'
566
-
567
- event = Event.new :project_id => project.id, :process => 'create_repo', :version_qualifier => ">"
568
- event.should_not be_valid
569
-
570
- event = Event.new :project_id => project.id, :process => 'create_repo', :version => 5
571
- event.should_not be_valid
572
-
573
- event = Event.new :project_id => project.id, :process => 'create_repo', :version => 5, :version_qualifier => '<='
574
- event.should be_valid
575
- end
576
-
577
- it "should correctly resolve version qualifiers" do
578
- event = Event.new :version_qualifier => nil, :version => "5"
579
- event.applies_to_version?('1.1').should be(true)
580
- event.applies_to_version?('1.5.3').should be(true)
581
-
582
- event = Event.new :version_qualifier => "=", :version => "5.3"
583
- event.applies_to_version?('1.2').should be(false)
584
- event.applies_to_version?('5.3').should be(true)
585
- event.applies_to_version?('5.3.0').should be(false)
586
- event.applies_to_version?('5.3.1').should be(false)
587
- event.applies_to_version?('7.9').should be(false)
588
-
589
- event = Event.new :version_qualifier => ">", :version => "1.9.2"
590
- event.applies_to_version?('1.8.1').should be(false)
591
- event.applies_to_version?('1.9.1').should be(false)
592
- event.applies_to_version?('1.9.3').should be(true)
593
- event.applies_to_version?('2.0').should be(true)
594
-
595
- event = Event.new :version_qualifier => "<", :version => "0.6"
596
- event.applies_to_version?('0.5').should be(true)
597
- event.applies_to_version?('0.6').should be(false)
598
- event.applies_to_version?('0.7').should be(false)
599
-
600
- event = Event.new :version_qualifier => ">=", :version => "1.9"
601
- event.applies_to_version?('1.8').should be(false)
602
- event.applies_to_version?('1.9').should be(true)
603
- event.applies_to_version?('2.0').should be(true)
604
-
605
- event = Event.new :version_qualifier => "<=", :version => "0.6.4"
606
- event.applies_to_version?('0.5.2').should be(true)
607
- event.applies_to_version?('0.6.1').should be(true)
608
- event.applies_to_version?('0.6.6').should be(false)
609
- event.applies_to_version?('0.7.4').should be(false)
610
- end
611
-
612
- it "should raise error if trying to compare invalid versions" do
613
- event = Event.new
614
-
615
- # nil event version and version_qualifier is permitted
616
- #lambda {
617
- # event.applies_to_version?('0.5.2')
618
- #}.should raise_error(ArgumentError)
619
-
620
- event.version = '0.7'
621
- lambda {
622
- event.applies_to_version?(111)
623
- }.should raise_error(ArgumentError)
624
- end
625
-
626
- it "should successfully run event process" do
627
- project = Project.new :name => "foobar"
628
- event = Event.new :project => project, :process => "test_event_run_method"
629
- event.run(:version => "5.0", :key1 => "val1", :some => "thing", :answer => 42)
630
-
631
- $test_event_run_hash[:event].should_not be_nil
632
- $test_event_run_hash[:project].should_not be_nil
633
- $test_event_run_hash[:version].should_not be_nil
634
- $test_event_run_hash[:key1].should_not be_nil
635
- $test_event_run_hash[:some].should_not be_nil
636
- $test_event_run_hash[:answer].should_not be_nil
637
-
638
- $test_event_run_hash[:event].process == "test_event_run_method"
639
- $test_event_run_hash[:project].name.should == "foobar"
640
- $test_event_run_hash[:version].should == "5.0"
641
- $test_event_run_hash[:key1].should == "val1"
642
- $test_event_run_hash[:some].should == "thing"
643
- $test_event_run_hash[:answer].should == 42
644
- end
645
-
646
- it "should raise an exception if running event w/out specifying version" do
647
- project = Project.new :name => "foobar"
648
- event = Event.new :project => project, :process => "test_event_run_method"
649
- lambda {
650
- event.run
651
- }.should raise_error(ArgumentError)
652
- end
653
-
654
- it "should raise an exception if running event process that doesn't correspond to a method" do
655
- project = Project.new :name => "foobar"
656
- event = Event.new :project => project, :process => "non_existant_method"
657
- lambda {
658
- event.run :version => "5"
659
- }.should raise_error(ArgumentError)
660
- end
661
-
662
- it "should raise an exception if event process being run does" do
663
- project = Project.new :name => "foobar"
664
- event = Event.new :project => project, :process => "error_generating_method"
665
- lambda {
666
- event.run :version => "5"
667
- }.should raise_error(RuntimeError)
668
- end
669
- end
670
-
671
- # prolly should fixure out a better way todo this
672
- $test_event_run_hash = {}
673
-
674
- # helper method, invoked in Event::run spec
675
- def test_event_run_method(event, version, args = {})
676
- $test_event_run_hash[:event] = event
677
- $test_event_run_hash[:project] = event.project
678
- $test_event_run_hash[:version] = version
679
- $test_event_run_hash[:key1] = args[:key1]
680
- $test_event_run_hash[:some] = args[:some]
681
- $test_event_run_hash[:answer] = args[:answer]
682
- end
683
-
684
- def error_generating_method(event, version, args = {})
685
- raise RuntimeError
686
- end
687
-
688
- $project_released_test_handler_flags = []
689
-
690
- def project_released_test_handlerAAA(event, version, args = {})
691
- $project_released_test_handler_flags << "AAA"
692
- end
693
-
694
- def project_released_test_handlerBBB(event, version, args = {})
695
- $project_released_test_handler_flags << "BBB"
696
- end
697
-
698
- def project_released_test_handlerCCC(event, version, args = {})
699
- $project_released_test_handler_flags << "CCC"
700
- end
701
-
702
- def project_released_test_handlerDDD(event, version, args = {})
703
- $project_released_test_handler_flags << "DDD"
704
-
705
- args.each { |k,v|
706
- $project_released_test_handler_flags << "#{k}=#{v}"
707
- }
708
- end
709
-
710
- def project_released_test_handlerEEE(event, version, args = {})
711
- $project_released_test_handler_flags << "EEE"
712
- end
713
-
714
- def project_released_test_handlerFFF(event, version, args = {})
715
- $project_released_test_handler_flags << "FFF"
716
- end
717
-
718
- def project_released_test_handlerGGG(event, version, args = {})
719
- $project_released_test_handler_flags << "GGG"
720
- end
721
-