foca-integrity 0.1.9.2 → 0.1.9.3

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.
@@ -36,18 +36,6 @@ class BuildTest < Test::Unit::TestCase
36
36
  @build.successful = false
37
37
  @build.status.should be(:failed)
38
38
  end
39
-
40
- test "deprecated properties" do
41
- silence_warnings {
42
- @build.short_commit_identifier.should == @build.commit.short_identifier
43
- @build.commit_identifier.should == @build.commit.identifier
44
- @build.commit_author.should == @build.commit.author
45
- @build.commit_message.should == @build.commit.message
46
- @build.commited_at.should == @build.commit.committed_at
47
- @build.project_id.should == @build.commit.project_id
48
- @build.should respond_to(:commit_metadata)
49
- }
50
- end
51
39
  end
52
40
 
53
41
  describe "Pending builds" do
@@ -32,6 +32,8 @@ class CommitTest < Test::Unit::TestCase
32
32
  commit.author.name.should == "Nicolás Sanguinetti"
33
33
  commit.author.email.should == "contacto@nicolassanguinetti.info"
34
34
  commit.author.full.should == "Nicolás Sanguinetti <contacto@nicolassanguinetti.info>"
35
+
36
+ Commit.gen(:author => nil).author.to_s.should =~ /not loaded/
35
37
  end
36
38
 
37
39
  it "raises ArgumentError with invalid author" do
@@ -41,6 +43,8 @@ class CommitTest < Test::Unit::TestCase
41
43
  it "has a commit message" do
42
44
  commit = Commit.gen(:message => "This commit rocks")
43
45
  commit.message.should == "This commit rocks"
46
+
47
+ Commit.gen(:message => nil).message.should =~ /not loaded/
44
48
  end
45
49
 
46
50
  it "has a commit date" do
@@ -24,13 +24,14 @@ class MigrationsTest < Test::Unit::TestCase
24
24
 
25
25
  before(:each) do
26
26
  [Project, Build, Commit, Notifier].each(&:auto_migrate_down!)
27
+ database_adapter.execute("DROP TABLE migration_info")
27
28
  assert !table_exists?("migration_info") # just to be sure
28
29
  end
29
30
 
30
31
  test "upgrading a pre migration database" do
31
32
  capture_stdout { Integrity.migrate_db }
32
33
 
33
- current_migrations.should == ["initial", "add_commits"]
34
+ current_migrations.should == ["initial", "add_commits", "add_enabled_column"]
34
35
  assert table_exists?("integrity_projects")
35
36
  assert table_exists?("integrity_builds")
36
37
  assert table_exists?("integrity_notifiers")
@@ -41,7 +42,7 @@ class MigrationsTest < Test::Unit::TestCase
41
42
  load_initial_migration_fixture
42
43
 
43
44
  capture_stdout { Integrity.migrate_db }
44
- current_migrations.should == ["initial", "add_commits"]
45
+ current_migrations.should == ["initial", "add_commits", "add_enabled_column"]
45
46
 
46
47
  sinatra = Project.first(:name => "Sinatra")
47
48
  sinatra.should have(1).commits
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + "/../../helpers"
2
+
3
+ class BaseNotifierTest < Test::Unit::TestCase
4
+ before(:each) do
5
+ @commit = Commit.gen(:successful)
6
+ @base = Notifier::Base.new(@commit, {})
7
+ end
8
+
9
+ it "requires to implement .to_haml" do
10
+ assert_raise(NotImplementedError) { Notifier::Base.to_haml }
11
+ end
12
+
13
+ it "requires to implement #deliver!" do
14
+ assert_raise(NotImplementedError) { @base.deliver! }
15
+ end
16
+
17
+ it "provides a short message" do
18
+ assert_equal "Built #{@commit.short_identifier} successfully", @base.short_message
19
+ end
20
+
21
+ it "provides a full message" do
22
+ assert @base.full_message.include?("Commit Message: #{@commit.message}")
23
+ assert @base.full_message.include?("Commit Date: #{@commit.committed_at}")
24
+ assert @base.full_message.include?("Commit Author: #{@commit.author.name}")
25
+ assert @base.full_message.include?("Link: #{@base.commit_url}")
26
+ assert @base.full_message.include?("Build Output")
27
+ assert @base.full_message.include?(@commit.build.output)
28
+ end
29
+
30
+ it "provides a commit url" do
31
+ assert_equal "http://localhost:8910/#{@commit.project.name}" +
32
+ "/commits/#{@commit.identifier}", @base.commit_url
33
+ end
34
+
35
+ test "deprecated methods" do
36
+ silence_warnings {
37
+ assert_equal @base.commit, @base.build
38
+ assert_equal @base.commit_url, @base.build_url
39
+ assert_equal @base.send(:stripped_commit_output),
40
+ @base.send(:stripped_build_output)
41
+ }
42
+ end
43
+ end
@@ -1,11 +1,6 @@
1
1
  require File.dirname(__FILE__) + "/../helpers"
2
2
 
3
3
  class NotifierTest < Test::Unit::TestCase
4
- test "deprecated methods" do
5
- Notifier::Base.new(Build.gen, {}).should respond_to(:build)
6
- Notifier::Base.new(Build.gen, {}).should respond_to(:build_url)
7
- end
8
-
9
4
  specify "IRC fixture is valid and can be saved" do
10
5
  lambda do
11
6
  Notifier.generate(:irc).tap do |project|
@@ -71,58 +66,32 @@ class NotifierTest < Test::Unit::TestCase
71
66
  end
72
67
  end
73
68
 
74
- it "knows which notifiers are available" do
75
- Notifier.gen(:irc)
76
- Notifier.gen(:twitter)
77
- Notifier.should have(2).available
78
- Notifier.available.should include(Integrity::Notifier::IRC)
79
- Notifier.available.should include(Integrity::Notifier::Twitter)
80
- end
69
+ describe "Registering a notifier" do
70
+ it "registers given notifier class" do
71
+ load "helpers/acceptance/textfile_notifier.rb"
81
72
 
82
- it "knows how to notify the world of a build" do
83
- irc = Notifier.generate(:irc)
84
- build = Integrity::Build.generate
85
- Notifier::IRC.expects(:notify_of_build).with(build, irc.config)
86
- irc.notify_of_build(build)
87
- end
73
+ Notifier.register(Integrity::Notifier::Textfile)
88
74
 
89
- describe "Enabling a list of notifiers for a project" do
90
- it "creates new notifiers for the project" do
91
- project = Project.generate
92
- lambda do
93
- project.enable_notifiers(["IRC", "Twitter"],
94
- {"IRC" => {"uri" => "irc://irc.freenode.net/integrity"},
95
- "Twitter" => {"username" => "john"}})
96
- end.should change(project.notifiers, :count).from(0).to(2)
75
+ assert_equal Integrity::Notifier::Textfile,
76
+ Notifier.available["Textfile"]
97
77
  end
98
78
 
99
- it "deletes all of previous notifiers" do
100
- project = Project.generate(:notifiers => [Notifier.gen(:irc), Notifier.gen(:twitter)])
101
- lambda do
102
- project.enable_notifiers("IRC", {"IRC" => {:foo => "bar"}})
103
- project.reload
104
- end.should change(project.notifiers, :count).from(2).to(1)
105
- end
79
+ it "raises ArgumentError if given class is not a valid notifier" do
80
+ assert_raise(ArgumentError) {
81
+ Notifier.register(Class.new)
82
+ }
106
83
 
107
- it "does nothing if given nil as the list of notifiers to enable" do
108
- lambda { Project.gen.enable_notifiers(nil, {}) }.should_not change(Notifier, :count)
84
+ assert Notifier.available.empty?
109
85
  end
86
+ end
110
87
 
111
- it "doesn't destroy any of the other notifiers that exist for other projects" do
112
- irc = Notifier.generate(:irc)
113
-
114
- project = Project.gen
115
- project.enable_notifiers("IRC", {"IRC" => irc.config})
88
+ it "knows how to notify the world of a build" do
89
+ irc = Notifier.gen(:irc)
90
+ Notifier.register(Integrity::Notifier::IRC)
91
+ build = Build.gen
116
92
 
117
- lambda do
118
- Project.gen.enable_notifiers("IRC", {"IRC" => irc.config})
119
- end.should_not change(project.notifiers, :count)
120
- end
121
- end
93
+ mock(Notifier::IRC).notify_of_build(build, irc.config) { nil }
122
94
 
123
- it "requires notifier classes to implement Notifier.to_haml and Notifier#deliver!" do
124
- class Blah < Notifier::Base; end
125
- lambda { Blah.to_haml }.should raise_error(NoMethodError)
126
- lambda { Blah.new(Build.gen, {}).deliver! }.should raise_error(NoMethodError)
95
+ irc.notify_of_build(build)
127
96
  end
128
97
  end
@@ -110,13 +110,6 @@ class ProjectTest < Test::Unit::TestCase
110
110
  project = Project.gen(:commits => commits)
111
111
  project.last_commit.should == commits.sort_by {|c| c.committed_at }.last
112
112
  end
113
-
114
- test "deprecated properties" do
115
- silence_warnings {
116
- @project.last_build.should == @project.last_commit
117
- @project.previous_builds.should == @project.previous_commits
118
- }
119
- end
120
113
  end
121
114
 
122
115
  describe "Validation" do
@@ -220,31 +213,113 @@ class ProjectTest < Test::Unit::TestCase
220
213
  end
221
214
  end
222
215
 
216
+ describe "When updating its notifiers" do
217
+ setup do
218
+ twitter = Notifier.gen(:twitter, :enabled => true)
219
+ irc = Notifier.gen(:irc, :enabled => false)
220
+
221
+ @project = Project.gen(:notifiers => [twitter, irc])
222
+ end
223
+
224
+ it "creates and enable the given notifiers" do
225
+ Notifier.all.destroy!
226
+
227
+ project = Project.gen
228
+ project.update_notifiers(["IRC", "Twitter"],
229
+ {"IRC" => {"uri" => "irc://irc.freenode.net/integrity"},
230
+ "Twitter" => {"username" => "john"}})
231
+
232
+ assert_equal 2, Notifier.count
233
+ assert_equal 2, project.enabled_notifiers.count
234
+ assert_equal "IRC", project.notifiers.first.name
235
+ assert_equal "Twitter", project.notifiers.last.name
236
+
237
+ project.update_notifiers(["Twitter"],
238
+ {"IRC" => {"uri" => "irc://irc.freenode.net/integrity"},
239
+ "Twitter" => {"username" => "john"}})
240
+
241
+ assert_equal 2, Notifier.count
242
+ assert ! project.notifies?("IRC")
243
+ assert project.notifies?("Twitter")
244
+ end
245
+
246
+ it "creates notifiers present in config even when they're disabled" do
247
+ @project.update_notifiers(["IRC"],
248
+ {"IRC" => {"uri" => "irc://irc.freenode.net/integrity"},
249
+ "Twitter" => {"username" => "john"}})
250
+
251
+ assert_equal 2, @project.notifiers.count
252
+ end
253
+
254
+ it "disables notifiers that are not included in the list" do
255
+ @project.update_notifiers(["IRC"],
256
+ {"IRC" => {"uri" => "irc://irc.freenode.net/integrity"},
257
+ "Twitter" => {"username" => "john"}})
258
+
259
+ @project.update_notifiers(["IRC"],
260
+ {"IRC" => {"uri" => "irc://irc.freenode.net/integrity"}})
261
+
262
+ assert ! @project.notifiers.first(:name => "Twitter").enabled?
263
+ assert @project.notifiers.first(:name => "IRC").enabled?
264
+ end
265
+
266
+ it "preserves config of notifiers that are being disabled" do
267
+ @project.update_notifiers(["IRC"],
268
+ {"IRC" => {"uri" => "irc://irc.freenode.net/integrity"},
269
+ "Twitter" => {"username" => "john"}})
270
+
271
+ assert_equal "john",
272
+ @project.notifiers.first(:name => "Twitter").config["username"]
273
+ end
274
+
275
+ it "does nothing if given nil as the list of notifiers to enable" do
276
+ lambda { Project.gen.update_notifiers(nil, {}) }.should_not change(Notifier, :count)
277
+ end
278
+
279
+ it "doesn't destroy any of the other notifiers that exist for other projects" do
280
+ irc = Notifier.generate(:irc)
281
+
282
+ project = Project.gen
283
+ project.update_notifiers("IRC", {"IRC" => irc.config})
284
+
285
+ lambda {
286
+ Project.gen.update_notifiers("IRC", {"IRC" => irc.config})
287
+ }.should_not change(project.notifiers, :count)
288
+ end
289
+ end
290
+
223
291
  describe "When retrieving state about its notifier" do
224
292
  before(:each) do
225
- @project = Project.generate
293
+ @project = Project.gen
226
294
  @irc = Notifier.generate(:irc)
227
295
  end
228
296
 
297
+ it "knows which notifiers are enabled" do
298
+ notifiers = [Notifier.gen(:irc, :enabled => false),
299
+ Notifier.gen(:twitter, :enabled => true)]
300
+ project = Project.gen(:notifiers => notifiers)
301
+
302
+ assert_equal 1, project.enabled_notifiers.size
303
+ end
304
+
229
305
  specify "#config_for returns given notifier's configuration" do
230
306
  @project.update_attributes(:notifiers => [@irc])
231
307
  @project.config_for("IRC").should == {:uri => "irc://irc.freenode.net/integrity"}
232
308
  end
233
309
 
234
- specify "#config_for returns an empty hash if no such notifier" do
310
+ specify "#config_for returns an empty hash for unknown notifier" do
235
311
  @project.config_for("IRC").should == {}
236
312
  end
237
313
 
238
- specify "#notifies? is true if it uses the given notifier" do
239
- @project.update_attributes(:notifiers => [@irc])
240
- @project.notifies?("IRC").should == true
241
- end
314
+ specify "#notifies? is true if the notifier exists and is enabled" do
315
+ assert ! @project.notifies?("UndefinedNotifier")
242
316
 
243
- specify "#notifies? is false if it doesnt use the given notifier" do
244
- @project.update_attributes(:notifiers => [])
317
+ @project.update_attributes(:notifiers =>
318
+ [ Notifier.gen(:irc, :enabled => true),
319
+ Notifier.gen(:twitter, :enabled => false) ])
245
320
 
246
- @project.notifies?("IRC").should == false
247
- @project.notifies?("UndefinedNotifier").should == false
321
+ assert @project.notifies?("IRC")
322
+ assert ! @project.notifies?("Twitter")
248
323
  end
249
324
  end
250
325
 
@@ -277,13 +352,12 @@ class ProjectTest < Test::Unit::TestCase
277
352
  }.should change(Commit, :count).by(1)
278
353
 
279
354
  build = Build.all.last
280
- build.commit.should be(@project.last_commit)
355
+ build.commit.should == @project.last_commit
281
356
 
282
357
  @project.last_commit.should be_pending
283
- @project.last_commit.identifier.should be("FOOBAR")
284
-
358
+ @project.last_commit.identifier.should == "FOOBAR"
285
359
  @project.last_commit.author.name.should == "<Commit author not loaded>"
286
- @project.last_commit.message.should == "<Commit message not loaded>"
360
+ @project.last_commit.message.should == "<Commit message not loaded>"
287
361
  end
288
362
  end
289
363
  end
@@ -12,7 +12,7 @@
12
12
  %span.who<
13
13
  &== by: #{commit.author.name}
14
14
  |
15
- %span.when{ :title => commit.commited_at }<
15
+ %span.when{ :title => commit.committed_at }<
16
16
  &= pretty_date commit.committed_at
17
17
  |
18
18
  %span.what<
@@ -29,8 +29,7 @@
29
29
  %input.hidden{ :name => "project_data[public]", :value => "0", :type => "hidden" }
30
30
  %input.checkbox#project_public{ checkbox("project_data[public]", @project.public?) }
31
31
 
32
- - Integrity::Notifier.available.each do |notifier|
33
- = notifier_form(notifier)
32
+ - notifier_form
34
33
 
35
34
  %p.submit
36
35
  %button.positive{ :type => "submit" }= @project.new_record? ? "Create Project" : "Update Project"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foca-integrity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9.2
4
+ version: 0.1.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Nicol\xC3\xA1s Sanguinetti"
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-03-16 00:00:00 -07:00
13
+ date: 2009-04-06 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -49,9 +49,9 @@ dependencies:
49
49
  version_requirement:
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.9.10
54
+ version: 0.9.11
55
55
  version:
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: uuidtools
@@ -163,6 +163,16 @@ dependencies:
163
163
  - !ruby/object:Gem::Version
164
164
  version: "0"
165
165
  version:
166
+ - !ruby/object:Gem::Dependency
167
+ name: jeremymcanally-matchy
168
+ type: :development
169
+ version_requirement:
170
+ version_requirements: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: "0"
175
+ version:
166
176
  - !ruby/object:Gem::Dependency
167
177
  name: jeremymcanally-pending
168
178
  type: :development
@@ -194,7 +204,7 @@ extra_rdoc_files: []
194
204
  files:
195
205
  - .gitignore
196
206
  - CHANGES
197
- - README.markdown
207
+ - README.md
198
208
  - Rakefile
199
209
  - bin/integrity
200
210
  - config/config.sample.ru
@@ -227,6 +237,8 @@ files:
227
237
  - lib/integrity/notifier/test/fixtures.rb
228
238
  - lib/integrity/notifier/test/hpricot_matcher.rb
229
239
  - lib/integrity/project.rb
240
+ - lib/integrity/project/notifiers.rb
241
+ - lib/integrity/project/push.rb
230
242
  - lib/integrity/project_builder.rb
231
243
  - lib/integrity/scm.rb
232
244
  - lib/integrity/scm/git.rb
@@ -245,7 +257,6 @@ files:
245
257
  - test/acceptance/installer_test.rb
246
258
  - test/acceptance/manual_build_project_test.rb
247
259
  - test/acceptance/not_found_page_test.rb
248
- - test/acceptance/notifier_test.rb
249
260
  - test/acceptance/project_syndication_test.rb
250
261
  - test/acceptance/stylesheet_test.rb
251
262
  - test/acceptance/unauthorized_page_test.rb
@@ -253,19 +264,20 @@ files:
253
264
  - test/helpers/acceptance.rb
254
265
  - test/helpers/acceptance/email_notifier.rb
255
266
  - test/helpers/acceptance/git_helper.rb
267
+ - test/helpers/acceptance/notifier_helper.rb
256
268
  - test/helpers/acceptance/textfile_notifier.rb
257
269
  - test/helpers/expectations.rb
258
270
  - test/helpers/expectations/be_a.rb
259
271
  - test/helpers/expectations/change.rb
260
272
  - test/helpers/expectations/have.rb
261
273
  - test/helpers/expectations/predicates.rb
262
- - test/helpers/fixtures.rb
263
274
  - test/helpers/initial_migration_fixture.sql
264
275
  - test/unit/build_test.rb
265
276
  - test/unit/commit_test.rb
266
277
  - test/unit/helpers_test.rb
267
278
  - test/unit/integrity_test.rb
268
279
  - test/unit/migrations_test.rb
280
+ - test/unit/notifier/base_test.rb
269
281
  - test/unit/notifier/test_test.rb
270
282
  - test/unit/notifier_test.rb
271
283
  - test/unit/project_builder_test.rb