imbriaco-integrity 0.1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +12 -0
- data/CHANGES +36 -0
- data/README.markdown +79 -0
- data/Rakefile +79 -0
- data/bin/integrity +4 -0
- data/config/config.sample.ru +21 -0
- data/config/config.sample.yml +41 -0
- data/config/heroku/.gems +1 -0
- data/config/heroku/Rakefile +6 -0
- data/config/heroku/config.ru +7 -0
- data/config/heroku/integrity-config.rb +14 -0
- data/config/thin.sample.yml +13 -0
- data/integrity.gemspec +140 -0
- data/lib/integrity/app.rb +138 -0
- data/lib/integrity/author.rb +39 -0
- data/lib/integrity/build.rb +91 -0
- data/lib/integrity/commit.rb +63 -0
- data/lib/integrity/core_ext/object.rb +6 -0
- data/lib/integrity/helpers/authorization.rb +33 -0
- data/lib/integrity/helpers/breadcrumbs.rb +20 -0
- data/lib/integrity/helpers/forms.rb +29 -0
- data/lib/integrity/helpers/pretty_output.rb +45 -0
- data/lib/integrity/helpers/rendering.rb +25 -0
- data/lib/integrity/helpers/resources.rb +19 -0
- data/lib/integrity/helpers/urls.rb +59 -0
- data/lib/integrity/helpers.rb +16 -0
- data/lib/integrity/installer.rb +136 -0
- data/lib/integrity/migrations.rb +151 -0
- data/lib/integrity/notifier/base.rb +74 -0
- data/lib/integrity/notifier/test/fixtures.rb +108 -0
- data/lib/integrity/notifier/test/hpricot_matcher.rb +38 -0
- data/lib/integrity/notifier/test.rb +59 -0
- data/lib/integrity/notifier.rb +34 -0
- data/lib/integrity/project/deprecated.rb +17 -0
- data/lib/integrity/project/notifiers.rb +33 -0
- data/lib/integrity/project/push.rb +44 -0
- data/lib/integrity/project.rb +102 -0
- data/lib/integrity/project_builder.rb +56 -0
- data/lib/integrity/scm/git/uri.rb +57 -0
- data/lib/integrity/scm/git.rb +84 -0
- data/lib/integrity/scm.rb +19 -0
- data/lib/integrity.rb +101 -0
- data/public/buttons.css +82 -0
- data/public/reset.css +7 -0
- data/public/spinner.gif +0 -0
- data/test/acceptance/api_test.rb +97 -0
- data/test/acceptance/browse_project_builds_test.rb +65 -0
- data/test/acceptance/browse_project_test.rb +99 -0
- data/test/acceptance/build_notifications_test.rb +95 -0
- data/test/acceptance/create_project_test.rb +97 -0
- data/test/acceptance/delete_project_test.rb +53 -0
- data/test/acceptance/edit_project_test.rb +117 -0
- data/test/acceptance/error_page_test.rb +18 -0
- data/test/acceptance/installer_test.rb +79 -0
- data/test/acceptance/manual_build_project_test.rb +82 -0
- data/test/acceptance/not_found_page_test.rb +29 -0
- data/test/acceptance/project_syndication_test.rb +30 -0
- data/test/acceptance/stylesheet_test.rb +26 -0
- data/test/acceptance/unauthorized_page_test.rb +20 -0
- data/test/helpers/acceptance/email_notifier.rb +55 -0
- data/test/helpers/acceptance/git_helper.rb +99 -0
- data/test/helpers/acceptance/notifier_helper.rb +47 -0
- data/test/helpers/acceptance/textfile_notifier.rb +26 -0
- data/test/helpers/acceptance.rb +79 -0
- data/test/helpers/expectations/be_a.rb +23 -0
- data/test/helpers/expectations/change.rb +90 -0
- data/test/helpers/expectations/have.rb +105 -0
- data/test/helpers/expectations/predicates.rb +37 -0
- data/test/helpers/expectations.rb +4 -0
- data/test/helpers/fixtures.rb +87 -0
- data/test/helpers/initial_migration_fixture.sql +44 -0
- data/test/helpers.rb +87 -0
- data/test/unit/build_test.rb +86 -0
- data/test/unit/commit_test.rb +62 -0
- data/test/unit/helpers_test.rb +103 -0
- data/test/unit/integrity_test.rb +52 -0
- data/test/unit/migrations_test.rb +57 -0
- data/test/unit/notifier/base_test.rb +43 -0
- data/test/unit/notifier/test_test.rb +29 -0
- data/test/unit/notifier_test.rb +85 -0
- data/test/unit/project_builder_test.rb +118 -0
- data/test/unit/project_test.rb +371 -0
- data/test/unit/scm_test.rb +54 -0
- data/views/_commit_info.haml +24 -0
- data/views/build.haml +2 -0
- data/views/error.haml +37 -0
- data/views/home.haml +21 -0
- data/views/integrity.sass +400 -0
- data/views/layout.haml +29 -0
- data/views/new.haml +50 -0
- data/views/not_found.haml +31 -0
- data/views/notifier.haml +7 -0
- data/views/project.builder +21 -0
- data/views/project.haml +30 -0
- data/views/unauthorized.haml +38 -0
- metadata +327 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
CREATE TABLE "integrity_builds" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "output" TEXT NOT NULL DEFAULT '', "successful" BOOLEAN NOT NULL DEFAULT 'f', "commit_identifier" VARCHAR(50) NOT NULL, "commit_metadata" TEXT NOT NULL, "created_at" DATETIME, "updated_at" DATETIME, "project_id" INTEGER);
|
2
|
+
INSERT INTO "integrity_builds" VALUES(1,'rake aborted!
|
3
|
+
Don''t know how to build task ''default''
|
4
|
+
/home/simon/.gems/gems/rake-0.8.3/lib/rake.rb:1706:in `[]''
|
5
|
+
(See full trace by running task with --trace)
|
6
|
+
(in /home/simon/bar/builds/sr-shout-bot-master)
|
7
|
+
','f','348e9e27fa72645518fc539b77f1c37fcc20ab11','---
|
8
|
+
:message: had to allow for registration time
|
9
|
+
:date: 2009-01-04 06:19:30 +0800
|
10
|
+
:author: syd <syd@teh.magicha.us>
|
11
|
+
','2009-02-17T19:48:31+01:00','2009-02-17T19:48:31+01:00',1);
|
12
|
+
INSERT INTO "integrity_builds" VALUES(2,'....*...........
|
13
|
+
|
14
|
+
Pending:
|
15
|
+
ShoutBot When using Shouter.shout passes given block to join (TODO)
|
16
|
+
Called from shout-bot.rb:113
|
17
|
+
|
18
|
+
Finished in 10.222458 seconds
|
19
|
+
|
20
|
+
16 examples, 0 failures, 1 pending
|
21
|
+
','t','348e9e27fa72645518fc539b77f1c37fcc20ab11','---
|
22
|
+
:message: had to allow for registration time
|
23
|
+
:date: 2009-01-04 06:19:30 +0800
|
24
|
+
:author: syd <syd@teh.magicha.us>
|
25
|
+
','2009-02-17T19:49:05+01:00','2009-02-17T19:49:05+01:00',1);
|
26
|
+
INSERT INTO "integrity_builds" VALUES(3,'(in /home/simon/bar/builds/sinatra-sinatra-master)
|
27
|
+
Loaded suite /home/simon/.gems/gems/rake-0.8.3/lib/rake/rake_test_loader
|
28
|
+
Started
|
29
|
+
.......................................................................................................................................................................................................................................
|
30
|
+
Finished in 1.097704 seconds.
|
31
|
+
|
32
|
+
231 tests, 437 assertions, 0 failures, 0 errors
|
33
|
+
','t','a2f5803ec642c43ece86ad96676c45f44fe3746e','---
|
34
|
+
:message: Allow dot in named param capture [#153]
|
35
|
+
:date: 2009-02-17 09:32:58 -0800
|
36
|
+
:author: Ryan Tomayko <rtomayko@gmail.com>
|
37
|
+
','2009-02-17T19:50:11+01:00','2009-02-17T19:50:11+01:00',2);
|
38
|
+
DELETE FROM sqlite_sequence;
|
39
|
+
INSERT INTO "sqlite_sequence" VALUES('integrity_projects',2);
|
40
|
+
INSERT INTO "sqlite_sequence" VALUES('integrity_builds',3);
|
41
|
+
CREATE TABLE "integrity_notifiers" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "name" VARCHAR(50) NOT NULL, "config" TEXT NOT NULL, "project_id" INTEGER);
|
42
|
+
CREATE TABLE "integrity_projects" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "name" VARCHAR(50) NOT NULL, "permalink" VARCHAR(50), "uri" VARCHAR(255) NOT NULL, "branch" VARCHAR(50) NOT NULL DEFAULT 'master', "command" VARCHAR(255) NOT NULL DEFAULT 'rake', "public" BOOLEAN DEFAULT 't', "building" BOOLEAN DEFAULT 'f', "created_at" DATETIME, "updated_at" DATETIME);
|
43
|
+
INSERT INTO "integrity_projects" VALUES(1,'Shout Bot','shout-bot','git://github.com/sr/shout-bot.git','master','ruby shout-bot.rb','t','f','2009-02-17T19:48:23+01:00','2009-02-17T19:49:05+01:00');
|
44
|
+
INSERT INTO "integrity_projects" VALUES(2,'Sinatra','sinatra','git://github.com/sinatra/sinatra.git','master','rake compat test','t','f','2009-02-17T19:49:48+01:00','2009-02-17T19:50:22+01:00');
|
data/test/helpers.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__) + "/../lib", File.dirname(__FILE__)
|
2
|
+
|
3
|
+
%w(test/unit
|
4
|
+
context
|
5
|
+
pending
|
6
|
+
matchy
|
7
|
+
storyteller
|
8
|
+
webrat/sinatra
|
9
|
+
rr
|
10
|
+
mocha
|
11
|
+
dm-sweatshop).each { |dependency|
|
12
|
+
begin
|
13
|
+
require dependency
|
14
|
+
rescue LoadError => e
|
15
|
+
puts "You're missing some gems required to run the tests."
|
16
|
+
puts "Please run `rake test:setup`"
|
17
|
+
puts "NOTE: You'll probably need to run that command as root or with sudo."
|
18
|
+
|
19
|
+
puts "Thanks :)"
|
20
|
+
puts
|
21
|
+
|
22
|
+
raise
|
23
|
+
end
|
24
|
+
}
|
25
|
+
|
26
|
+
begin
|
27
|
+
require "ruby-debug"
|
28
|
+
require "redgreen"
|
29
|
+
rescue LoadError
|
30
|
+
end
|
31
|
+
|
32
|
+
require "integrity"
|
33
|
+
require "helpers/expectations"
|
34
|
+
require "integrity/notifier/test/fixtures"
|
35
|
+
|
36
|
+
module TestHelper
|
37
|
+
def ignore_logs!
|
38
|
+
Integrity.config[:log] = "/tmp/integrity.test.log"
|
39
|
+
end
|
40
|
+
|
41
|
+
def capture_stdout
|
42
|
+
output = StringIO.new
|
43
|
+
$stdout = output
|
44
|
+
yield
|
45
|
+
$stdout = STDOUT
|
46
|
+
output
|
47
|
+
end
|
48
|
+
|
49
|
+
def silence_warnings
|
50
|
+
$VERBOSE, v = nil, $VERBOSE
|
51
|
+
yield
|
52
|
+
ensure
|
53
|
+
$VERBOSE = v
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class Test::Unit::TestCase
|
58
|
+
class << self
|
59
|
+
alias_method :specify, :test
|
60
|
+
end
|
61
|
+
|
62
|
+
include RR::Adapters::TestUnit
|
63
|
+
include Integrity
|
64
|
+
include TestHelper
|
65
|
+
|
66
|
+
before(:all) do
|
67
|
+
DataMapper.setup(:default, "sqlite3::memory:")
|
68
|
+
end
|
69
|
+
|
70
|
+
before(:each) do
|
71
|
+
require "integrity/migrations"
|
72
|
+
[Project, Build, Commit, Notifier].each(&:auto_migrate_down!)
|
73
|
+
capture_stdout { Integrity.migrate_db }
|
74
|
+
|
75
|
+
RR.reset
|
76
|
+
|
77
|
+
Notifier.available.each { |n|
|
78
|
+
Notifier.send(:remove_const, n.to_s.split(":").last.to_sym)
|
79
|
+
}
|
80
|
+
Integrity.instance_variable_set(:@config, nil)
|
81
|
+
Integrity.instance_variable_set(:@notifiers, nil)
|
82
|
+
end
|
83
|
+
|
84
|
+
after(:each) do
|
85
|
+
capture_stdout { Integrity::Migrations.migrate_down! }
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../helpers'
|
2
|
+
|
3
|
+
class BuildTest < Test::Unit::TestCase
|
4
|
+
before(:each) do
|
5
|
+
RR.reset
|
6
|
+
end
|
7
|
+
|
8
|
+
specify "fixture is valid and can be saved" do
|
9
|
+
lambda do
|
10
|
+
build = Build.gen
|
11
|
+
build.save
|
12
|
+
|
13
|
+
build.should be_valid
|
14
|
+
end.should change(Build, :count).by(1)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "Properties" do
|
18
|
+
before(:each) do
|
19
|
+
@build = Build.gen
|
20
|
+
end
|
21
|
+
|
22
|
+
it "captures the build's STDOUT/STDERR" do
|
23
|
+
@build.output.should_not be_blank
|
24
|
+
end
|
25
|
+
|
26
|
+
it "knows if it failed or not" do
|
27
|
+
@build.successful = true
|
28
|
+
@build.should be_successful
|
29
|
+
@build.successful = false
|
30
|
+
@build.should be_failed
|
31
|
+
end
|
32
|
+
|
33
|
+
it "knows it's status" do
|
34
|
+
@build.successful = true
|
35
|
+
@build.status.should be(:success)
|
36
|
+
@build.successful = false
|
37
|
+
@build.status.should be(:failed)
|
38
|
+
end
|
39
|
+
|
40
|
+
test "deprecated properties" do
|
41
|
+
pending do
|
42
|
+
silence_warnings {
|
43
|
+
@build.short_commit_identifier.should == @build.commit.short_identifier
|
44
|
+
@build.commit_identifier.should == @build.commit.identifier
|
45
|
+
@build.commit_author.should == @build.commit.author
|
46
|
+
@build.commit_message.should == @build.commit.message
|
47
|
+
@build.commited_at.should == @build.commit.committed_at
|
48
|
+
@build.project_id.should == @build.commit.project_id
|
49
|
+
@build.should respond_to(:commit_metadata)
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "Pending builds" do
|
56
|
+
before(:each) do
|
57
|
+
3.of { Build.gen(:started_at => nil) }
|
58
|
+
2.of { Build.gen(:started_at => Time.mktime(2009, 1, 17, 23, 18)) }
|
59
|
+
end
|
60
|
+
|
61
|
+
it "finds builds that need to be built" do
|
62
|
+
Build.should have(3).pending
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "Queueing a build" do
|
67
|
+
before(:each) do
|
68
|
+
@commit = Commit.gen
|
69
|
+
stub.instance_of(ProjectBuilder).build(@commit)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "creates an empty Build" do
|
73
|
+
@commit.build.should be_nil
|
74
|
+
Build.queue(@commit)
|
75
|
+
@commit.build.should_not be_nil
|
76
|
+
end
|
77
|
+
|
78
|
+
it "ensures the build is saved" do
|
79
|
+
@commit.build.should be_nil
|
80
|
+
Build.queue(@commit)
|
81
|
+
|
82
|
+
commit = Commit.first(:identifier => @commit.identifier)
|
83
|
+
commit.build.should_not be_nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../helpers'
|
2
|
+
|
3
|
+
class CommitTest < Test::Unit::TestCase
|
4
|
+
specify "fixture is valid and can be saved" do
|
5
|
+
lambda do
|
6
|
+
commit = Commit.gen
|
7
|
+
commit.save
|
8
|
+
|
9
|
+
commit.should be_valid
|
10
|
+
end.should change(Commit, :count).by(1)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "Properties" do
|
14
|
+
before(:each) do
|
15
|
+
@commit = Commit.generate(:identifier => "658ba96cb0235e82ee720510c049883955200fa9",
|
16
|
+
:author => "Nicolás Sanguinetti <contacto@nicolassanguinetti.info>")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "has a commit identifier" do
|
20
|
+
@commit.identifier.should be("658ba96cb0235e82ee720510c049883955200fa9")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "has a short commit identifier" do
|
24
|
+
@commit.short_identifier.should == "658ba96"
|
25
|
+
|
26
|
+
@commit.identifier = "402"
|
27
|
+
@commit.short_identifier.should == "402"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has a commit author" do
|
31
|
+
commit = Commit.gen(:author => "Nicolás Sanguinetti <contacto@nicolassanguinetti.info>")
|
32
|
+
commit.author.name.should == "Nicolás Sanguinetti"
|
33
|
+
commit.author.email.should == "contacto@nicolassanguinetti.info"
|
34
|
+
commit.author.full.should == "Nicolás Sanguinetti <contacto@nicolassanguinetti.info>"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "raises ArgumentError with invalid author" do
|
38
|
+
lambda { Commit.gen(:author => "foo") }.should raise_error(ArgumentError)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "has a commit message" do
|
42
|
+
commit = Commit.gen(:message => "This commit rocks")
|
43
|
+
commit.message.should == "This commit rocks"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "has a commit date" do
|
47
|
+
commit = Commit.gen(:committed_at => Time.utc(2008, 10, 12, 14, 18, 20))
|
48
|
+
commit.committed_at.to_s.should == "2008-10-12T14:18:20+00:00"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "has a human readable status" do
|
52
|
+
commit = Commit.gen(:successful, :identifier => "658ba96cb0235e82ee720510c049883955200fa9")
|
53
|
+
commit.human_readable_status.should be("Built 658ba96 successfully")
|
54
|
+
|
55
|
+
commit = Commit.gen(:failed, :identifier => "658ba96cb0235e82ee720510c049883955200fa9")
|
56
|
+
commit.human_readable_status.should be("Built 658ba96 and failed")
|
57
|
+
|
58
|
+
commit = Commit.gen(:pending, :identifier => "658ba96cb0235e82ee720510c049883955200fa9")
|
59
|
+
commit.human_readable_status.should be("658ba96 hasn't been built yet")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helpers"
|
2
|
+
|
3
|
+
class BrowsePublicProjectsTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@h = Module.new { extend Integrity::Helpers }
|
6
|
+
end
|
7
|
+
|
8
|
+
test "#pretty_date" do
|
9
|
+
@h.pretty_date(Time.now).should == "today"
|
10
|
+
@h.pretty_date(Time.new - 86400).should == "yesterday"
|
11
|
+
|
12
|
+
@h.pretty_date(Time.mktime(1995, 12, 01)).should == "on Dec 01st"
|
13
|
+
@h.pretty_date(Time.mktime(1995, 12, 21)).should == "on Dec 21st"
|
14
|
+
@h.pretty_date(Time.mktime(1995, 12, 31)).should == "on Dec 31st"
|
15
|
+
|
16
|
+
@h.pretty_date(Time.mktime(1995, 12, 22)).should == "on Dec 22nd"
|
17
|
+
@h.pretty_date(Time.mktime(1995, 12, 22)).should == "on Dec 22nd"
|
18
|
+
|
19
|
+
@h.pretty_date(Time.mktime(1995, 12, 03)).should == "on Dec 03rd"
|
20
|
+
@h.pretty_date(Time.mktime(1995, 12, 23)).should == "on Dec 23rd"
|
21
|
+
|
22
|
+
@h.pretty_date(Time.mktime(1995, 12, 15)).should == "on Dec 15th"
|
23
|
+
@h.pretty_date(Time.mktime(1995, 12, 15)).should == "on Dec 15th"
|
24
|
+
@h.pretty_date(Time.mktime(1995, 12, 15)).should == "on Dec 15th"
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "urls" do
|
28
|
+
before do
|
29
|
+
Integrity.config[:base_uri] = "http://example.org/ci"
|
30
|
+
|
31
|
+
@project = Project.gen(:name => "Foo Bar")
|
32
|
+
@build = Build.gen(:successful)
|
33
|
+
@commit = @build.commit
|
34
|
+
end
|
35
|
+
|
36
|
+
test "root" do
|
37
|
+
assert_equal "http://example.org/ci", @h.root_url.to_s
|
38
|
+
assert_equal "/ci", @h.root_path
|
39
|
+
assert_equal "/ci/stylesheet.css", @h.root_path("/stylesheet.css")
|
40
|
+
|
41
|
+
Integrity.config[:base_uri] = nil
|
42
|
+
@h.instance_variable_set(:@url, nil)
|
43
|
+
lambda { @h.root_url }.should raise_error
|
44
|
+
|
45
|
+
stub(@h).request { OpenStruct.new(:url => "http://0.0.0.0/") }
|
46
|
+
assert_equal "http://0.0.0.0/", @h.root_url.to_s
|
47
|
+
end
|
48
|
+
|
49
|
+
test "project" do
|
50
|
+
assert_equal "/ci/foo-bar", @h.project_path(@project)
|
51
|
+
assert_equal "http://example.org/ci/foo-bar",
|
52
|
+
@h.project_url(@project).to_s
|
53
|
+
end
|
54
|
+
|
55
|
+
test "commit" do
|
56
|
+
silence_warnings {
|
57
|
+
assert_equal "/ci/foo-bar/commits/#{@commit.identifier}",
|
58
|
+
@h.commit_path(@build.commit)
|
59
|
+
assert_equal "http://example.org/ci/foo-bar/commits/#{@commit.identifier}",
|
60
|
+
@h.commit_url(@build.commit).to_s
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
test "compat" do
|
65
|
+
silence_warnings {
|
66
|
+
assert_equal @h.build_path(@build), @h.commit_path(@build.commit)
|
67
|
+
assert_equal @h.build_url(@build), @h.commit_url(@build.commit)
|
68
|
+
}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#push_url_for" do
|
73
|
+
before(:each) do
|
74
|
+
@project = Project.gen(:integrity)
|
75
|
+
Integrity.config[:admin_username] = "admin"
|
76
|
+
Integrity.config[:admin_password] = "test"
|
77
|
+
Integrity.config[:base_uri] = "http://integrity.example.org:1234"
|
78
|
+
end
|
79
|
+
|
80
|
+
test "with auth disabled" do
|
81
|
+
Integrity.config[:use_basic_auth] = false
|
82
|
+
|
83
|
+
assert_equal "http://integrity.example.org:1234/integrity/push",
|
84
|
+
@h.push_url_for(@project)
|
85
|
+
end
|
86
|
+
|
87
|
+
test "with auth and hashing enabled" do
|
88
|
+
Integrity.config[:use_basic_auth] = true
|
89
|
+
Integrity.config[:hash_admin_password] = true
|
90
|
+
|
91
|
+
assert_equal "http://admin:<password>@integrity.example.org:1234/integrity/push",
|
92
|
+
@h.push_url_for(@project)
|
93
|
+
end
|
94
|
+
|
95
|
+
test "with auth enabled and hashing disabled" do
|
96
|
+
Integrity.config[:use_basic_auth] = true
|
97
|
+
Integrity.config[:hash_admin_password] = false
|
98
|
+
|
99
|
+
assert_equal "http://admin:test@integrity.example.org:1234/integrity/push",
|
100
|
+
@h.push_url_for(@project)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helpers"
|
2
|
+
|
3
|
+
class IntegrityTest < Test::Unit::TestCase
|
4
|
+
describe "#new" do
|
5
|
+
setup do
|
6
|
+
stub(DataMapper).setup { nil }
|
7
|
+
@config_file = File.dirname(__FILE__) + "/../../config/config.sample.yml"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "doesn't require any argument" do
|
11
|
+
Integrity.new
|
12
|
+
|
13
|
+
assert_equal Integrity.default_configuration[:log],
|
14
|
+
Integrity.config[:log]
|
15
|
+
end
|
16
|
+
|
17
|
+
it "loads configuration from a file" do
|
18
|
+
Integrity.new(@config_file)
|
19
|
+
|
20
|
+
assert_equal "http://integrity.domain.tld", Integrity.config[:base_uri]
|
21
|
+
assert_equal "/path/to/scm/exports", Integrity.config[:export_directory]
|
22
|
+
end
|
23
|
+
|
24
|
+
it "takes configuration as an hash" do
|
25
|
+
Integrity.new(:base_uri => "http://foo.org")
|
26
|
+
|
27
|
+
assert_equal "http://foo.org", Integrity.config[:base_uri]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
specify "config is just a hash" do
|
32
|
+
Integrity.config[:foo] = "bar"
|
33
|
+
Integrity.config[:foo].should == "bar"
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "Registering a notifier" do
|
37
|
+
it "registers given notifier class" do
|
38
|
+
load "helpers/acceptance/textfile_notifier.rb"
|
39
|
+
|
40
|
+
Integrity.register_notifier(Integrity::Notifier::Textfile)
|
41
|
+
assert_equal Integrity::Notifier::Textfile, Integrity.notifiers["Textfile"]
|
42
|
+
end
|
43
|
+
|
44
|
+
it "raises ArgumentError if given class is not a valid notifier" do
|
45
|
+
assert_raise(ArgumentError) {
|
46
|
+
Integrity.register_notifier(Class.new)
|
47
|
+
}
|
48
|
+
|
49
|
+
assert Integrity.notifiers.empty?
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helpers"
|
2
|
+
|
3
|
+
class MigrationsTest < Test::Unit::TestCase
|
4
|
+
def database_adapter
|
5
|
+
DataMapper.repository(:default).adapter
|
6
|
+
end
|
7
|
+
|
8
|
+
def table_exists?(table_name)
|
9
|
+
database_adapter.storage_exists?(table_name)
|
10
|
+
end
|
11
|
+
|
12
|
+
def current_migrations
|
13
|
+
database_adapter.query("SELECT * from migration_info")
|
14
|
+
end
|
15
|
+
|
16
|
+
def load_initial_migration_fixture
|
17
|
+
database_adapter.execute(File.read(File.dirname(__FILE__) +
|
18
|
+
"/../helpers/initial_migration_fixture.sql"))
|
19
|
+
end
|
20
|
+
|
21
|
+
before(:all) do
|
22
|
+
require "integrity/migrations"
|
23
|
+
end
|
24
|
+
|
25
|
+
before(:each) do
|
26
|
+
[Project, Build, Commit, Notifier].each(&:auto_migrate_down!)
|
27
|
+
database_adapter.execute("DROP TABLE migration_info")
|
28
|
+
assert !table_exists?("migration_info") # just to be sure
|
29
|
+
end
|
30
|
+
|
31
|
+
test "upgrading a pre migration database" do
|
32
|
+
capture_stdout { Integrity.migrate_db }
|
33
|
+
|
34
|
+
current_migrations.should == ["initial", "add_commits", "add_enabled_column"]
|
35
|
+
assert table_exists?("integrity_projects")
|
36
|
+
assert table_exists?("integrity_builds")
|
37
|
+
assert table_exists?("integrity_notifiers")
|
38
|
+
assert table_exists?("integrity_commits")
|
39
|
+
end
|
40
|
+
|
41
|
+
test "migrating data from initial to add_commits migration" do
|
42
|
+
load_initial_migration_fixture
|
43
|
+
|
44
|
+
capture_stdout { Integrity.migrate_db }
|
45
|
+
current_migrations.should == ["initial", "add_commits", "add_enabled_column"]
|
46
|
+
|
47
|
+
sinatra = Project.first(:name => "Sinatra")
|
48
|
+
sinatra.should have(1).commits
|
49
|
+
sinatra.commits.first.should be_successful
|
50
|
+
sinatra.commits.first.output.should =~ /sinatra/
|
51
|
+
|
52
|
+
shout_bot = Project.first(:name => "Shout Bot")
|
53
|
+
shout_bot.should have(1).commits
|
54
|
+
shout_bot.commits.first.should be_failed
|
55
|
+
shout_bot.commits.first.output.should =~ /shout-bot/
|
56
|
+
end
|
57
|
+
end
|
@@ -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
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../helpers"
|
2
|
+
require "helpers/acceptance/textfile_notifier"
|
3
|
+
|
4
|
+
require "integrity/notifier/test"
|
5
|
+
|
6
|
+
class NotifierTestTest < Test::Unit::TestCase
|
7
|
+
include Integrity::Notifier::Test
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
# Because we unset every notifier in global setup
|
11
|
+
load "helpers/acceptance/textfile_notifier.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
def notifier
|
15
|
+
"Textfile"
|
16
|
+
end
|
17
|
+
|
18
|
+
test "it provides a formulary to configure options" do
|
19
|
+
assert_form_have_option("file")
|
20
|
+
end
|
21
|
+
|
22
|
+
test "it sends notification" do
|
23
|
+
commit = Integrity::Commit.gen(:build => Build.gen(:successful))
|
24
|
+
|
25
|
+
assert notification(commit).include?(commit.identifier)
|
26
|
+
assert notification_failed.include?("failed")
|
27
|
+
assert notification_successful.include?("was successful")
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helpers"
|
2
|
+
|
3
|
+
class NotifierTest < Test::Unit::TestCase
|
4
|
+
specify "IRC fixture is valid and can be saved" do
|
5
|
+
lambda do
|
6
|
+
Notifier.generate(:irc).tap do |project|
|
7
|
+
project.should be_valid
|
8
|
+
project.save
|
9
|
+
end
|
10
|
+
end.should change(Project, :count).by(1)
|
11
|
+
end
|
12
|
+
|
13
|
+
specify "Twitter fixture is valid and can be saved" do
|
14
|
+
lambda do
|
15
|
+
Notifier.generate(:twitter).tap do |project|
|
16
|
+
project.should be_valid
|
17
|
+
project.save
|
18
|
+
end
|
19
|
+
end.should change(Project, :count).by(1)
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "Properties" do
|
23
|
+
before(:each) do
|
24
|
+
@notifier = Notifier.generate(:irc)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "has a name" do
|
28
|
+
@notifier.name.should == "IRC"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "has a config" do
|
32
|
+
@notifier.config.should == {:uri => "irc://irc.freenode.net/integrity"}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "Validation" do
|
37
|
+
it "requires a name" do
|
38
|
+
lambda do
|
39
|
+
Notifier.generate(:irc, :name => nil)
|
40
|
+
end.should_not change(Notifier, :count)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "requires a config" do
|
44
|
+
lambda do
|
45
|
+
Notifier.generate(:irc, :config => nil)
|
46
|
+
end.should_not change(Notifier, :count)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "requires a project" do
|
50
|
+
lambda do
|
51
|
+
Notifier.generate(:irc, :project => nil)
|
52
|
+
end.should_not change(Notifier, :count)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "requires an unique name in project scope" do
|
56
|
+
project = Project.generate
|
57
|
+
irc = Notifier.gen(:irc, :project => project)
|
58
|
+
|
59
|
+
project.tap { |project| project.notifiers << irc }.save
|
60
|
+
|
61
|
+
lambda do
|
62
|
+
project.tap { |project| project.notifiers << irc }.save
|
63
|
+
end.should_not change(project.notifiers, :count).from(1).to(2)
|
64
|
+
|
65
|
+
lambda { Notifier.gen(:irc) }.should change(Notifier, :count).to(2)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
test "managing available notifiers" do
|
70
|
+
Notifier.gen(:irc)
|
71
|
+
Notifier.register(Integrity::Notifier::IRC)
|
72
|
+
|
73
|
+
assert_equal 1, Notifier.available.size
|
74
|
+
end
|
75
|
+
|
76
|
+
it "knows how to notify the world of a build" do
|
77
|
+
irc = Notifier.gen(:irc)
|
78
|
+
Notifier.register(Integrity::Notifier::IRC)
|
79
|
+
build = Build.gen
|
80
|
+
|
81
|
+
mock(Notifier::IRC).notify_of_build(build, irc.config) { nil }
|
82
|
+
|
83
|
+
irc.notify_of_build(build)
|
84
|
+
end
|
85
|
+
end
|