alphasights-integrity 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.
- data/.gitignore +13 -0
- data/CHANGES +48 -0
- data/README.md +82 -0
- data/Rakefile +58 -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 +137 -0
- data/lib/integrity.rb +77 -0
- data/lib/integrity/app.rb +138 -0
- data/lib/integrity/author.rb +39 -0
- data/lib/integrity/build.rb +52 -0
- data/lib/integrity/commit.rb +61 -0
- data/lib/integrity/core_ext/object.rb +6 -0
- data/lib/integrity/helpers.rb +16 -0
- data/lib/integrity/helpers/authorization.rb +33 -0
- data/lib/integrity/helpers/breadcrumbs.rb +20 -0
- data/lib/integrity/helpers/gravatar.rb +16 -0
- data/lib/integrity/helpers/pretty_output.rb +45 -0
- data/lib/integrity/helpers/rendering.rb +49 -0
- data/lib/integrity/helpers/resources.rb +19 -0
- data/lib/integrity/helpers/urls.rb +59 -0
- data/lib/integrity/installer.rb +138 -0
- data/lib/integrity/migrations.rb +153 -0
- data/lib/integrity/notifier.rb +44 -0
- data/lib/integrity/notifier/base.rb +74 -0
- data/lib/integrity/notifier/test.rb +52 -0
- data/lib/integrity/notifier/test/fixtures.rb +108 -0
- data/lib/integrity/notifier/test/hpricot_matcher.rb +38 -0
- data/lib/integrity/project.rb +94 -0
- data/lib/integrity/project/notifiers.rb +31 -0
- data/lib/integrity/project/push.rb +43 -0
- data/lib/integrity/project_builder.rb +56 -0
- data/lib/integrity/scm.rb +19 -0
- data/lib/integrity/scm/git.rb +84 -0
- data/lib/integrity/scm/git/uri.rb +57 -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 +114 -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 +21 -0
- data/test/acceptance/installer_test.rb +81 -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.rb +75 -0
- data/test/helpers/acceptance.rb +82 -0
- data/test/helpers/acceptance/email_notifier.rb +52 -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/expectations.rb +4 -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/initial_migration_fixture.sql +44 -0
- data/test/unit/build_test.rb +72 -0
- data/test/unit/commit_test.rb +66 -0
- data/test/unit/helpers_test.rb +103 -0
- data/test/unit/integrity_test.rb +35 -0
- data/test/unit/migrations_test.rb +57 -0
- data/test/unit/notifier/base_test.rb +43 -0
- data/test/unit/notifier_test.rb +96 -0
- data/test/unit/project_builder_test.rb +118 -0
- data/test/unit/project_test.rb +344 -0
- data/test/unit/scm_test.rb +54 -0
- data/views/_commit_info.haml +30 -0
- data/views/build.haml +2 -0
- data/views/error.haml +37 -0
- data/views/home.haml +22 -0
- data/views/integrity.sass +424 -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 +31 -0
- data/views/unauthorized.haml +38 -0
- metadata +324 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
module Matchy::Expectations
|
2
|
+
class PredicateExpectation < Base
|
3
|
+
def initialize(predicate, *arguments)
|
4
|
+
@test_case = arguments.pop
|
5
|
+
@predicate = predicate
|
6
|
+
@arguments = arguments
|
7
|
+
end
|
8
|
+
|
9
|
+
def matches?(receiver)
|
10
|
+
@receiver = receiver
|
11
|
+
@receiver.send("#{@predicate}?", *@arguments)
|
12
|
+
end
|
13
|
+
|
14
|
+
def failure_message
|
15
|
+
message = "Expected #{@receiver.inspect} to be #{@predicate}"
|
16
|
+
message << " with #{@arguments.map {|e| e.inspect }.join(", ")}" unless @arguments.empty?
|
17
|
+
message
|
18
|
+
end
|
19
|
+
|
20
|
+
def negative_failure_message
|
21
|
+
message = "Expected #{@receiver.inspect} not to be #{@predicate}"
|
22
|
+
message << " with #{@arguments.map {|e| e.inspect }.join(", ")}" unless @arguments.empty?
|
23
|
+
message
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module TestCaseExtensions
|
28
|
+
def method_missing(method, *args, &block)
|
29
|
+
if method.to_s =~ /^be_(.*)/
|
30
|
+
args << self
|
31
|
+
Matchy::Expectations::PredicateExpectation.new($1, *args)
|
32
|
+
else
|
33
|
+
super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -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');
|
@@ -0,0 +1,72 @@
|
|
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
|
+
end
|
40
|
+
|
41
|
+
describe "Pending builds" do
|
42
|
+
before(:each) do
|
43
|
+
3.of { Build.gen(:started_at => nil) }
|
44
|
+
2.of { Build.gen(:started_at => Time.mktime(2009, 1, 17, 23, 18)) }
|
45
|
+
end
|
46
|
+
|
47
|
+
it "finds builds that need to be built" do
|
48
|
+
Build.should have(3).pending
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "Queueing a build" do
|
53
|
+
before(:each) do
|
54
|
+
@commit = Commit.gen
|
55
|
+
stub.instance_of(ProjectBuilder).build(@commit)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "creates an empty Build" do
|
59
|
+
@commit.build.should be_nil
|
60
|
+
Build.queue(@commit)
|
61
|
+
@commit.build.should_not be_nil
|
62
|
+
end
|
63
|
+
|
64
|
+
it "ensures the build is saved" do
|
65
|
+
@commit.build.should be_nil
|
66
|
+
Build.queue(@commit)
|
67
|
+
|
68
|
+
commit = Commit.first(:identifier => @commit.identifier)
|
69
|
+
commit.build.should_not be_nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,66 @@
|
|
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
|
+
|
36
|
+
Commit.gen(:author => nil).author.to_s.should =~ /not loaded/
|
37
|
+
end
|
38
|
+
|
39
|
+
it "raises ArgumentError with invalid author" do
|
40
|
+
lambda { Commit.gen(:author => "foo") }.should raise_error(ArgumentError)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has a commit message" do
|
44
|
+
commit = Commit.gen(:message => "This commit rocks")
|
45
|
+
commit.message.should == "This commit rocks"
|
46
|
+
|
47
|
+
Commit.gen(:message => nil).message.should =~ /not loaded/
|
48
|
+
end
|
49
|
+
|
50
|
+
it "has a commit date" do
|
51
|
+
commit = Commit.gen(:committed_at => Time.utc(2008, 10, 12, 14, 18, 20))
|
52
|
+
commit.committed_at.to_s.should == "2008-10-12T14:18:20+00:00"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "has a human readable status" do
|
56
|
+
commit = Commit.gen(:successful, :identifier => "658ba96cb0235e82ee720510c049883955200fa9")
|
57
|
+
commit.human_readable_status.should be("Built 658ba96 successfully")
|
58
|
+
|
59
|
+
commit = Commit.gen(:failed, :identifier => "658ba96cb0235e82ee720510c049883955200fa9")
|
60
|
+
commit.human_readable_status.should be("Built 658ba96 and failed")
|
61
|
+
|
62
|
+
commit = Commit.gen(:pending, :identifier => "658ba96cb0235e82ee720510c049883955200fa9")
|
63
|
+
commit.human_readable_status.should be("658ba96 hasn't been built yet")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
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,35 @@
|
|
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
|
+
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{ |i| i.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
|